wok rev 8703

add:: ndoutils
author Eric Joseph-Alexandre <erjo@slitaz.org>
date Thu Feb 17 23:12:37 2011 +0100 (2011-02-17)
parents 3b3a18a0c294
children 2b32764afdc5
files ndoutils/receipt ndoutils/stuff/etc/init.d/ndo2db ndoutils/stuff/etc/mysql.d/ndoutils ndoutils/stuff/ndoutils-1.4b9-Makefile.in.u ndoutils/stuff/ndoutils-1.4b9-Makefiles.in.u
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/ndoutils/receipt	Thu Feb 17 23:12:37 2011 +0100
     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 +}
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/ndoutils/stuff/etc/init.d/ndo2db	Thu Feb 17 23:12:37 2011 +0100
     2.3 @@ -0,0 +1,163 @@
     2.4 +#!/bin/sh
     2.5 +# 
     2.6 +#
     2.7 +# chkconfig: 345 99 01
     2.8 +# description: Nagios to mysql
     2.9 +#
    2.10 +# Author : Gaétan Lucas
    2.11 +# Realase : 07/02/08
    2.12 +# Version : 0.1 b
    2.13 +# File : ndo2db
    2.14 +# Description: Starts and stops the Ndo2db daemon
    2.15 +#              used to provide network services status in a database.
    2.16 +#
    2.17 +  
    2.18 +status_ndo ()
    2.19 +{
    2.20 +	if ps -p $NdoPID > /dev/null 2>&1; then
    2.21 +	        return 0
    2.22 +	else
    2.23 +		return 1
    2.24 +	fi
    2.25 +
    2.26 +	return 1
    2.27 +}
    2.28 +
    2.29 +printstatus_ndo()
    2.30 +{
    2.31 +	if status_ndo $1 $2; then
    2.32 +		echo "ndo (pid $NdoPID) is running..."
    2.33 +	else
    2.34 +		echo "ndo is not running"
    2.35 +	fi
    2.36 +}
    2.37 +
    2.38 +killproc_ndo ()
    2.39 +{
    2.40 +	echo "kill $2 $NdoPID"
    2.41 +	kill $2 $NdoPID
    2.42 +}
    2.43 +
    2.44 +pid_ndo ()
    2.45 +{
    2.46 +	if test ! -f $NdoRunFile; then
    2.47 +		echo "No lock file found in $NdoRunFile"
    2.48 +		echo -n "         checking runing process..."
    2.49 +		NdoPID=`ps -ef|grep ndo2db|cut -c0-5`
    2.50 +		if [ -z "$NdoPID" ]; then
    2.51 +			echo "     No ndo2db process found"
    2.52 +			exit 1
    2.53 +		else
    2.54 +			echo "     found process pid: $NdoPID"
    2.55 +			echo -n "         reinit $NdoRunFile ..."
    2.56 +			touch $NdoRunFile
    2.57 +			chown $NdoUser:$NdoGroup $NdoRunFile
    2.58 +			echo "$NdoPID" > $NdoRunFile
    2.59 +			echo "     done"
    2.60 +		fi
    2.61 +	fi
    2.62 +
    2.63 +	NdoPID=`head $NdoRunFile`
    2.64 +}
    2.65 +
    2.66 +# Source function library
    2.67 +# Solaris doesn't have an rc.d directory, so do a test first
    2.68 +if [ -f /etc/rc.d/init.d/functions ]; then
    2.69 +	. /etc/rc.d/init.d/functions
    2.70 +elif [ -f /etc/init.d/functions ]; then
    2.71 +	. /etc/init.d/functions
    2.72 +fi
    2.73 +
    2.74 +prefix=/usr
    2.75 +exec_prefix=${prefix}/bin
    2.76 +NdoBin=${exec_prefix}/ndo2db
    2.77 +NdoCfgFile=/etc/nagios/ndo2db.cfg
    2.78 +NdoRunFile=/var/run/nagios/ndo2db.run
    2.79 +NdoLockDir=/var/lock/subsys
    2.80 +NdoLockFile=ndo2db.lock
    2.81 +NdoUser=nagios
    2.82 +NdoGroup=nagios
    2.83 +          
    2.84 +# Check that ndo exists.
    2.85 +if [ ! -f $NdoBin ]; then
    2.86 +   echo "Executable file $NdoBin not found.  Exiting."
    2.87 +   exit 1
    2.88 +fi
    2.89 +
    2.90 +# Check that ndo.cfg exists.
    2.91 +if [ ! -f $NdoCfgFile ]; then
    2.92 +   echo "Configuration file $NdoCfgFile not found.  Exiting."
    2.93 +   exit 1
    2.94 +fi
    2.95 +          
    2.96 +# See how we were called.
    2.97 +case "$1" in
    2.98 +
    2.99 +	start)
   2.100 +		echo -n "Starting ndo:"
   2.101 +		touch $NdoRunFile
   2.102 +		chown $NdoUser:$NdoGroup $NdoRunFile
   2.103 +		$NdoBin -c $NdoCfgFile
   2.104 +		if [ -d $NdoLockDir ]; then
   2.105 +			touch $NdoLockDir/$NdoLockFile;
   2.106 +	       	fi
   2.107 +		ps -ef|grep ndo2db|cut -c0-5 > $NdoRunFile
   2.108 +		if [ $? -eq 0 ]; then
   2.109 +			echo " done."
   2.110 +			exit 0
   2.111 +		else
   2.112 +			echo " failed."
   2.113 +			$0 stop
   2.114 +			exit 1
   2.115 +		fi
   2.116 +		;;
   2.117 +
   2.118 +	stop)
   2.119 +		echo -n "Stopping ndo: "
   2.120 +
   2.121 +		pid_ndo
   2.122 +		killproc_ndo
   2.123 +
   2.124 +		# now we have to wait for ndo to exit and remove its
   2.125 +		# own NdoRunFile, otherwise a following "start" could
   2.126 +		# happen, and then the exiting ndo will remove the
   2.127 +		# new NdoRunFile, allowing multiple ndo daemons
   2.128 +		# to (sooner or later) run
   2.129 +		#echo -n 'Waiting for ndo to exit .'
   2.130 +		for i in 1 2 3 4 5 6 7 8 9 10 ; do
   2.131 +		    if status_ndo > /dev/null; then
   2.132 +			echo -n '.'
   2.133 +			sleep 1
   2.134 +		    else
   2.135 +			break
   2.136 +		    fi
   2.137 +		done
   2.138 +		if status_ndo > /dev/null; then
   2.139 +		    echo 
   2.140 +		    echo 'Warning - ndo did not exit in a timely manner'
   2.141 +		else
   2.142 +		    echo 'done.'
   2.143 + 		fi
   2.144 +
   2.145 +		rm -f $NdoRunFile $NdoLockDir/$NdoLockFile
   2.146 +		;;
   2.147 +
   2.148 +	status)
   2.149 +		pid_ndo
   2.150 +		printstatus_ndo ndo
   2.151 +		;;
   2.152 +
   2.153 +	restart)
   2.154 +		$0 stop
   2.155 +		$0 start
   2.156 +		;;
   2.157 +
   2.158 +	*)
   2.159 +		echo "Usage: ndo {start|stop|restart|status}"
   2.160 +		exit 1
   2.161 +		;;
   2.162 +
   2.163 +esac
   2.164 +  
   2.165 +# End of this script
   2.166 +
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/ndoutils/stuff/etc/mysql.d/ndoutils	Thu Feb 17 23:12:37 2011 +0100
     3.3 @@ -0,0 +1,9 @@
     3.4 +#!/bin/sh
     3.5 +
     3.6 +mysqldump nagios > /dev/null 2>&1 ||
     3.7 +mysql <<EOT
     3.8 +create database nagios;
     3.9 +use nagios;
    3.10 +\. /usr/share/nagios/ndoutils/nagios.sql
    3.11 +EOT
    3.12 +chmod -x /etc/mysql.d/ndoutils
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/ndoutils/stuff/ndoutils-1.4b9-Makefile.in.u	Thu Feb 17 23:12:37 2011 +0100
     4.3 @@ -0,0 +1,11 @@
     4.4 +--- ndoutils-1.4b9-ori/Makefile	Sat Jun 12 09:56:33 2010
     4.5 ++++ ndoutils-1.4b9/Makefile	Sat Jun 12 09:57:06 2010
     4.6 +@@ -17,7 +17,7 @@
     4.7 + BINDIR=${exec_prefix}/bin
     4.8 + LIBEXECDIR=${exec_prefix}/libexec
     4.9 + INSTALL=/usr/bin/install -c
    4.10 +-INSTALL_OPTS=-o nagios -g nagios
    4.11 ++INSTALL_OPTS=
    4.12 + INIT_DIR=/etc/init.d
    4.13 + INIT_OPTS=-o root -g root
    4.14 + 
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/ndoutils/stuff/ndoutils-1.4b9-Makefiles.in.u	Thu Feb 17 23:12:37 2011 +0100
     5.3 @@ -0,0 +1,42 @@
     5.4 +--- ndoutils-1.4b9-ori/Makefile.in	Tue Sep 15 14:04:34 2009
     5.5 ++++ ndoutils-1.4b9/Makefile.in	Sat Jun 12 10:47:30 2010
     5.6 +@@ -17,7 +17,7 @@
     5.7 + BINDIR=@bindir@
     5.8 + LIBEXECDIR=@libexecdir@
     5.9 + INSTALL=@INSTALL@
    5.10 +-INSTALL_OPTS=@INSTALL_OPTS@
    5.11 ++INSTALL_OPTS=
    5.12 + INIT_DIR=@init_dir@
    5.13 + INIT_OPTS=-o root -g root
    5.14 + 
    5.15 +@@ -32,8 +32,8 @@
    5.16 + 
    5.17 + install-config:
    5.18 + 	$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(CFGDIR)
    5.19 +-	$(INSTALL) -b -m 664 $(INSTALL_OPTS) config/ndo2db.cfg-sample $(DESTDIR)$(CFGDIR)
    5.20 +-	$(INSTALL) -b -m 664 $(INSTALL_OPTS) config/ndomod.cfg-sample $(DESTDIR)$(CFGDIR)
    5.21 ++	$(INSTALL) -b -m 664 $(INSTALL_OPTS) config/ndo2db.cfg-sample $(DESTDIR)$(CFGDIR)/ndo2db.cfg
    5.22 ++	$(INSTALL) -b -m 664 $(INSTALL_OPTS) config/ndomod.cfg-sample $(DESTDIR)$(CFGDIR)/ndomod.cfg
    5.23 + 	@echo ""
    5.24 + 	@echo "*** Config files installed ***"
    5.25 + 	@echo ""
    5.26 +--- ndoutils-1.4b9-ori/src/Makefile.in	Tue Sep 15 14:04:35 2009
    5.27 ++++ ndoutils-1.4b9/src/Makefile.in	Sat Jun 12 10:53:40 2010
    5.28 +@@ -16,7 +16,7 @@
    5.29 + LIBEXECDIR=@libexecdir@
    5.30 + CGIDIR=@sbindir@
    5.31 + INSTALL=@INSTALL@
    5.32 +-INSTALL_OPTS=@INSTALL_OPTS@
    5.33 ++INSTALL_OPTS=
    5.34 + 
    5.35 + CC=@CC@
    5.36 + 
    5.37 +@@ -130,6 +130,7 @@
    5.38 + 
    5.39 + install-3x:
    5.40 + 	$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(BINDIR)
    5.41 ++	$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(LIBEXECDIR)
    5.42 + 	$(INSTALL) -m 755 $(INSTALL_OPTS) ndo2db-3x $(DESTDIR)$(BINDIR)/ndo2db
    5.43 +-	$(INSTALL) -m 755 $(INSTALL_OPTS) ndomod-3x.o $(DESTDIR)$(BINDIR)/ndomod.o
    5.44 ++	$(INSTALL) -m 755 $(INSTALL_OPTS) ndomod-3x.o $(DESTDIR)$(LIBEXECDIR)/ndomod.o
    5.45 +