wok-next diff ocsreports/receipt @ rev 4493

Up: amsn (0.98.1)
author Eric Joseph-Alexandre <erjo@slitaz.org>
date Wed Nov 18 22:02:57 2009 +0000 (2009-11-18)
parents
children 6ec17b55b59a
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/ocsreports/receipt	Wed Nov 18 22:02:57 2009 +0000
     1.3 @@ -0,0 +1,109 @@
     1.4 +# SliTaz package receipt.
     1.5 +
     1.6 +PACKAGE="ocsreports"
     1.7 +VERSION="1.02.1"
     1.8 +CATEGORY="network"
     1.9 +SHORT_DESC="Inventory and package deployement system"
    1.10 +MAINTAINER="pascal.bellard@slitaz.org"
    1.11 +DEPENDS="php-apache php-mysql mysql"
    1.12 +WANTED="ocsinventory"
    1.13 +SOURCE="OCSNG_UNIX_SERVER"
    1.14 +TARBALL="${SOURCE}_${VERSION}.tar.gz"
    1.15 +WEB_SITE="http://www.ocsinventory-ng.org/"
    1.16 +
    1.17 +# Rules to gen a SliTaz package suitable for Tazpkg.
    1.18 +genpkg_rules()
    1.19 +{
    1.20 +	src=$WOK/$WANTED/$SOURCE-$VERSION
    1.21 +	
    1.22 +	mkdir -p $fs/usr/share \
    1.23 +		$fs/etc/ocsreports
    1.24 +		
    1.25 +	cp -a $WOK/$WANTED/${SOURCE}-${VERSION}/${PACKAGE} $fs/usr/share/
    1.26 +	cat > $fs/etc/ocsreports/dbconfig.inc.php <<EOT
    1.27 +<?php 
    1.28 +	\$_SESSION["SERVEUR_SQL"]="localhost";
    1.29 +	\$_SESSION["COMPTE_BASE"]="ocs";
    1.30 +	\$_SESSION["PSWD_BASE"]="ocs";
    1.31 +?>
    1.32 +EOT
    1.33 +
    1.34 +	install -o root -g www -m 0755 $src/Apache/binutils/ipdiscover-util.pl \
    1.35 +		$fs/usr/share/ocsreports/ipdiscover-util.pl
    1.36 +
    1.37 +	rm -f $fs/usr/share/${PACKAGE}/dbconfig.inc.php
    1.38 +	cd $fs/usr/share/${PACKAGE} ; ln -s /etc/ocsreports/dbconfig.inc.php ; cd -
    1.39 +
    1.40 +	# Remove doc file.
    1.41 +	rm -f  $fs/usr/share/ocsreports/files/*.pdf
    1.42 +}
    1.43 +
    1.44 +post_install()
    1.45 +{
    1.46 +	# Configure apache server
    1.47 +	if [ -f $1/etc/apache/httpd.conf ]; then
    1.48 +		if [ ! -f $1/etc/apache/conf.d/$PACKAGE ]; then
    1.49 +			cat > $1/etc/apache/conf.d/$PACKAGE <<EOT
    1.50 +<IfModule mod_alias.c>
    1.51 +    Alias /$PACKAGE /usr/share/$PACKAGE/
    1.52 +</IfModule>
    1.53 +<Directory "/usr/share/$PACKAGE">
    1.54 +	Options Indexes FollowSymLinks
    1.55 +	AllowOverride None
    1.56 +	Order deny,allow
    1.57 +	Allow from all
    1.58 +</Directory>
    1.59 +
    1.60 +EOT
    1.61 +			if [ -z "$1" ]; then
    1.62 +				# Start Web server.
    1.63 +				test -f /var/run/apache/httpd.pid && \
    1.64 +					( kill -0 $(cat /var/run/apache/httpd.pid) && /etc/init.d/apache restart )
    1.65 +			fi
    1.66 +		fi
    1.67 +	fi
    1.68 +
    1.69 +	# Configure every thing for ocsweb.
    1.70 +	if [ -z $1 ]; then
    1.71 +		if ( ! mysqladmin -s ping > /dev/null ); then
    1.72 +			echo "Starting MySQL server"
    1.73 +			( /etc/init.d/mysql start ; status  ) || exit 
    1.74 +			sleep 4 #let the mysql daemon start
    1.75 +		fi
    1.76 +		if ( ! mysql -Be 'show databases' | grep -q ocsweb ); then
    1.77 +			echo -n "Create $PACKAGE database and schema"
    1.78 +		#	mysql -Be "create database ocsweb" ; status
    1.79 +			mysql -f -s -u root < /usr/share/$PACKAGE/files/ocsbase.sql > /dev/null 2>&1
    1.80 +			# We suppose that ocs user does not exist.
    1.81 +			# It may be false.
    1.82 +			echo  -n "Create user ocs with password ocs"
    1.83 +			mysql -Be "grant all privileges on ocsweb.* to 'ocs'@'localhost' 
    1.84 +				identified by 'ocs'" ; status
    1.85 +		fi
    1.86 +			
    1.87 +	fi
    1.88 +}
    1.89 +
    1.90 +post_remove()
    1.91 +{
    1.92 +		echo -n "Would you like to remove data and database files.(y/n) "
    1.93 +		read answer
    1.94 +
    1.95 +		case $answer in 
    1.96 +		y|Y)
    1.97 +			echo -n "Removing data directories..."
    1.98 +			rm -rf /usr/share/ocsreports
    1.99 +			if ( mysql -Be 'show databases' | grep -q ocsweb ); then
   1.100 +				echo -n "Deleting ocsreports database;"
   1.101 +				mysql -u root -Be "drop database ocsweb;" ; status
   1.102 +				echo  -n "Delete user ocs"
   1.103 +				mysql -u root -Be "delete from mysql.db where user=ocs;" ; status
   1.104 +			fi
   1.105 +			unset $answer
   1.106 +			;;
   1.107 +		*)
   1.108 +			;;
   1.109 +		esac
   1.110 +	
   1.111 +}
   1.112 +