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