wok view nconf/receipt @ rev 15180

mosh: update deps
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Aug 20 11:57:56 2013 +0000 (2013-08-20)
parents 066baa4a3634
children 3765f181a6d5
line source
1 # SliTaz package receipt.
3 PACKAGE="nconf"
4 VERSION="1.3.0-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 gen a SliTaz package suitable for Tazpkg.
14 genpkg_rules()
15 {
16 mkdir -p $fs/usr/share/nconf \
17 $fs/var/lib/nconf \
18 $fs/etc/nconf \
19 $fs/etc/apache/conf.d \
20 $fs/etc/nagios/import
22 cp $stuff/apache2-nconf.conf $fs/etc/apache/conf.d
24 # Copy files
25 cp -a $src/* $fs/usr/share/nconf
27 # Move config, output, static_cfg, temp tor $fs/var/lib/nconf (FHS)
28 # and link them to $fs/usr/sahre/nconf
29 cp -a $fs/usr/share/nconf/config.orig/* $fs/etc/nconf
30 mv $fs/usr/share/nconf/output $fs/var/lib/nconf
31 mv $fs/usr/share/nconf/static_cfg $fs/var/lib/nconf
32 mv $fs/usr/share/nconf/temp $fs/var/lib/nconf
34 chown -R www.www $fs/usr/share/nconf \
35 $fs/var/lib/nconf
37 ln -s /etc/nconf/authentication.php $fs/usr/share/nconf/config
38 ln -s /etc/nconf/main.php $fs/usr/share/nconf/config
39 ln -s /etc/nconf/mysql.php $fs/usr/share/nconf/config
40 ln -s /etc/nconf/nconf.php $fs/usr/share/nconf/config
41 ln -s /var/lib/nconf/output $fs/usr/share/nconf/
42 ln -s /var/lib/nconf/static_cfg $fs/usr/share/nconf/
43 ln -s /var/lib/nconf/temp $fs/usr/share/nconf/
45 mv $fs/usr/share/nconf/INSTALL $fs/var/lib/nconf
46 # Cleanup
47 rm -rf $fs/usr/share/nconf/UPDATE*
48 rm -f $fs/usr/share/nconf/INSTALL.php
50 # Set default settings
51 sed -i -e 's/Nconf/nconf/' -e 's/link2db/nconf/' $fs/etc/nconf/mysql.php
52 sed -i -e '/NCONFDIR/ s|/var/www|/usr/share|' \
53 -e '/NAGIOS_BIN/ s|/var/www/nconf/bin|/usr/bin|' $fs/etc/nconf/mysql.php
55 # Fix add-ons scripts
56 sed -i -e 's|bash|sh|' -e '/OUTPUT_DIR/ s|/var/www/html|/usr/share|' \
57 -e '/NAGIOS_DIR/ s|NAGIOS_DIR=.*|NAGIOS_DIR=\"/etc/nagios\"|' $fs/usr/share/nconf/ADD-ONS/deploy_local.sh
58 sed -i -e 's|bash|sh|' -e '/DBNAME/ s|NConf|nconf|' $fs/usr/share/nconf/ADD-ONS/history_cleanup.sh
59 }
61 post_install()
62 {
63 local db=nconf
64 local db_user=nconf
65 local db_password=nconf
66 local sql_script='/var/lib/nconf/INSTALL/create_database.sql'
68 # Minimal config for NConf.
69 if [ -z $1 ]; then
70 if ( ! mysqladmin -s ping > /dev/null ); then
71 echo "Starting MySQL server"
72 ( /etc/init.d/mysql start ; status ) || exit
73 sleep 4 #let the mysql daemon start
74 fi
75 if ( ! mysql -u root -Be 'show databases' | grep -q $db ); then
76 echo -n "Create $db database"
77 mysql -Be "create database $db" ; status
78 # We suppose that $DB_USER user does not exist.
79 # It may be false.
80 echo -n "Create user $db_user with password $db_password"
81 mysql -Be "grant all privileges on $db.* to '"$db_user"'@'localhost'
82 identified by '"$db_password"'" ; status
83 # At last create the database for $PACKAGE.
84 echo -n "Create $db database schema."
85 mysql -u $db_user -p${db_password} -D $db < $sql_script ; status
86 fi
87 fi
88 }
90 post_remove()
91 {
92 if [ -z $1 ]; then
93 local db=nconf
94 local db_user=nconf
95 local db_password=nconf
97 echo -n "Would you like to remove data and database files.(y/n) "
98 read answer
100 case $answer in
101 y|Y)
102 echo -n "Removing data directories..."
103 rm -rf /var/lib/nconf ; status
104 if ( mysql -u root -Be 'show databases' | grep -q $db ); then
105 echo -n "Deleting $db database"
106 mysql -Be "drop database $db" ; status
107 # We suppose that $db_user user does not exist.
108 # It may be false.
109 echo -n "Delete user $db_user"
110 mysql -Be "delete from mysql.db where user='"$db_user"'" ; status
111 fi
112 unset answer
113 ;;
114 *)
115 ;;
116 esac
117 fi
118 }