Debian: Added checkconfig helper to initscript.

And simplified check handling over all functions.

Refs #5305
This commit is contained in:
Markus Frosch 2013-12-11 15:19:50 +01:00
parent 4c8f1f3d9d
commit 16e1da530f

View File

@ -51,13 +51,9 @@ check_run () {
} }
check_config () { check_config () {
if ! $DAEMON --validate -u "$DAEMON_USER" -g "$DAEMON_GROUP" -c "$DAEMON_CONFIG" >/dev/null 2>&1; then $DAEMON --validate -u "$DAEMON_USER" -g "$DAEMON_GROUP" -c "$DAEMON_CONFIG"
# blark output
$DAEMON --validate -u "$DAEMON_USER" -g "$DAEMON_GROUP" -c "$DAEMON_CONFIG"
fi
} }
# #
# Function that starts the daemon/service # Function that starts the daemon/service
# #
@ -116,17 +112,25 @@ do_reload() {
return 0 return 0
} }
do_check_config () {
DOEXITONOK="$1"
log_begin_msg "checking Icinga2 configuration"
if ! check_config >/dev/null 2>&1; then
echo
check_config
log_failure_msg "checking Icinga2 configuration"
exit 1
else
log_end_msg 0
[ -n "$DOEXITONOK" ] && exit 0
fi
}
check_run check_run
case "$1" in case "$1" in
start) start)
log_action_msg "checking Icinga2 configuration" do_check_config
if ! check_config; then
log_failure_msg "config test failed!"
log_end_msg 1
exit 1
fi
log_daemon_msg "Starting $DESC" "$NAME" log_daemon_msg "Starting $DESC" "$NAME"
do_start do_start
case "$?" in case "$?" in
@ -146,25 +150,13 @@ case "$1" in
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
;; ;;
reload|force-reload) reload|force-reload)
log_action_msg "checking Icinga2 configuration" do_check_config
if ! check_config; then
log_failure_msg "config test failed!"
log_end_msg 1
exit 1
fi
log_daemon_msg "Reloading $DESC" "$NAME" log_daemon_msg "Reloading $DESC" "$NAME"
do_reload do_reload
log_end_msg $? log_end_msg $?
;; ;;
restart) restart)
log_action_msg "checking Icinga2 configuration" do_check_config
if ! check_config; then
log_failure_msg "config test failed!"
log_end_msg 1
exit 1
fi
log_daemon_msg "Restarting $DESC" "$NAME" log_daemon_msg "Restarting $DESC" "$NAME"
do_stop do_stop
case "$?" in case "$?" in
@ -182,8 +174,11 @@ case "$1" in
;; ;;
esac esac
;; ;;
checkconfig)
do_check_config 1
;;
*) *)
echo "Usage: $SCRIPTNAME {start|stop|status|reload|force-reload|restart}" >&2 echo "Usage: $SCRIPTNAME {start|stop|status|reload|force-reload|restart|checkconfig}" >&2
exit 3 exit 3
;; ;;
esac esac