wok view nconf/receipt @ rev 9121

cndrvcups-common: fix genpkg_rules
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Mar 05 16:49:29 2011 +0100 (2011-03-05)
parents
children 066baa4a3634
line source
1 # SliTaz package receipt.
3 PACKAGE="nconf"
4 VERSION="1.2.6-0"
5 CATEGORY="system-tools"
6 SHORT_DESC="Enterprise Nagios configurator"
7 MAINTAINER="erjo@slitaz.org"
8 DEPENDS="mysql php-apache nagios perl perl-dbi perl-dbd-mysql"
9 TARBALL="$PACKAGE-$VERSION.tgz"
10 WEB_SITE="http://www.nconf.org/dokuwiki/doku.php"
11 WGET_URL="$SF_MIRROR/$PACKAGE/$TARBALL"
13 # Rules to configure and make the package.
14 compile_rules()
15 {
16 [ -d $PACKAGE-$VERSION ] || mv $PACKAGE $PACKAGE-$VERSION
17 cd $src
18 }
20 # Rules to gen a SliTaz package suitable for Tazpkg.
21 genpkg_rules()
22 {
23 mkdir -p $fs/usr/share/nconf \
24 $fs/var/lib/nconf \
25 $fs/etc/nconf \
26 $fs/etc/apache/conf.d \
27 $fs/etc/nagios/import
29 cp stuff/apache2-nconf.conf $fs/etc/apache/conf.d
31 # Copy files
32 cp -a $src/* $fs/usr/share/nconf
34 # Move config, output, static_cfg, temp tor $fs/var/lib/nconf (FHS)
35 # and link them to $fs/usr/sahre/nconf
36 cp -a $fs/usr/share/nconf/config.orig/* $fs/etc/nconf
37 mv $fs/usr/share/nconf/output $fs/var/lib/nconf
38 mv $fs/usr/share/nconf/static_cfg $fs/var/lib/nconf
39 mv $fs/usr/share/nconf/temp $fs/var/lib/nconf
41 chown -R www.www $fs/usr/share/nconf \
42 $fs/var/lib/nconf
44 ln -s /etc/nconf/authentication.php $fs/usr/share/nconf/config
45 ln -s /etc/nconf/main.php $fs/usr/share/nconf/config
46 ln -s /etc/nconf/mysql.php $fs/usr/share/nconf/config
47 ln -s /etc/nconf/nconf.php $fs/usr/share/nconf/config
48 ln -s /var/lib/nconf/output $fs/usr/share/nconf/
49 ln -s /var/lib/nconf/static_cfg $fs/usr/share/nconf/
50 ln -s /var/lib/nconf/temp $fs/usr/share/nconf/
52 mv $fs/usr/share/nconf/INSTALL $fs/var/lib/nconf
53 # Cleanup
54 rm -rf $fs/usr/share/nconf/UPDATE*
55 rm -f $fs/usr/share/nconf/INSTALL.php
57 # Set default settings
58 sed -i -e 's/Nconf/nconf/' -e 's/link2db/nconf/' $fs/etc/nconf/mysql.php
59 sed -i -e '/NCONFDIR/ s|/var/www|/usr/share|' \
60 -e '/NAGIOS_BIN/ s|/var/www/nconf/bin|/usr/bin|' $fs/etc/nconf/mysql.php
62 # Fix add-ons scripts
63 sed -i -e 's|bash|sh|' -e '/OUTPUT_DIR/ s|/var/www/html|/usr/share|' \
64 -e '/NAGIOS_DIR/ s|NAGIOS_DIR=.*|NAGIOS_DIR=\"/etc/nagios\"|' $fs/usr/share/nconf/ADD-ONS/deploy_local.sh
65 sed -i -e 's|bash|sh|' -e '/DBNAME/ s|NConf|nconf|' $fs/usr/share/nconf/ADD-ONS/history_cleanup.sh
66 }
68 post_install()
69 {
70 local db=nconf
71 local db_user=nconf
72 local db_password=nconf
73 local sql_script='/var/lib/nconf/INSTALL/create_database.sql'
75 # Minimal config for NConf.
76 if [ -z $1 ]; then
77 if ( ! mysqladmin -s ping > /dev/null ); then
78 echo "Starting MySQL server"
79 ( /etc/init.d/mysql start ; status ) || exit
80 sleep 4 #let the mysql daemon start
81 fi
82 if ( ! mysql -u root -Be 'show databases' | grep -q $db ); then
83 echo -n "Create $db database"
84 mysql -Be "create database $db" ; status
85 # We suppose that $DB_USER user does not exist.
86 # It may be false.
87 echo -n "Create user $db_user with password $db_password"
88 mysql -Be "grant all privileges on $db.* to '"$db_user"'@'localhost'
89 identified by '"$db_password"'" ; status
90 # At last create the database for $PACKAGE.
91 echo -n "Create $db database schema."
92 mysql -u $db_user -p${db_password} -D $db < $sql_script ; status
93 fi
94 fi
95 }
97 post_remove()
98 {
99 local db=nconf
100 local db_user=nconf
101 local db_password=nconf
103 echo -n "Would you like to remove data and database files.(y/n) "
104 read answer
106 case $answer in
107 y|Y)
108 echo -n "Removing data directories..."
109 rm -rf /var/lib/nconf ; status
110 if ( mysql -u root -Be 'show databases' | grep -q $db ); then
111 echo -n "Deleting $db database"
112 mysql -Be "drop database $db" ; status
113 # We suppose that $db_user user does not exist.
114 # It may be false.
115 echo -n "Delete user $db_user"
116 mysql -Be "delete from mysql.db where user='"$db_user"'" ; status
117 fi
118 unset $answer
119 ;;
120 *)
121 ;;
122 esac
123 }