mirror of
https://github.com/Icinga/icinga2.git
synced 2025-04-08 17:05:25 +02:00
Debian: Added checkconfig helper to initscript.
And simplified check handling over all functions. Refs #5305
This commit is contained in:
parent
4c8f1f3d9d
commit
16e1da530f
49
debian/icinga2-common.icinga2.init
vendored
49
debian/icinga2-common.icinga2.init
vendored
@ -51,13 +51,9 @@ check_run () {
|
||||
}
|
||||
|
||||
check_config () {
|
||||
if ! $DAEMON --validate -u "$DAEMON_USER" -g "$DAEMON_GROUP" -c "$DAEMON_CONFIG" >/dev/null 2>&1; then
|
||||
# blark output
|
||||
$DAEMON --validate -u "$DAEMON_USER" -g "$DAEMON_GROUP" -c "$DAEMON_CONFIG"
|
||||
fi
|
||||
$DAEMON --validate -u "$DAEMON_USER" -g "$DAEMON_GROUP" -c "$DAEMON_CONFIG"
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Function that starts the daemon/service
|
||||
#
|
||||
@ -116,17 +112,25 @@ do_reload() {
|
||||
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
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
log_action_msg "checking Icinga2 configuration"
|
||||
if ! check_config; then
|
||||
log_failure_msg "config test failed!"
|
||||
log_end_msg 1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
do_check_config
|
||||
log_daemon_msg "Starting $DESC" "$NAME"
|
||||
do_start
|
||||
case "$?" in
|
||||
@ -146,25 +150,13 @@ case "$1" in
|
||||
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
|
||||
;;
|
||||
reload|force-reload)
|
||||
log_action_msg "checking Icinga2 configuration"
|
||||
if ! check_config; then
|
||||
log_failure_msg "config test failed!"
|
||||
log_end_msg 1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
do_check_config
|
||||
log_daemon_msg "Reloading $DESC" "$NAME"
|
||||
do_reload
|
||||
log_end_msg $?
|
||||
;;
|
||||
restart)
|
||||
log_action_msg "checking Icinga2 configuration"
|
||||
if ! check_config; then
|
||||
log_failure_msg "config test failed!"
|
||||
log_end_msg 1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
do_check_config
|
||||
log_daemon_msg "Restarting $DESC" "$NAME"
|
||||
do_stop
|
||||
case "$?" in
|
||||
@ -182,8 +174,11 @@ case "$1" in
|
||||
;;
|
||||
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
|
||||
;;
|
||||
esac
|
||||
|
Loading…
x
Reference in New Issue
Block a user