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

Marc Haber zugschlus at costa.debian.org
Wed Aug 16 08:16:47 UTC 2006


Author: zugschlus
Date: 2006-08-16 08:16:47 +0000 (Wed, 16 Aug 2006)
New Revision: 978

Modified:
   nagios2/trunk/debian/changelog
   nagios2/trunk/debian/nagios2-common.nagios2.init
Log:
  * lsb-ize init script. Closes: #377028



Modified: nagios2/trunk/debian/changelog
===================================================================
--- nagios2/trunk/debian/changelog	2006-08-16 08:00:04 UTC (rev 977)
+++ nagios2/trunk/debian/changelog	2006-08-16 08:16:47 UTC (rev 978)
@@ -5,6 +5,7 @@
     * Now gracefully exits with meaningful log entry if p1.pl is not found.
       Thanks to Matt Brown. Closes: #368684
   * -dbg package is extra. Thanks to Joerg Jaspert.
+  * lsb-ize init script. Closes: #377028
   * Versioned recommends on nagios-images >> 0.1, since n-i 0.2 has
     symlinks fixing the issue mentioned by Herbert Straub. Closes: #358922.
   * remove _ from Default: false in boolean template.
@@ -19,7 +20,7 @@
   * New Czech (cs) translation.
     Thanks to Martin Šín. Closes: #382924
 
- -- Marc Haber <mh+debian-packages at zugschlus.de>  Wed, 16 Aug 2006 07:59:22 +0000
+ -- Marc Haber <mh+debian-packages at zugschlus.de>  Wed, 16 Aug 2006 08:16:00 +0000
 
 nagios2 (2.4-1) unstable; urgency=low
 

Modified: nagios2/trunk/debian/nagios2-common.nagios2.init
===================================================================
--- nagios2/trunk/debian/nagios2-common.nagios2.init	2006-08-16 08:00:04 UTC (rev 977)
+++ nagios2/trunk/debian/nagios2-common.nagios2.init	2006-08-16 08:16:47 UTC (rev 978)
@@ -6,7 +6,27 @@
 #		Nagios version by Sean Finney <seanius at debian.org> and probably others
 #		nagios2 version by Marc Haber <mh+debian-packages at zugschlus.de>
 
-PATH=/sbin:/bin:/usr/sbin:/usr/bin
+### BEGIN INIT INFO
+# Provides:          nagios2
+# Required-Start:    $local_fs $remote_fs $syslog $named $network $time
+# Required-Stop:     $local_fs $remote_fs $syslog $named $network
+# Should-Start:      
+# Should-Stop:       
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: nagios host/service/network monitoring and management system
+# Description:       nagios is a monitoring and management system for hosts, services and networks.
+### END INIT INFO
+
+set -e
+
+if ! [ -x "/lib/lsb/init-functions" ]; then
+  . /lib/lsb/init-functions
+else
+  echo "E: /lib/lsb/init-functions not found, lsb-base (>= 3.0-6) needed"
+  exit 1
+fi
+
 DAEMON=/usr/sbin/nagios2
 NAME="nagios2"
 DESC="nagios2 monitoring daemon"
@@ -16,13 +36,25 @@
 
 [ -x "$DAEMON" ] || exit 0
 [ -r /etc/default/nagios2 ] && . /etc/default/nagios2
-. /lib/lsb/init-functions
 
+# this is from madduck on IRC, 2006-07-06
+# There should be a better possibility to give daemon error messages
+# and/or to log things
+log()
+{
+  case "$1" in
+    [[:digit:]]*) success=$1; shift;;
+    *) :;;
+  esac
+  log_action_begin_msg "$1"; shift
+  log_action_end_msg ${success:-0} "$*"
+}
+
 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
+    log 6 "unable to determine nagios_check_command from $CGICFG!" 
+    return 6
   fi
 
   eval $check_cmd >/dev/null
@@ -79,15 +111,9 @@
 
 if [ ! -f "$NAGIOSCFG" ]; then
   log_failure_msg "There is no configuration file for Nagios 2."
-  exit 1;
+  exit 6
 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/nagios2/nagios.pid'
 
@@ -119,6 +145,7 @@
     log_end_msg 1
     exit 1
   fi
+  return $ret
 }
 
 stop () {
@@ -155,6 +182,23 @@
     fi
 }
 
+status()
+{
+  log_action_begin_msg "checking $DAEMON"
+  if start-stop-daemon --stop --signal 0 --quiet --pid $THEPIDFILE >/dev/null; then
+    log_action_end_msg 0 "running"
+  else
+    if [ -e "$THEPIDFILE" ]; then
+      log_action_end_msg 1 "$DAEMON failed"
+      exit 1
+    else
+      log_action_end_msg 0 "not running"
+      exit 3
+    fi
+  fi
+}
+
+
 reload () {
   # Check first
   if check_config; then
@@ -162,13 +206,13 @@
       killproc -p $THEPIDFILE $DAEMON 1 
     else
       log_failure_msg "Not running."
-      log_end_msg 1
-      exit 1
+      log_end_msg 7
+      exit 7
     fi
   else
     log_failure_msg "errors in config!"
-    log_end_msg 1
-    exit 1
+    log_end_msg 6
+    exit 6
  fi
 }
 
@@ -176,7 +220,7 @@
   start)
     log_daemon_msg "Starting $DESC" "$NAME"
     start
-    log_end_msg $ret
+    log_end_msg $?
     ;;
   stop)
     log_daemon_msg "Stopping $DESC" "$NAME"
@@ -196,8 +240,11 @@
     reload
     log_end_msg $?
   ;;
+  status)
+    status
+    ;;
   *)
-    log_failure_msg "Usage: $0 {start|stop|restart|reload|force-reload}" >&2
+    log_failure_msg "Usage: $0 {start|stop|restart|reload|force-reload|status}" >&2
     exit 1
   ;;
 esac




More information about the Pkg-nagios-changes mailing list