wok-next diff ndoutils/receipt @ rev 9504

Up: dhcp and dhcp6 to 4.2.1-P1.
author Christopher Rogers <slaxemulator@gmail.com>
date Tue Apr 05 22:31:31 2011 +0000 (2011-04-05)
parents
children d1768332cee0
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/ndoutils/receipt	Tue Apr 05 22:31:31 2011 +0000
     1.3 @@ -0,0 +1,112 @@
     1.4 +# SliTaz package receipt.
     1.5 +
     1.6 +PACKAGE="ndoutils"
     1.7 +VERSION="1.4b9"
     1.8 +CATEGORY="network"
     1.9 +SHORT_DESC="Provide mysql access to nagios."
    1.10 +MAINTAINER="pascal.bellard@slitaz.org"
    1.11 +TARBALL="$PACKAGE-$VERSION.tar.gz"
    1.12 +WEB_SITE="http://www.nagios.org/"
    1.13 +WGET_URL="$SF_MIRROR/nagios/$TARBALL"
    1.14 +DEPENDS="nagios mysql"
    1.15 +BUILD_DEPENDS="mysql-dev"
    1.16 +CONFIG_FILES="/etc/nagios"
    1.17 +
    1.18 +# Rules to configure and make the package.
    1.19 +compile_rules()
    1.20 +{
    1.21 +	cd $src
    1.22 +	
    1.23 +	while read patch_file; do
    1.24 +		if [ ! -f done.$patch_file ]; then
    1.25 +			patch -p1 < ../stuff/$patch_file || exit 1
    1.26 +			touch done.$patch_file
    1.27 +		fi
    1.28 +	done <<EOT
    1.29 +$PACKAGE-$VERSION-Makefiles.in.u
    1.30 +EOT
    1.31 +
    1.32 +	./configure --prefix=/usr \
    1.33 +	--with-ndo2db-user=nagios \
    1.34 +	--with-ndo2db-group=nagios \
    1.35 +	--localstatedir=/var/run/nagios \
    1.36 +	--sysconfdir=/etc/nagios \
    1.37 +	--libexecdir=/usr/lib/$PACKAGE \
    1.38 +	--mandir=/usr/share/man $CONFIGURE_ARGS &&
    1.39 +	make && \
    1.40 +	make DESTDIR=$PWD/_pkg install && \
    1.41 +	make DESTDIR=$PWD/_pkg install-config
    1.42 +}	
    1.43 +
    1.44 +# Rules to gen a SliTaz package suitable for Tazpkg.
    1.45 +genpkg_rules()
    1.46 +{
    1.47 +	mkdir -p $fs/usr/share/nagios/ndoutils \
    1.48 +		$fs/etc/nagios \
    1.49 +		$fs/var/run/nagios \
    1.50 +		$fs/etc/mysql.d
    1.51 +	
    1.52 +	cp -a $_pkg/usr/bin $fs/usr
    1.53 +	cp -a $_pkg/usr/lib $fs/usr
    1.54 +	cp -a $_pkg/etc $fs
    1.55 +	
    1.56 +	# config ndo2db.cfg
    1.57 +	sed -i  -e 's/ndo2db_user=nagios/ndo2db_user=nagios/' \
    1.58 +		-e 's/ndo2db_group=nagios/ndo2db_group=nagios/' \
    1.59 +		-e 's|/usr/local/nagios/var/|/var/run/nagios/|' \
    1.60 +		-e 's/db_user=ndouser/db_user=root/' \
    1.61 +		-e 's/db_pass=ndopassword/db_pass=/' $fs/etc/nagios/ndo2db.cfg
    1.62 +
    1.63 +	# config ndomod.cfg
    1.64 +	sed -i  -e 's|output=/usr/local/nagios/var/|output=/var/run/nagios/|' \
    1.65 +		-e 's|buffer_file=/usr/local/nagios/var/|buffer_file=/var/tmp/|' \
    1.66 +		$fs/etc/nagios/ndomod.cfg
    1.67 +
    1.68 +	cp -a  $src/db/mysql.sql  $fs/usr/share/nagios/ndoutils/nagios.sql
    1.69 +	cp -a stuff/etc $fs
    1.70 +	
    1.71 +	chmod 755 $fs/usr/bin/*
    1.72 +	chmod 755 $fs/etc/mysql.d/*
    1.73 +}
    1.74 +
    1.75 +post_install()
    1.76 +{
    1.77 +	if ! grep -q nagios $1/etc/passwd; then
    1.78 +		echo -n "Adding user nagios..."
    1.79 +		chroot $1/ adduser -S -D -H nagios
    1.80 +		status
    1.81 +	fi
    1.82 +		
    1.83 +	if ! grep -q ndomod.cfg $1/etc/nagios/nagios.cfg; then
    1.84 +		sed -i '/LOG ROTATION METHOD/i\broker_module=/usr/lib/ndoutils/ndomod.o config_file=/etc/nagios/ndomod.cfg' $1/etc/nagios/nagios.cfg
    1.85 +		chroot $1/ chown nagios.nagios $1/etc/nagios/nagios.cfg
    1.86 +	fi
    1.87 +	
    1.88 +	chroot $1/ chown nagios.nagios $fs/usr/lib/ndoutils/ndomod.o \
    1.89 +	 $fs/etc/nagios/ndo2db.cfg $fs/etc/nagios/ndomod.cfg \
    1.90 +	 $fs/var/run/nagios $fs/etc/nagios
    1.91 +
    1.92 +	sed -i "s/nagios/ndo2db nagios/" $1/etc/rcS.conf 
    1.93 +	
    1.94 +	if [ -z "$1" ]; then	
    1.95 +		[ -f /var/run/mysqld/mysql.pid ] || /etc/init.d/mysql start
    1.96 +		/etc/mysql.d/$PACKAGE    
    1.97 +		#/usr/bin/ndo2db -c /etc/nagios/ndo2db.cfg
    1.98 +		/etc/init.d/ndo2db start
    1.99 +		/etc/init.d/nagios stop
   1.100 +		/etc/init.d/nagios start
   1.101 +
   1.102 +	fi	
   1.103 +}
   1.104 +
   1.105 +pre_remove()
   1.106 +{
   1.107 +	/etc/init.d/ndo2db stop
   1.108 +}
   1.109 +
   1.110 +post_remove()
   1.111 +{
   1.112 +		sed -i "s/ndo2db//" $1/etc/rcS.conf 
   1.113 +		/etc/init.d/nagios restart
   1.114 +		sed -i 's|broker_module=/usr/lib/ndoutils/ndomod.o config_file=/etc/nagios/ndomod.cfg||' $1/etc/nagios/nagios.cfg
   1.115 +}