wok-current view ndoutils/receipt @ rev 14463
Up: ndoutils (1.5.2)
author | Eric Joseph-Alexandre <erjo@slitaz.org> |
---|---|
date | Sat Apr 27 03:10:35 2013 +0200 (2013-04-27) |
parents | d1768332cee0 |
children | 23c3aed67cd9 |
line source
1 # SliTaz package receipt.
3 PACKAGE="ndoutils"
4 VERSION="1.5.2"
5 CATEGORY="network"
6 SHORT_DESC="Provide mysql access to nagios."
7 MAINTAINER="pascal.bellard@slitaz.org"
8 TARBALL="$PACKAGE-$VERSION.tar.gz"
9 WEB_SITE="http://www.nagios.org/"
10 WGET_URL="$SF_MIRROR/nagios/$TARBALL"
11 DEPENDS="nagios mysql"
12 BUILD_DEPENDS="mysql-dev"
13 CONFIG_FILES="/etc/nagios"
15 # Rules to configure and make the package.
16 compile_rules()
17 {
18 cd $src
20 while read patch_file; do
21 if [ ! -f done.$patch_file ]; then
22 patch -p1 < $stuff/$patch_file || exit 1
23 touch done.$patch_file
24 fi
25 done <<EOT
26 $PACKAGE-$VERSION-Makefiles.in.u
27 EOT
29 ./configure --prefix=/usr \
30 --with-ndo2db-user=nagios \
31 --with-ndo2db-group=nagios \
32 --localstatedir=/var/run/nagios \
33 --sysconfdir=/etc/nagios \
34 --libexecdir=/usr/lib/$PACKAGE \
35 --mandir=/usr/share/man $CONFIGURE_ARGS &&
36 make && \
37 make DESTDIR=$PWD/_pkg install && \
38 make DESTDIR=$PWD/_pkg install-config
39 }
41 # Rules to gen a SliTaz package suitable for Tazpkg.
42 genpkg_rules()
43 {
44 mkdir -p $fs/usr/share/nagios/ndoutils \
45 $fs/etc/nagios \
46 $fs/var/run/nagios \
47 $fs/etc/mysql.d
49 cp -a $_pkg/usr/bin $fs/usr
50 cp -a $_pkg/usr/lib $fs/usr
51 cp -a $_pkg/etc $fs
53 # config ndo2db.cfg
54 sed -i -e 's/ndo2db_user=nagios/ndo2db_user=nagios/' \
55 -e 's/ndo2db_group=nagios/ndo2db_group=nagios/' \
56 -e 's|/usr/local/nagios/var/|/var/run/nagios/|' \
57 -e 's/db_user=ndouser/db_user=root/' \
58 -e 's/db_pass=ndopassword/db_pass=/' $fs/etc/nagios/ndo2db.cfg
60 # config ndomod.cfg
61 sed -i -e 's|output=/usr/local/nagios/var/|output=/var/run/nagios/|' \
62 -e 's|buffer_file=/usr/local/nagios/var/|buffer_file=/var/tmp/|' \
63 $fs/etc/nagios/ndomod.cfg
65 cp -a $src/db/mysql.sql $fs/usr/share/nagios/ndoutils/nagios.sql
66 cp -a stuff/etc $fs
68 chmod 755 $fs/usr/bin/*
69 chmod 755 $fs/etc/mysql.d/*
70 }
72 post_install()
73 {
74 if ! grep -q nagios $1/etc/passwd; then
75 echo -n "Adding user nagios..."
76 chroot $1/ adduser -S -D -H nagios
77 status
78 fi
80 if ! grep -q ndomod.cfg $1/etc/nagios/nagios.cfg; then
81 sed -i '/LOG ROTATION METHOD/i\broker_module=/usr/lib/ndoutils/ndomod.o config_file=/etc/nagios/ndomod.cfg' $1/etc/nagios/nagios.cfg
82 chroot $1/ chown nagios.nagios $1/etc/nagios/nagios.cfg
83 fi
85 chroot $1/ chown nagios.nagios $fs/usr/lib/ndoutils/ndomod.o \
86 $fs/etc/nagios/ndo2db.cfg $fs/etc/nagios/ndomod.cfg \
87 $fs/var/run/nagios $fs/etc/nagios
89 sed -i "s/nagios/ndo2db nagios/" $1/etc/rcS.conf
91 if [ -z "$1" ]; then
92 [ -f /var/run/mysqld/mysql.pid ] || /etc/init.d/mysql start
93 /etc/mysql.d/$PACKAGE
94 #/usr/bin/ndo2db -c /etc/nagios/ndo2db.cfg
95 /etc/init.d/ndo2db start
96 /etc/init.d/nagios stop
97 /etc/init.d/nagios start
99 fi
100 }
102 pre_remove()
103 {
104 /etc/init.d/ndo2db stop
105 }
107 post_remove()
108 {
109 sed -i "s/ndo2db//" $1/etc/rcS.conf
110 /etc/init.d/nagios restart
111 sed -i 's|broker_module=/usr/lib/ndoutils/ndomod.o config_file=/etc/nagios/ndomod.cfg||' $1/etc/nagios/nagios.cfg
112 }