]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/commitdiff
dnsdist: Improve initscript to prevent reload on config error
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 1 Jun 2021 09:39:09 +0000 (11:39 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 1 Jun 2021 09:39:09 +0000 (11:39 +0200)
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>
lfs/dnsdist
src/initscripts/packages/dnsdist

index 3c30b4213492c107e2fd136efe1610878c3bb2c6..b93a4fc36b0713dca285ebb86b7e72dce7a69dc7 100644 (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       =
 
index c94f429ab9d0c4d8e3072eeb6cccb161e710912e..35cc3c653c0b220918158316c8e9a7df2d15e76d 100644 (file)
 
 [ -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