Do not start, restart, reload on config validation errors.

Fixes #5781
This commit is contained in:
Michael Friedrich 2014-03-16 23:26:47 +01:00
parent 2d38f68bd6
commit 1e9f2f57a3

View File

@ -58,12 +58,6 @@ start() {
chown $ICINGA2_USER:$ICINGA2_COMMAND_GROUP $ICINGA2_STATE_DIR/run/icinga2/cmd chown $ICINGA2_USER:$ICINGA2_COMMAND_GROUP $ICINGA2_STATE_DIR/run/icinga2/cmd
chmod 2755 $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: " echo "Starting Icinga 2: "
$DAEMON -c $ICINGA2_CONFIG_FILE -d -e $ICINGA2_ERROR_LOG -u $ICINGA2_USER -g $ICINGA2_GROUP $DAEMON -c $ICINGA2_CONFIG_FILE -d -e $ICINGA2_ERROR_LOG -u $ICINGA2_USER -g $ICINGA2_GROUP
@ -125,8 +119,13 @@ reload() {
checkconfig() { checkconfig() {
printf "Checking configuration:" printf "Checking configuration:"
echo "Validating the configuration file:" echo "Validating the configuration file:"
exec $DAEMON -c $ICINGA2_CONFIG_FILE -C 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 # Print status for Icinga 2
@ -145,6 +144,7 @@ status() {
### main logic ### ### main logic ###
case "$1" in case "$1" in
start) start)
checkconfig start fail
start start
;; ;;
stop) stop)
@ -154,10 +154,12 @@ case "$1" in
status status
;; ;;
restart|condrestart) restart|condrestart)
checkconfig restart fail
stop nofail stop nofail
start start
;; ;;
reload) reload)
checkconfig reload fail
reload reload
;; ;;
checkconfig) checkconfig)