From 839451c527ddb4563a3ea2361e012e405a5b11a2 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Tue, 1 Jun 2021 11:39:09 +0200 Subject: [PATCH] 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 --- lfs/dnsdist | 2 +- src/initscripts/packages/dnsdist | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lfs/dnsdist b/lfs/dnsdist index 3c30b42134..b93a4fc36b 100644 --- a/lfs/dnsdist +++ b/lfs/dnsdist @@ -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 = diff --git a/src/initscripts/packages/dnsdist b/src/initscripts/packages/dnsdist index c94f429ab9..35cc3c653c 100644 --- a/src/initscripts/packages/dnsdist +++ b/src/initscripts/packages/dnsdist @@ -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 -- 2.39.5