]> granicus.if.org Git - icinga2/commitdiff
Debian: Fixed config check and changed DAEMON_ARGS in init script.
authorMarkus Frosch <markus@lazyfrosch.de>
Wed, 4 Dec 2013 18:50:10 +0000 (19:50 +0100)
committerMarkus Frosch <markus@lazyfrosch.de>
Wed, 4 Dec 2013 18:50:10 +0000 (19:50 +0100)
Check now actually works, command was incorrect and not properly blocking the
actual action on fail.

Also the config file is now in DAEMON_CONFIG variable.

Fixes #5086

debian/icinga2-common.icinga2.default
debian/icinga2-common.icinga2.init

index afb0e75bc0dfba9ecacb6f1cf0a1cf8882913bf1..b24f3ddeb7f4aa6506f73b49c6b957eb270f2780 100644 (file)
@@ -1,3 +1,4 @@
 # default settings for icinga2's initscript
 
-#DAEMON_ARGS="-c /etc/icinga2/icinga2.conf -e /var/log/icinga2/icinga2.err -d -u nagios -g nagios"
+#DAEMON_CONFIG="/etc/icinga2/icinga2.conf"
+#DAEMON_ARGS="-e /var/log/icinga2/icinga2.err -d -u nagios -g nagios"
index e646b421c2f427b428823cd91adf5d48dae505f0..f980465747b26c535713ec32ce2609d30dd7fd95 100644 (file)
@@ -17,7 +17,8 @@ PATH=/sbin:/usr/sbin:/bin:/usr/bin
 DESC="icinga2 monitoring daemon"
 NAME=icinga2
 DAEMON=/usr/sbin/icinga2
-DAEMON_ARGS="-c /etc/icinga2/icinga2.conf -e /var/log/icinga2/icinga2.err -d -u nagios -g nagios"
+DAEMON_CONFIG="/etc/icinga2/icinga2.conf"
+DAEMON_ARGS="-e /var/log/icinga2/icinga2.err -d -u nagios -g nagios"
 PIDFILE=/var/run/icinga2/$NAME.pid
 SCRIPTNAME=/etc/init.d/$NAME
 
@@ -48,7 +49,10 @@ check_run () {
 }
 
 check_config () {
-  $DAEMON -C $DAEMON_ARGS
+  if ! $DAEMON --validate -c "$DAEMON_CONFIG" >/dev/null 2>&1; then
+    # blark output
+    $DAEMON --validate -c "$DAEMON_CONFIG"
+  fi
 }
 
 
@@ -64,7 +68,7 @@ do_start()
        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
                || return 1
        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
-               $DAEMON_ARGS \
+               -c "$DAEMON_CONFIG" $DAEMON_ARGS \
                || return 2
        # Add code here, if necessary, that waits for the process to be ready
        # to handle requests from services started subsequently which depend
@@ -118,6 +122,7 @@ case "$1" in
     if ! check_config; then
         log_failure_msg "config test failed!"
         log_end_msg 1
+        exit 1
     fi
 
        log_daemon_msg "Starting $DESC" "$NAME"
@@ -143,6 +148,7 @@ case "$1" in
     if ! check_config; then
         log_failure_msg "config test failed!"
         log_end_msg 1
+        exit 1
     fi
 
        log_daemon_msg "Reloading $DESC" "$NAME"
@@ -154,6 +160,7 @@ case "$1" in
     if ! check_config; then
         log_failure_msg "config test failed!"
         log_end_msg 1
+        exit 1
     fi
 
        log_daemon_msg "Restarting $DESC" "$NAME"