wok view nconf/receipt @ rev 24402
Add some current_version
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Tue Feb 08 16:59:06 2022 +0000 (2022-02-08) |
parents | 970c5ec9a60a |
children | 73f36875e5a7 |
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 # What is the latest version available today?
16 current_version()
17 {
18 wget -O - https://sourceforge.net/projects/nconf/files/nconf/ 2>/dev/null | \
19 sed '/scope="row/!d;s|.*href="|"https://sourceforge.net|;q' | xargs wget -O - 2>/dev/null | \
20 sed '/scope="row/!d;s|.*/nconf/||;s|/.*||;q'
21 }
23 # Rules to gen a SliTaz package suitable for Tazpkg.
24 genpkg_rules()
25 {
26 mkdir -p $fs/usr/share/nconf \
27 $fs/var/lib/nconf \
28 $fs/etc/nconf \
29 $fs/etc/apache/conf.d \
30 $fs/etc/nagios/import
32 cp $stuff/apache2-nconf.conf $fs/etc/apache/conf.d
34 # Copy files
35 cp -a $src/* $fs/usr/share/nconf
37 # Move config, output, static_cfg, temp tor $fs/var/lib/nconf (FHS)
38 # and link them to $fs/usr/sahre/nconf
39 cp -a $fs/usr/share/nconf/config.orig/* $fs/etc/nconf
40 mv $fs/usr/share/nconf/output $fs/var/lib/nconf
41 mv $fs/usr/share/nconf/static_cfg $fs/var/lib/nconf
42 mv $fs/usr/share/nconf/temp $fs/var/lib/nconf
44 chown -R www.www $fs/usr/share/nconf \
45 $fs/var/lib/nconf
47 ln -s /etc/nconf/authentication.php $fs/usr/share/nconf/config
48 ln -s /etc/nconf/main.php $fs/usr/share/nconf/config
49 ln -s /etc/nconf/mysql.php $fs/usr/share/nconf/config
50 ln -s /etc/nconf/nconf.php $fs/usr/share/nconf/config
51 ln -s /var/lib/nconf/output $fs/usr/share/nconf/
52 ln -s /var/lib/nconf/static_cfg $fs/usr/share/nconf/
53 ln -s /var/lib/nconf/temp $fs/usr/share/nconf/
55 mv $fs/usr/share/nconf/INSTALL $fs/var/lib/nconf
56 # Cleanup
57 rm -rf $fs/usr/share/nconf/UPDATE*
58 rm -f $fs/usr/share/nconf/INSTALL.php
60 # Set default settings
61 sed -i -e 's/Nconf/nconf/' -e 's/link2db/nconf/' $fs/etc/nconf/mysql.php
62 sed -i -e '/NCONFDIR/ s|/var/www|/usr/share|' \
63 -e '/NAGIOS_BIN/ s|/var/www/nconf/bin|/usr/bin|' $fs/etc/nconf/mysql.php
65 # Fix add-ons scripts
66 sed -i -e 's|bash|sh|' -e '/OUTPUT_DIR/ s|/var/www/html|/usr/share|' \
67 -e '/NAGIOS_DIR/ s|NAGIOS_DIR=.*|NAGIOS_DIR=\"/etc/nagios\"|' $fs/usr/share/nconf/ADD-ONS/deploy_local.sh
68 sed -i -e 's|bash|sh|' -e '/DBNAME/ s|NConf|nconf|' $fs/usr/share/nconf/ADD-ONS/history_cleanup.sh
69 }
71 post_install()
72 {
73 local db=nconf
74 local db_user=nconf
75 local db_password=nconf
76 local sql_script='/var/lib/nconf/INSTALL/create_database.sql'
78 # Minimal config for NConf.
79 if [ -z "$1" ]; then
80 if ( ! mysqladmin -s ping > /dev/null ); then
81 echo
82 echo "Starting MySQL server"
83 ( /etc/init.d/mysql start ; status ) || exit
84 sleep 4 #let the mysql daemon start
85 fi
86 if ( ! mysql -u root -Be 'show databases' | grep -q $db ); then
87 echo
88 echo -n "Create $db database"
89 mysql -Be "create database $db" ; status
90 # We suppose that $DB_USER user does not exist.
91 # It may be false.
92 echo -n "Create user $db_user with password $db_password"
93 mysql -Be "grant all privileges on $db.* to '"$db_user"'@'localhost'
94 identified by '"$db_password"'" ; status
95 # At last create the database for $PACKAGE.
96 echo -n "Create $db database schema."
97 mysql -u $db_user -p${db_password} -D $db < $sql_script ; status
98 fi
99 fi
100 true
101 }
103 post_remove()
104 {
105 if [ -z "$1" ]; then
106 local db=nconf
107 local db_user=nconf
108 local db_password=nconf
110 echo -n "Would you like to remove data and database files.(y/n) "
111 read answer
113 case $answer in
114 y|Y)
115 echo -n "Removing data directories..."
116 rm -rf /var/lib/nconf ; status
117 if ( mysql -u root -Be 'show databases' | grep -q $db ); then
118 echo -n "Deleting $db database"
119 mysql -Be "drop database $db" ; status
120 # We suppose that $db_user user does not exist.
121 # It may be false.
122 echo -n "Delete user $db_user"
123 mysql -Be "delete from mysql.db where user='"$db_user"'" ; status
124 fi
125 unset answer
126 ;;
127 *)
128 ;;
129 esac
130 fi
131 }