]> granicus.if.org Git - icinga2/commitdiff
Do not start, restart, reload on config validation errors.
authorMichael Friedrich <Michael.Friedrich@netways.de>
Sun, 16 Mar 2014 22:26:47 +0000 (23:26 +0100)
committerMichael Friedrich <Michael.Friedrich@netways.de>
Sun, 16 Mar 2014 22:26:47 +0000 (23:26 +0100)
Fixes #5781

etc/init.d/icinga2.cmake

index f7bb476b112167d9bf98a98f3afd81c4be6c4325..e550dc27277fb3feb5328cf93915d4a9d8f3f651 100644 (file)
@@ -58,12 +58,6 @@ start() {
        chown $ICINGA2_USER:$ICINGA2_COMMAND_GROUP $ICINGA2_STATE_DIR/run/icinga2/cmd
        chmod 2755 $ICINGA2_STATE_DIR/run/icinga2/cmd
 
-        echo "Validating the configuration file:"
-        if ! $DAEMON -c $ICINGA2_CONFIG_FILE -C; then
-                echo "Not starting Icinga 2 due to configuration errors."
-                exit 1
-        fi
-
         echo "Starting Icinga 2: "
         $DAEMON -c $ICINGA2_CONFIG_FILE -d -e $ICINGA2_ERROR_LOG -u $ICINGA2_USER -g $ICINGA2_GROUP
 
@@ -125,8 +119,13 @@ reload() {
 checkconfig() {
        printf "Checking configuration:"
 
-       echo "Validating the configuration file:"
-       exec $DAEMON -c $ICINGA2_CONFIG_FILE -C
+        echo "Validating the configuration file:"
+        if ! $DAEMON -c $ICINGA2_CONFIG_FILE -C; then
+                echo "Not "$1"ing Icinga 2 due to configuration errors."
+                if [ "x$2" = "xfail" ]; then
+                       exit 1
+               fi
+        fi
 }
 
 # Print status for Icinga 2
@@ -145,6 +144,7 @@ status() {
 ### main logic ###
 case "$1" in
   start)
+       checkconfig start fail
         start
         ;;
   stop)
@@ -154,10 +154,12 @@ case "$1" in
         status
         ;;
   restart|condrestart)
+       checkconfig restart fail
         stop nofail
         start
         ;;
   reload)
+       checkconfig reload fail
        reload
        ;;
   checkconfig)