[Pkg-nagios-changes] [pkg-nagios] r16 - nagios2/trunk/debian

Marc Haber zugschlus at costa.debian.org
Tue Dec 20 19:08:52 UTC 2005


Author: zugschlus
Date: 2005-12-20 19:08:52 +0000 (Tue, 20 Dec 2005)
New Revision: 16

Added:
   nagios2/trunk/debian/nagios2-common.nagios2.default
   nagios2/trunk/debian/nagios2-common.nagios2.init
Modified:
   nagios2/trunk/debian/control
   nagios2/trunk/debian/rules
Log:
add init script, have it installed and enabled


Modified: nagios2/trunk/debian/control
===================================================================
--- nagios2/trunk/debian/control	2005-12-20 18:44:08 UTC (rev 15)
+++ nagios2/trunk/debian/control	2005-12-20 19:08:52 UTC (rev 16)
@@ -8,7 +8,7 @@
 
 Package: nagios2-common
 Architecture: all
-Depends: nagios-plugins-basic, coreutils (>= 4.5.3), apache2 | httpd, mailx, adduser, ${misc:Depends}
+Depends: nagios-plugins-basic, coreutils (>= 4.5.3), apache2 | httpd, mailx, adduser, lsb-base, ${misc:Depends}
 Recommends: nagios-plugins
 Conflicts: nagios-mysql, nagios-pgsql, nagios-common
 Replaces: nagios, nagios-common

Added: nagios2/trunk/debian/nagios2-common.nagios2.default
===================================================================
--- nagios2/trunk/debian/nagios2-common.nagios2.default	2005-12-20 18:44:08 UTC (rev 15)
+++ nagios2/trunk/debian/nagios2-common.nagios2.default	2005-12-20 19:08:52 UTC (rev 16)
@@ -0,0 +1,10 @@
+# /etc/default/nagios2
+
+# location of the nagios configuration file
+NAGIOSCFG="/etc/nagios/nagios.cfg"
+
+# location of the CGI configuration file
+CGICFG="/etc/nagios/cgi.cfg"
+
+# nicelevel to run nagios daemon with
+NICENESS=5

Added: nagios2/trunk/debian/nagios2-common.nagios2.init
===================================================================
--- nagios2/trunk/debian/nagios2-common.nagios2.init	2005-12-20 18:44:08 UTC (rev 15)
+++ nagios2/trunk/debian/nagios2-common.nagios2.init	2005-12-20 19:08:52 UTC (rev 16)
@@ -0,0 +1,203 @@
+#! /bin/sh
+#		Written by Miquel van Smoorenburg <miquels at cistron.nl>.
+#		Modified for Debian GNU/Linux
+#		by Ian Murdock <imurdock at gnu.ai.mit.edu>.
+#               Clamav version by Magnus Ekdahl <magnus at debian.org>
+#		nagios2 version by Marc Haber <mh+debian-packages at zugschlus.de>
+
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
+DAEMON=/usr/sbin/nagios
+NAME="nagios"
+DESC="nagios2 daemon"
+NAGIOSCFG="/etc/nagios/nagios.cfg"
+CGICFG="/etc/nagios/cgi.cfg"
+NICENESS=5
+
+[ -x "$DAEMON" ] || exit 0
+[ -r /etc/default/nagios2 ] && . /etc/default/nagios2
+. /lib/lsb/init-functions
+
+check_started () {
+  check_cmd="$(get_config "nagios_check_command" "$CGICFG")"
+  if [ ! "$check_cmd" ]; then
+    echo "unable to determine nagios_check_command from $CGICFG!" >&2
+    return 1
+  fi
+
+  eval $check_cmd >/dev/null
+		
+  if [ -f "$THEPIDFILE" ]; then
+    pid="$(cat $THEPIDFILE)"
+    if [ "$pid" ] && kill -0 $pid >/dev/null; then
+      return 0    # Is started
+    fi
+  fi
+  return 1	# Isn't started
+}
+
+#
+#	get_config()
+#
+#	grab a config option from nagios.cfg (or possibly another nagios config
+#	file if specified).  everything after the '=' is echo'd out, making
+#	this a nice generalized way to get requested settings.
+#
+get_config () {
+  if [ "$2" ]; then
+    set -- `grep ^$1 $2 | sed 's@=@ @'`
+  else
+    set -- `grep ^$1 $NAGIOSCFG | sed 's@=@ @'`
+  fi
+  shift
+  echo $*
+}
+
+check_config () {
+  if $DAEMON -v $NAGIOSCFG >/dev/null 2>&1 ; then
+    # First get the user/group etc Nagios is running as
+    nagios_user="$(get_config nagios_user)"
+    nagios_group="$(get_config nagios_group)"
+    log_file="$(get_config log_file)"
+    log_dir="$(dirname $log_file)"
+
+    # Chown the log directory to this user/group so that
+    # Nagios can write there.
+    chown -R ${nagios_user}:$nagios_group $log_dir
+
+    return 0    # Config is ok
+  else
+    # config is not okay, so let's barf the error to the user
+    $DAEMON -v $NAGIOSCFG
+  fi
+}
+
+check_named_pipe () {
+  nagiospipe="$(get_config command_file)"
+  if [ -p "$nagiospipe" ]; then
+    return 1   # a named pipe exists
+  else
+    return 0   # no named pipe exists
+  fi
+}
+
+if [ ! -f "$NAGIOSCFG" ]; then
+  log_failure_msg "There is no configuration file for Nagios 2."
+  exit 1;
+fi
+
+#if grep -q "^Example" $NAGIOSCFG; then
+#  log_failure_msg "Nagios 2 is not configured."
+#  log_failure_msg "Please edit $NAGIOSCFG and run  '/etc/init.d/nagios start'"
+#  exit 0
+#fi
+
+THEPIDFILE="$(grep lock_file $NAGIOSCFG | awk '{print $2}' FS="=")"
+[ -n "$THEPIDFILE" ] || THEPIDFILE='/var/run/nagios/nagios.pid'
+
+[ -e "$THEPIDFILE" ] && PID=$(cat $THEPIDFILE)
+
+[ "$PID" = '1' ] && unset PID
+
+start () {
+  if ! check_started; then
+    if ! check_named_pipe; then
+      log_action_msg "named pipe exists - removing"
+      rm -f $nagiospipe
+    fi
+    if check_config; then
+      start_daemon -n $NICENESS -p $THEPIDFILE $DAEMON -d $NAGIOSCFG
+      ret=$?
+    else
+      log_failure_msg "errors in config!"
+      log_end_msg 1
+      exit 1
+    fi
+  else
+    log_failure_msg "already running!"
+    log_end_msg 1
+    exit 1
+  fi
+}
+
+stop () {
+    if [ -n "$PID" ]; then
+      kill -15 -"$PID"
+      ret=$?
+#      sleep 1
+#      if kill -0 "$PID" 2>/dev/null; then
+#        ret=$?
+#        log_progress_msg "Waiting . "
+#        cnt=0
+#        while kill -0 "$PID" 2>/dev/null; do
+#          ret=$?
+#          cnt=`expr "$cnt" + 1`
+#          if [ "$cnt" -gt 15 ]; then
+#            kill -9 -"$PID"
+#            break
+#          fi
+#          sleep 2
+#          log_progress_msg ". "
+#        done
+#      fi
+    else
+      killproc -p $THEPIDFILE
+      ret=$?
+    fi
+    if ! check_named_pipe; then
+      rm -f $nagiospipe
+    fi
+    if [ -n "$ret" ]; then
+      return $ret
+    else
+      return $?
+    fi
+}
+
+reload () {
+  # Check first
+  if check_config; then
+    if check_started; then
+      killproc -p $THEPIDFILE $DAEMON 1 
+    else
+      log_failure_msg "Not running."
+      log_end_msg 1
+      exit 1
+    fi
+  else
+    log_failure_msg "errors in config!"
+    log_end_msg 1
+    exit 1
+ fi
+}
+
+case "$1" in
+  start)
+    log_daemon_msg "Starting $DESC" "$NAME"
+    start
+    log_end_msg $ret
+    ;;
+  stop)
+    log_daemon_msg "Stopping $DESC" "$NAME"
+    stop
+    log_end_msg $?
+  ;;
+  restart)
+    log_daemon_msg "Restarting $DESC" "$NAME"
+    stop
+    if [ -z "$?" ]; then
+      start
+    fi
+    log_end_msg $?
+  ;;
+  reload|force-reload)
+    log_daemon_msg "Reloading $DESC configuration files" "$NAME"
+    reload
+    log_end_msg $?
+  ;;
+  *)
+    log_failure_msg "Usage: $0 {start|stop|restart|reload|force-reload}" >&2
+    exit 1
+  ;;
+esac
+
+exit 0


Property changes on: nagios2/trunk/debian/nagios2-common.nagios2.init
___________________________________________________________________
Name: svn:executable
   + *

Modified: nagios2/trunk/debian/rules
===================================================================
--- nagios2/trunk/debian/rules	2005-12-20 18:44:08 UTC (rev 15)
+++ nagios2/trunk/debian/rules	2005-12-20 19:08:52 UTC (rev 16)
@@ -122,7 +122,7 @@
 	#dh_install           -i
 	#install -m 755 cgi/grouplist.cgi.in debian/$@/usr/lib/cgi-bin/nagios/grouplist.cgi
 	# they install it themselves now?
-	#dh_installinit 	     -p$@ -P$(b)/$@ --name nagios -- defaults 30 18
+	dh_installinit 	     --name nagios2 -- defaults 30 18
 	#chmod +x $(maindir)/debian/nagios-common/usr/lib/nagios/plugins/check-imap
 	#chmod +x $(maindir)/debian/nagios-common/usr/lib/cgi-bin/nagios/traceroute.cgi
 	#chmod 660 $(maindir)/debian/nagios-common/etc/nagios/resource.cfg




More information about the Pkg-nagios-changes mailing list