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