wok-6.x annotate ocsreports/receipt @ rev 3768

Add php-dba
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Jul 29 17:26:41 2009 +0200 (2009-07-29)
parents
children 6ec17b55b59a
rev   line source
erjo@3676 1 # SliTaz package receipt.
erjo@3676 2
erjo@3676 3 PACKAGE="ocsreports"
erjo@3676 4 VERSION="1.02.1"
erjo@3676 5 CATEGORY="network"
erjo@3676 6 SHORT_DESC="Inventory and package deployement system"
erjo@3676 7 MAINTAINER="pascal.bellard@slitaz.org"
erjo@3676 8 DEPENDS="php-apache php-mysql mysql"
erjo@3676 9 WANTED="ocsinventory"
erjo@3676 10 SOURCE="OCSNG_UNIX_SERVER"
erjo@3676 11 TARBALL="${SOURCE}_${VERSION}.tar.gz"
erjo@3676 12 WEB_SITE="http://www.ocsinventory-ng.org/"
erjo@3676 13
erjo@3676 14 # Rules to gen a SliTaz package suitable for Tazpkg.
erjo@3676 15 genpkg_rules()
erjo@3676 16 {
erjo@3676 17 src=$WOK/$WANTED/$SOURCE-$VERSION
erjo@3676 18
erjo@3676 19 mkdir -p $fs/usr/share \
erjo@3676 20 $fs/etc/ocsreports
erjo@3676 21
erjo@3676 22 cp -a $WOK/$WANTED/${SOURCE}-${VERSION}/${PACKAGE} $fs/usr/share/
erjo@3676 23 cat > $fs/etc/ocsreports/dbconfig.inc.php <<EOT
erjo@3676 24 <?php
erjo@3676 25 \$_SESSION["SERVEUR_SQL"]="localhost";
erjo@3676 26 \$_SESSION["COMPTE_BASE"]="ocs";
erjo@3676 27 \$_SESSION["PSWD_BASE"]="ocs";
erjo@3676 28 ?>
erjo@3676 29 EOT
erjo@3676 30
erjo@3676 31 install -o root -g www -m 0755 $src/Apache/binutils/ipdiscover-util.pl \
erjo@3676 32 $fs/usr/share/ocsreports/ipdiscover-util.pl
erjo@3676 33
erjo@3676 34 rm -f $fs/usr/share/${PACKAGE}/dbconfig.inc.php
erjo@3676 35 cd $fs/usr/share/${PACKAGE} ; ln -s /etc/ocsreports/dbconfig.inc.php ; cd -
erjo@3676 36
erjo@3676 37 # Remove doc file.
erjo@3676 38 rm -f $fs/usr/share/ocsreports/files/*.pdf
erjo@3676 39 }
erjo@3676 40
erjo@3676 41 post_install()
erjo@3676 42 {
erjo@3676 43 # Configure apache server
erjo@3676 44 if [ -f $1/etc/apache/httpd.conf ]; then
erjo@3676 45 if [ ! -f $1/etc/apache/conf.d/$PACKAGE ]; then
erjo@3676 46 cat > $1/etc/apache/conf.d/$PACKAGE <<EOT
erjo@3676 47 <IfModule mod_alias.c>
erjo@3676 48 Alias /$PACKAGE /usr/share/$PACKAGE/
erjo@3676 49 </IfModule>
erjo@3676 50 <Directory "/usr/share/$PACKAGE">
erjo@3676 51 Options Indexes FollowSymLinks
erjo@3676 52 AllowOverride None
erjo@3676 53 Order deny,allow
erjo@3676 54 Allow from all
erjo@3676 55 </Directory>
erjo@3676 56
erjo@3676 57 EOT
erjo@3676 58 if [ -z "$1" ]; then
erjo@3676 59 # Start Web server.
erjo@3676 60 test -f /var/run/apache/httpd.pid && \
erjo@3676 61 ( kill -0 $(cat /var/run/apache/httpd.pid) && /etc/init.d/apache restart )
erjo@3676 62 fi
erjo@3676 63 fi
erjo@3676 64 fi
erjo@3676 65
erjo@3676 66 # Configure every thing for ocsweb.
erjo@3676 67 if [ -z $1 ]; then
erjo@3676 68 if ( ! mysqladmin -s ping > /dev/null ); then
erjo@3676 69 echo "Starting MySQL server"
erjo@3676 70 ( /etc/init.d/mysql start ; status ) || exit
erjo@3676 71 sleep 4 #let the mysql daemon start
erjo@3676 72 fi
erjo@3676 73 if ( ! mysql -Be 'show databases' | grep -q ocsweb ); then
erjo@3676 74 echo -n "Create $PACKAGE database and schema"
erjo@3676 75 # mysql -Be "create database ocsweb" ; status
erjo@3676 76 mysql -f -s -u root < /usr/share/$PACKAGE/files/ocsbase.sql > /dev/null 2>&1
erjo@3676 77 # We suppose that ocs user does not exist.
erjo@3676 78 # It may be false.
erjo@3676 79 echo -n "Create user ocs with password ocs"
erjo@3676 80 mysql -Be "grant all privileges on ocsweb.* to 'ocs'@'localhost'
erjo@3676 81 identified by 'ocs'" ; status
erjo@3676 82 fi
erjo@3676 83
erjo@3676 84 fi
erjo@3676 85 }
erjo@3676 86
erjo@3676 87 post_remove()
erjo@3676 88 {
erjo@3676 89 echo -n "Would you like to remove data and database files.(y/n) "
erjo@3676 90 read answer
erjo@3676 91
erjo@3676 92 case $answer in
erjo@3676 93 y|Y)
erjo@3676 94 echo -n "Removing data directories..."
erjo@3676 95 rm -rf /usr/share/ocsreports
erjo@3676 96 if ( mysql -Be 'show databases' | grep -q ocsweb ); then
erjo@3676 97 echo -n "Deleting ocsreports database;"
erjo@3676 98 mysql -u root -Be "drop database ocsweb;" ; status
erjo@3676 99 echo -n "Delete user ocs"
erjo@3676 100 mysql -u root -Be "delete from mysql.db where user=ocs;" ; status
erjo@3676 101 fi
erjo@3676 102 unset $answer
erjo@3676 103 ;;
erjo@3676 104 *)
erjo@3676 105 ;;
erjo@3676 106 esac
erjo@3676 107
erjo@3676 108 }
erjo@3676 109