wok-6.x view glpi/receipt @ rev 8353

up: glpi (0.78.2) + improve install
author Eric Joseph-Alexandre <erjo@slitaz.org>
date Thu Feb 03 17:09:38 2011 +0100 (2011-02-03)
parents c43ee66023b0
children 9dde2e58512f
line source
1 # SliTaz package receipt.
3 PACKAGE="glpi"
4 VERSION="0.78.2"
5 CATEGORY="network"
6 SHORT_DESC="IT and Asset Management."
7 MAINTAINER="erjo@slitaz.org"
8 DEPENDS="mysql apache php-apache php-ldap php-imap php-mysql pam logrotate"
9 TARBALL="$PACKAGE-$VERSION.tar.gz"
10 WEB_SITE="http://glpi-project.org/"
11 WGET_URL="https://forge.indepnet.net/attachments/download/772/$TARBALL"
12 CONFIG_FILES="/etc/glpi/config_db.php /etc/glpi/config_db_slave.php"
14 # Rules to gen a SliTaz package suitable for Tazpkg.
15 genpkg_rules()
16 {
17 test -d $PACKAGE && mv $PACKAGE $PACKAGE-$VERSION
19 _pkg=$src
21 mkdir -p $fs/usr/share/$PACKAGE \
22 $fs/etc/$PACKAGE \
23 $fs/var/log/$PACKAGE \
24 $fs/var/lib/$PACKAGE
26 cp -a $_pkg/* $fs/usr/share/$PACKAGE
27 [ -d $fs/usr/share/$PACKAGE/files ] && mv $fs/usr/share/$PACKAGE/files $fs/var/lib/$PACKAGE
28 #[ -d $fs/usr/share/$PACKAGE/config ] && mv $fs/usr/share/$PACKAGE/config $fs/etc/$PACKAGE
30 # Copy config db as temporary file.
31 cp stuff/config_db.php $fs/etc/glpi/
32 cp -a stuff/logrotate.d $fs/etc
34 cd $fs/usr/share/glpi
35 [ -f config/config_db.php ] && rm -f config/config_db.php
36 [ -f config/config_db_slave.php ] && rm -f config/config_db_slave.php
37 ln -s /etc/glpi/config_db.php config/
38 [ -f $fs/etc/glpi/config_db_slave.php ] && ln -s /etc/glpi/config_db_slave.php config/
39 ln -s /var/lib/glpi/files
40 cd -
41 chown -R www.www $fs/var/lib/$PACKAGE/files $fs/etc/$PACKAGE/*
43 # Create the magic file config_path.php
44 cat <<EOF> $fs/usr/share/glpi/config/config_path.php
45 <?php
46 // for packaging defaults
48 define("GLPI_CONFIG_DIR", "/etc/glpi");
50 define("GLPI_DOC_DIR", "/var/lib/glpi/files");
51 define("GLPI_DUMP_DIR", "/var/lib/glpi/files/_dumps");
52 define("GLPI_CACHE_DIR", "/var/lib/glpi/files/_cache/");
53 define("GLPI_CRON_DIR", "/var/lib/glpi/files/_cron");
54 define("GLPI_SESSION_DIR", "/var/lib/glpi/files/_sessions");
55 define("GLPI_PLUGIN_DOC_DIR", "/var/lib/glpi/files/_plugins");
56 define("GLPI_LOCK_DIR", "/var/lib/glpi/files/_lock/");
58 define("GLPI_LOG_DIR", "/var/log/glpi");
59 ?>
61 EOF
62 }
64 post_install()
65 {
66 # Configure apache server
67 if [ -f $1/etc/apache/httpd.conf ]; then
68 if [ ! -f $1/etc/apache/conf.d/glpi ]; then
69 cat > $1/etc/apache/conf.d/glpi <<EOT
70 <IfModule mod_alias.c>
71 Alias /glpi /usr/share/glpi/
72 </IfModule>
73 <Directory "/usr/share/glpi">
74 Options Indexes FollowSymLinks
76 php_value memory_limit 64M
78 AllowOverride None
79 Order deny,allow
80 Allow from all
81 </Directory>
83 <Directory /usr/share/glpi/config>
84 Order Allow,Deny
85 Deny from all
86 </Directory>
88 <Directory /usr/share/glpi/locales>
89 Order Allow,Deny
90 Deny from all
91 </Directory>
93 <Directory /usr/share/glpi/install/mysql>
94 Order Allow,Deny
95 Deny from all
96 </Directory>
98 <Directory /usr/share/glpi/scripts>
99 Order Allow,Deny
100 Deny from all
101 </Directory>
104 EOT
105 if [ -z "$1" ]; then
106 # Start Web server.
107 test -f /var/run/apache/httpd.pid && \
108 ( kill -0 $(cat /var/run/apache/httpd.pid) && /etc/init.d/apache restart )
109 fi
110 fi
111 fi
113 # Configure every thing for glpi.
114 if [ -z $1 ]; then
115 if ( ! mysqladmin -s ping > /dev/null ); then
116 echo "Starting MySQL server"
117 ( /etc/init.d/mysql start ; status ) || exit
118 sleep 4 #let the mysql daemon start
119 fi
120 if ( ! mysql -u root -Be 'show databases' | grep -q glpi ); then
121 echo -n "Create Glpi database"
122 mysql -Be "create database glpi" ; status
123 # We suppose that glpi user does not exist.
124 # It may be false.
125 echo -n "Create user glpi with password glpi"
126 mysql -Be "grant all privileges on glpi.* to 'glpi'@'localhost'
127 identified by 'glpi'" ; status
128 # At last create the database for glpi.
129 echo -n "Create glpi database schema."
130 mysql -u glpi -pglpi -D glpi < /usr/share/glpi/install/mysql/glpi-${VERSION}-empty.sql ; status
132 fi
134 fi
135 }
137 post_remove()
138 {
139 echo -n "Would you like to remove data and database files.(y/n) "
140 read answer
142 case $answer in
143 y|Y)
144 echo -n "Removing data directories..."
145 rm -rf /var/lib/glpi ; status
146 if ( mysql -u root -Be 'show databases' | grep -q glpi ); then
147 echo -n "Deleting Glpi database"
148 mysql -Be "drop database glpi" ; status
149 # We suppose that glpi user does not exist.
150 # It may be false.
151 echo -n "Delete user glpi"
152 mysql -Be "delete from mysql.db where user='glpi'" ; status
153 fi
154 unset $answer
155 ;;
156 *)
157 ;;
158 esac
160 }