wok-6.x view ndoutils/receipt @ rev 16681

Create some /var/run/<dir> in /etc/init.d/<daemon> scritps
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun May 18 20:24:07 2014 +0000 (2014-05-18)
parents 23c3aed67cd9
children 9e01bc6321ea
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 LICENSE="GPL2"
9 TARBALL="$PACKAGE-$VERSION.tar.gz"
10 WEB_SITE="http://www.nagios.org/"
11 WGET_URL="$SF_MIRROR/nagios/$TARBALL"
12 CONFIG_FILES="/etc/nagios"
14 DEPENDS="nagios mysql"
15 BUILD_DEPENDS="mysql-dev"
17 # Rules to configure and make the package.
18 compile_rules()
19 {
20 cd $src
22 while read patch_file; do
23 if [ ! -f done.$patch_file ]; then
24 patch -p1 < $stuff/$patch_file || exit 1
25 touch done.$patch_file
26 fi
27 done <<EOT
28 $PACKAGE-$VERSION-Makefiles.in.u
29 EOT
31 ./configure --prefix=/usr \
32 --with-ndo2db-user=nagios \
33 --with-ndo2db-group=nagios \
34 --localstatedir=/var/run/nagios \
35 --sysconfdir=/etc/nagios \
36 --libexecdir=/usr/lib/$PACKAGE \
37 --mandir=/usr/share/man $CONFIGURE_ARGS &&
38 make && \
39 make DESTDIR=$DESTDIR install && \
40 make DESTDIR=$DESTDIR install-config
41 }
43 # Rules to gen a SliTaz package suitable for Tazpkg.
44 genpkg_rules()
45 {
46 mkdir -p $fs/usr/share/nagios/ndoutils \
47 $fs/etc/nagios \
48 $fs/etc/mysql.d
50 cp -a $install/usr/bin $fs/usr
51 cp -a $install/usr/lib $fs/usr
52 cp -a $install/etc $fs
54 # config ndo2db.cfg
55 sed -i -e 's/ndo2db_user=nagios/ndo2db_user=nagios/' \
56 -e 's/ndo2db_group=nagios/ndo2db_group=nagios/' \
57 -e 's|/usr/local/nagios/var/|/var/run/nagios/|' \
58 -e 's/db_user=ndouser/db_user=root/' \
59 -e 's/db_pass=ndopassword/db_pass=/' $fs/etc/nagios/ndo2db.cfg
61 # config ndomod.cfg
62 sed -i -e 's|output=/usr/local/nagios/var/|output=/var/run/nagios/|' \
63 -e 's|buffer_file=/usr/local/nagios/var/|buffer_file=/var/tmp/|' \
64 $fs/etc/nagios/ndomod.cfg
66 cp -a $src/db/mysql.sql $fs/usr/share/nagios/ndoutils/nagios.sql
67 cp -a stuff/etc $fs
69 chmod 755 $fs/usr/bin/*
70 chmod 755 $fs/etc/mysql.d/*
71 }
73 post_install()
74 {
75 if ! grep -q nagios $1/etc/passwd; then
76 echo -n "Adding user nagios..."
77 chroot $1/ adduser -S -D -H nagios
78 status
79 fi
81 if ! grep -q ndomod.cfg $1/etc/nagios/nagios.cfg; then
82 sed -i '/LOG ROTATION METHOD/i\broker_module=/usr/lib/ndoutils/ndomod.o config_file=/etc/nagios/ndomod.cfg' $1/etc/nagios/nagios.cfg
83 chroot $1/ chown nagios.nagios $1/etc/nagios/nagios.cfg
84 fi
86 chroot $1/ chown nagios.nagios $fs/usr/lib/ndoutils/ndomod.o \
87 $fs/etc/nagios/ndo2db.cfg $fs/etc/nagios/ndomod.cfg \
88 $fs/etc/nagios
90 sed -i "s/nagios/ndo2db nagios/" $1/etc/rcS.conf
92 if [ -z "$1" ]; then
93 [ -f /var/run/mysqld/mysql.pid ] || /etc/init.d/mysql start
94 /etc/mysql.d/$PACKAGE
95 #/usr/bin/ndo2db -c /etc/nagios/ndo2db.cfg
96 /etc/init.d/ndo2db start
97 /etc/init.d/nagios stop
98 /etc/init.d/nagios start
100 fi
101 }
103 pre_remove()
104 {
105 /etc/init.d/ndo2db stop
106 }
108 post_remove()
109 {
110 sed -i "s/ndo2db//" $1/etc/rcS.conf
111 /etc/init.d/nagios restart
112 sed -i 's|broker_module=/usr/lib/ndoutils/ndomod.o config_file=/etc/nagios/ndomod.cfg||' $1/etc/nagios/nagios.cfg
113 }