wok diff nconf/receipt @ rev 14411

new: python-ecore-dev
author Dominique Corbex <domcox@slitaz.org>
date Tue Apr 23 18:30:12 2013 +0200 (2013-04-23)
parents
children 066baa4a3634
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/nconf/receipt	Tue Apr 23 18:30:12 2013 +0200
     1.3 @@ -0,0 +1,123 @@
     1.4 +# SliTaz package receipt.
     1.5 +
     1.6 +PACKAGE="nconf"
     1.7 +VERSION="1.2.6-0"
     1.8 +CATEGORY="system-tools"
     1.9 +SHORT_DESC="Enterprise Nagios configurator"
    1.10 +MAINTAINER="erjo@slitaz.org"
    1.11 +DEPENDS="mysql php-apache nagios perl perl-dbi perl-dbd-mysql"
    1.12 +TARBALL="$PACKAGE-$VERSION.tgz"
    1.13 +WEB_SITE="http://www.nconf.org/dokuwiki/doku.php"
    1.14 +WGET_URL="$SF_MIRROR/$PACKAGE/$TARBALL"
    1.15 +
    1.16 +# Rules to configure and make the package.
    1.17 +compile_rules()
    1.18 +{
    1.19 +	[ -d $PACKAGE-$VERSION ] || mv $PACKAGE $PACKAGE-$VERSION
    1.20 +	cd $src
    1.21 +}
    1.22 +
    1.23 +# Rules to gen a SliTaz package suitable for Tazpkg.
    1.24 +genpkg_rules()
    1.25 +{
    1.26 +	mkdir -p $fs/usr/share/nconf \
    1.27 +		$fs/var/lib/nconf \
    1.28 +		$fs/etc/nconf \
    1.29 +		$fs/etc/apache/conf.d \
    1.30 +		$fs/etc/nagios/import
    1.31 +		
    1.32 +	cp  stuff/apache2-nconf.conf $fs/etc/apache/conf.d
    1.33 +	
    1.34 +	# Copy files
    1.35 +	cp -a $src/* $fs/usr/share/nconf
    1.36 +	
    1.37 +	# Move config, output, static_cfg, temp tor $fs/var/lib/nconf (FHS)
    1.38 +	# and link them to $fs/usr/sahre/nconf
    1.39 +	cp -a  $fs/usr/share/nconf/config.orig/* $fs/etc/nconf
    1.40 +	mv $fs/usr/share/nconf/output $fs/var/lib/nconf
    1.41 +	mv $fs/usr/share/nconf/static_cfg $fs/var/lib/nconf
    1.42 +	mv $fs/usr/share/nconf/temp $fs/var/lib/nconf
    1.43 +	
    1.44 +	chown -R www.www $fs/usr/share/nconf \
    1.45 +		$fs/var/lib/nconf
    1.46 +	
    1.47 +	ln -s /etc/nconf/authentication.php $fs/usr/share/nconf/config
    1.48 +	ln -s /etc/nconf/main.php $fs/usr/share/nconf/config
    1.49 +	ln -s /etc/nconf/mysql.php $fs/usr/share/nconf/config
    1.50 +	ln -s /etc/nconf/nconf.php $fs/usr/share/nconf/config
    1.51 +	ln -s /var/lib/nconf/output $fs/usr/share/nconf/
    1.52 +	ln -s /var/lib/nconf/static_cfg $fs/usr/share/nconf/
    1.53 +	ln -s /var/lib/nconf/temp $fs/usr/share/nconf/
    1.54 +	
    1.55 +	mv $fs/usr/share/nconf/INSTALL $fs/var/lib/nconf
    1.56 +	# Cleanup
    1.57 +	rm -rf $fs/usr/share/nconf/UPDATE*
    1.58 +	rm -f $fs/usr/share/nconf/INSTALL.php
    1.59 +	
    1.60 +	# Set default settings
    1.61 +	sed -i -e 's/Nconf/nconf/' -e 's/link2db/nconf/' $fs/etc/nconf/mysql.php
    1.62 +	sed -i -e '/NCONFDIR/ s|/var/www|/usr/share|' \
    1.63 +		-e '/NAGIOS_BIN/ s|/var/www/nconf/bin|/usr/bin|' $fs/etc/nconf/mysql.php
    1.64 +		
    1.65 +	# Fix add-ons scripts
    1.66 +	sed -i -e 's|bash|sh|' -e '/OUTPUT_DIR/ s|/var/www/html|/usr/share|' \
    1.67 +		-e '/NAGIOS_DIR/ s|NAGIOS_DIR=.*|NAGIOS_DIR=\"/etc/nagios\"|' $fs/usr/share/nconf/ADD-ONS/deploy_local.sh
    1.68 +	sed -i -e 's|bash|sh|' -e '/DBNAME/ s|NConf|nconf|' $fs/usr/share/nconf/ADD-ONS/history_cleanup.sh
    1.69 +}
    1.70 +
    1.71 +post_install()
    1.72 +{
    1.73 +	local db=nconf
    1.74 +	local db_user=nconf
    1.75 +	local db_password=nconf
    1.76 +	local sql_script='/var/lib/nconf/INSTALL/create_database.sql'
    1.77 +	
    1.78 +	# Minimal config for NConf.
    1.79 +	if [ -z $1 ]; then
    1.80 +		if ( ! mysqladmin -s ping > /dev/null ); then
    1.81 +			echo "Starting MySQL server"
    1.82 +			( /etc/init.d/mysql start ; status  ) || exit 
    1.83 +			sleep 4 #let the mysql daemon start
    1.84 +		fi
    1.85 +		if ( ! mysql -u root -Be 'show databases' | grep -q $db ); then
    1.86 +			echo -n "Create $db database"
    1.87 +			mysql -Be "create database $db" ; status
    1.88 +			# We suppose that $DB_USER user does not exist.
    1.89 +			# It may be false.
    1.90 +			echo  -n "Create user $db_user with password $db_password"
    1.91 +			mysql -Be "grant all privileges on $db.* to '"$db_user"'@'localhost' 
    1.92 +				identified by '"$db_password"'" ; status
    1.93 +			# At last create the database for $PACKAGE.
    1.94 +			echo -n "Create $db database schema."
    1.95 +			mysql -u $db_user -p${db_password} -D $db < $sql_script  ; status
    1.96 +		fi
    1.97 +	fi
    1.98 +}
    1.99 +
   1.100 +post_remove()
   1.101 +{
   1.102 +		local db=nconf
   1.103 +		local db_user=nconf
   1.104 +		local db_password=nconf
   1.105 +	
   1.106 +		echo -n "Would you like to remove data and database files.(y/n) "
   1.107 +		read answer
   1.108 +
   1.109 +		case $answer in 
   1.110 +		y|Y)
   1.111 +			echo -n "Removing data directories..."
   1.112 +			rm -rf /var/lib/nconf ; status
   1.113 +			if ( mysql -u root -Be 'show databases' | grep -q $db ); then
   1.114 +				echo -n "Deleting $db database"
   1.115 +				mysql -Be "drop database $db" ; status
   1.116 +				# We suppose that $db_user user does not exist.
   1.117 +				# It may be false.
   1.118 +				echo  -n "Delete user $db_user"
   1.119 +				mysql -Be "delete from mysql.db where user='"$db_user"'" ; status
   1.120 +			fi
   1.121 +			unset $answer
   1.122 +			;;
   1.123 +		*)
   1.124 +			;;
   1.125 +		esac
   1.126 +}