wok-next view ocsinventory/receipt @ rev 20674
Up putty (0.70)
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Sat May 12 05:17:48 2018 +0300 (2018-05-12) |
parents | fe76d2fe539b |
children | e8933007f065 |
line source
1 # SliTaz package receipt v2.
3 PACKAGE="ocsinventory"
4 VERSION="2.3.1"
5 CATEGORY="meta"
6 SHORT_DESC="Automated inventory and deployement system."
7 MAINTAINER="pascal.bellard@slitaz.org"
8 LICENSE="GPL2"
9 SOURCE="OCSNG_UNIX_SERVER"
10 TARBALL="$SOURCE-$VERSION.tar.gz"
11 WEB_SITE="http://www.ocsinventory-ng.org/"
12 WGET_URL="https://github.com/OCSInventory-NG/OCSInventory-Server/archive/$VERSION.tar.gz"
13 TAGS="system administration"
15 BUILD_DEPENDS="perl perl-dbd-mysql perl-apache-dbi perl-net-ip perl-xml-simple \
16 wget"
17 SPLIT="ocsinventory ocsinventory-server ocsreports"
19 # Rules to configure and make the package.
20 compile_rules()
21 {
22 cd $src/Apache
23 perl Makefile.PL &&
24 make &&
25 make DESTDIR=$DESTDIR install
26 }
28 genpkg_rules()
29 {
30 case $PACKAGE in
31 ocsinventory)
32 DEPENDS="ocsinventory-server ocsinventory-agent ocsreports"
33 mkdir $fs/usr
34 ;;
35 ocsinventory-server)
36 CAT="network|Iventory and package deployment system"
37 DEPENDS="apache php-apache mysql perl perl-xml-simple \
38 perl-compress-raw-zlib perl-dbi perl-dbd-mysql \
39 perl-apache-dbi perl-net-ip perl-soap-lite \
40 perl-xml-parser perl-xml-sax-writer apache-mod-perl"
41 mkdir -p $fs/usr
42 cp -a $install/usr/lib $fs/usr
44 install -o www -g www -m 0775 -d $fs/var/log/ocsinventory-server
45 install -o root -g www -m 0775 -d $fs/var/lib/ocsinventory-server/ipd
46 install -o root -g www -m 0775 -d $fs/var/lib/ocsinventory-server/download
48 mkdir -p $fs/etc/logrotate.d
49 cp -f $src/etc/logrotate.d/ocsinventory-server \
50 $fs/etc/logrotate.d/ocsinventory-server
51 sed -i "s#PATH_TO_LOG_DIRECTORY#/var/log/ocsinventory-server#g" \
52 $fs/etc/logrotate.d/ocsinventory-server
54 mkdir -p $fs/etc/apache/conf.d
55 cp $src/etc/ocsinventory/ocsinventory-server.conf \
56 $fs/etc/apache/conf.d/ocsinventory-server.conf
57 sed -i -e "s#DATABASE_SERVER#localhost#g" \
58 -e "s#DATABASE_PORT#3306#g" \
59 -e "s#VERSION_MP#2#g" \
60 -e "s#PATH_TO_LOG_DIRECTORY#/var/log/ocsinventory-server#g" \
61 $fs/etc/apache/conf.d/ocsinventory-server.conf
63 if ! grep -q mod_perl.so $fs/etc/apache/conf.d/ocsinventory-server.conf;
64 then
65 cat > $fs/etc/apache/conf.d/ocsinventory-server.tmp <<EOT
66 <IfModule !mod_perl.c>
67 loadmodule perl_module share/apache/modules/mod_perl.so
68 </IfModule>
70 $(cat $fs/etc/apache/conf.d/ocsinventory-server.conf)
71 EOT
72 mv $fs/etc/apache/conf.d/ocsinventory-server.tmp \
73 $fs/etc/apache/conf.d/ocsinventory-server
74 [ -f $fs/etc/apache/conf.d/ocsinventory-server.conf ] && \
75 rm -f $fs/etc/apache/conf.d/ocsinventory-server.conf
76 fi
77 ;;
78 ocsreports)
79 CAT="network|Inventory and package deployement system"
80 TAGS="system administration"
81 DEPENDS="php-apache php-mysql mysql"
82 mkdir -p $fs/usr/share \
83 $fs/etc/ocsreports
85 cp -a $src/${PACKAGE} $fs/usr/share/
86 cat > $fs/etc/ocsreports/dbconfig.inc.php <<EOT
87 <?php
88 define("DB_NAME", "ocsweb");
89 define("SERVER_READ","localhost");
90 define("SERVER_WRITE","localhost");
91 define("COMPTE_BASE","ocs");
92 define("PSWD_BASE","ocs");
93 ?>
94 EOT
96 install -o root -g www -m 0755 $src/binutils/*.pl \
97 $fs/usr/share/ocsreports/
99 rm -f $fs/usr/share/${PACKAGE}/dbconfig.inc.php
100 cd $fs/usr/share/${PACKAGE} ; ln -s /etc/ocsreports/dbconfig.inc.php ; cd -
102 # Remove doc file.
103 rm -f $fs/usr/share/ocsreports/files/*.pdf
104 ;;
105 esac
106 }
108 post_install_ocsinventory_server()
109 {
110 if [ -z "$1" ]; then
111 echo "Now you can connect to http://$(hostname)/ocsreports"
112 # Restart Apache if is running
113 [ -f /var/run/apache/httpd.pid ] && /etc/init.d/apache reload
114 fi
115 }
117 post_install_ocsreports()
118 {
119 # Configure apache server
120 if [ -f "$1/etc/apache/httpd.conf" ]; then
121 if [ ! -f "$1/etc/apache/conf.d/$PACKAGE" ]; then
122 cat > "$1/etc/apache/conf.d/$PACKAGE" <<EOT
123 <IfModule mod_alias.c>
124 Alias /$PACKAGE /usr/share/$PACKAGE/
125 </IfModule>
126 <Directory "/usr/share/$PACKAGE">
127 Options Indexes FollowSymLinks
128 AllowOverride None
129 Order deny,allow
130 Allow from all
131 </Directory>
133 EOT
134 if [ -z "$1" ]; then
135 # Start Web server.
136 test -f /var/run/apache/httpd.pid && \
137 ( kill -0 $(cat /var/run/apache/httpd.pid) && /etc/init.d/apache restart )
138 fi
139 fi
140 fi
142 # Configure every thing for ocsweb.
143 if [ -z "$1" ]; then
144 if ( ! mysqladmin -s ping > /dev/null ); then
145 echo "Starting MySQL server"
146 ( /etc/init.d/mysql start ; status ) || exit
147 sleep 4 #let the mysql daemon start
148 fi
149 if ( ! mysql -Be 'show databases' | grep -q ocsweb ); then
150 echo -n "Create $PACKAGE database and schema"
151 mysql -Be "create database ocsweb CHARACTER SET utf8 COLLATE utf8_bin" ; status
152 mysql -s -u root ocsweb < /usr/share/$PACKAGE/files/ocsbase_new.sql > /dev/null 2>&1
153 # We suppose that ocs user does not exist.
154 # It may be false.
155 echo -n "Create user ocs with password ocs"
156 mysql -Be "grant all privileges on ocsweb.* to 'ocs'@'localhost'
157 identified by 'ocs'" ; status
158 fi
160 fi
161 true
162 }
164 post_remove_ocsreports()
165 {
167 if [ -z "$1" ]; then
168 echo -n "Would you like to remove data and database files.(y/n) "
169 read answer
171 case $answer in
172 y|Y)
173 echo -n "Removing data directories..."
174 rm -rf /usr/share/ocsreports
175 if ( mysql -Be 'show databases' | grep -q ocsweb ); then
176 echo -n "Deleting ocsreports database;"
177 mysql -u root -Be "drop database ocsweb;" ; status
178 echo -n "Delete user ocs"
179 mysql -u root -Be "delete from mysql.db where user=ocs;" ; status
180 fi
181 unset $answer
182 ;;
183 *)
184 ;;
185 esac
186 fi
188 }