dnsdist: Improve initscript to prevent reload on config error

start, restart and reload will now be prohibited if the configuration
file has an incorrect syntax. This avoids killing a running daemon and
is showing an indication to the user instead of having the daemon dying
silently in the background.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
Michael Tremer
2021-06-01 11:39:09 +02:00
parent ceb5733c59
commit 839451c527
2 changed files with 23 additions and 1 deletions

View File

@@ -33,7 +33,7 @@ DIR_APP = $(DIR_SRC)/$(THISAPP)
TARGET = $(DIR_INFO)/$(THISAPP)
SUP_ARCH = x86_64
PROG = dnsdist
PAK_VER = 8
PAK_VER = 9
DEPS =

View File

@@ -11,8 +11,22 @@
[ -r "/etc/sysconfig/dnsdist" ] && . /etc/sysconfig/dnsdist
check_config() {
if ! /usr/bin/dnsdist --check-config >/dev/null; then
boot_mesg "dnsdist configuration file contains errors" "${FAILURE}"
echo_failure
return 1
fi
return 0
}
case "${1}" in
start)
if ! check_config; then
exit 1
fi
boot_mesg "Starting dnsdist..."
# Increasing maximum number of open files
@@ -29,11 +43,19 @@ case "${1}" in
;;
reload)
if ! check_config; then
exit 1
fi
boot_mesg "Reloading dnsdist..."
reloadproc /usr/bin/dnsdist
;;
restart)
if ! check_config; then
exit 1
fi
${0} stop
sleep 1
${0} start