wok annotate ndoutils/receipt @ rev 22926

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