Author: glen                         Date: Tue Dec  7 14:20:25 2010 GMT
Module: packages                      Tag: HEAD
---- Log message:
- empty configtest body

---- Files affected:
packages/nagios-merlin:
   merlind.init (1.2 -> 1.3) 

---- Diffs:

================================================================
Index: packages/nagios-merlin/merlind.init
diff -u packages/nagios-merlin/merlind.init:1.2 
packages/nagios-merlin/merlind.init:1.3
--- packages/nagios-merlin/merlind.init:1.2     Tue Dec  7 15:12:43 2010
+++ packages/nagios-merlin/merlind.init Tue Dec  7 15:20:20 2010
@@ -35,6 +35,44 @@
 pidfile="/var/run/merlind.pid"
 config_file=/etc/nagios/merlin.conf
 
+# configtest itself
+# must return non-zero if check failed
+# output is discarded if checkconfig is ran without details
+configtest() {
+       local val ret=0
+
+       return $ret
+}
+
+# wrapper for configtest
+checkconfig() {
+       local details=${1:-0}
+
+       if [ $details = 1 ]; then
+               # run config test and display report (status action)
+               show "Checking %s configuration" "Merlin Daemon"; busy
+               local out
+               out=$(configtest 2>&1)
+               RETVAL=$?
+               if [ $RETVAL = 0 ]; then
+                       ok
+               else
+                       fail
+               fi
+               [ "$out" ] && echo >&2 "$out"
+       else
+               # run config test and abort with nice message if failed
+               # (for actions checking status before action).
+               configtest >/dev/null 2>&1
+               RETVAL=$?
+               if [ $RETVAL != 0 ]; then
+                       show "Checking %s configuration" "Merlin Daemon"; fail
+                       nls 'Configuration test failed. See details with %s 
"checkconfig"' $0
+                       exit $RETVAL
+               fi
+       fi
+}
+
 start() {
        # Check if the service is already running?
        if [ -f /var/lock/subsys/merlind ]; then
@@ -42,6 +80,7 @@
                return
        fi
 
+       checkconfig
        msg_starting "Merlin Daemon"
        daemon $daemon -c "$config_file"
        RETVAL=$?
@@ -67,6 +106,7 @@
                return
        fi
 
+       checkconfig
        stop
        start
 }
@@ -81,6 +121,7 @@
        stop
        ;;
   restart)
+       checkconfig
        stop
        start
        ;;
@@ -90,12 +131,15 @@
   force-reload)
        condrestart 7
        ;;
+  checkconfig|configtest)
+       checkconfig 1
+       ;;
   status)
        status --pidfile $pidfile merlind
        RETVAL=$?
        ;;
   *)
-       msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
+       msg_usage "$0 
{start|stop|restart|try-restart|force-reload|checkconfig|status}"
        exit 3
 esac
 
================================================================

---- CVS-web:
    
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/nagios-merlin/merlind.init?r1=1.2&r2=1.3&f=u

_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to