keepalived: add option to override service running check
authorFrancesco Benini <francy.benini@gmail.com>
Sat, 19 Oct 2024 22:36:07 +0000 (00:36 +0200)
committerFlorian Eckert <Eckert.Florian@googlemail.com>
Tue, 22 Oct 2024 13:46:27 +0000 (15:46 +0200)
Some init.d scripts like firewall and sqm do not return the actual state
of the service if called with "running" parameter. This result in the
init script called with "start" parameter and the service may not load
the new configuration. Firewall init script is one of this
An option is added in order to skip the "running" check for the service.

Signed-off-by: Francesco Benini <francy.benini@gmail.com>
net/keepalived/Makefile
net/keepalived/files/etc/hotplug.d/keepalived/511-firewall
net/keepalived/files/lib/functions/keepalived/hotplug.sh

index f020e11f8255abb8718f72f29e7f86d49e71bf35..21ec9f73da4f9c330e79a4442f28b7d4850552c1 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=keepalived
 PKG_VERSION:=2.2.8
-PKG_RELEASE:=7
+PKG_RELEASE:=8
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://www.keepalived.org/software
index d8619e9f1872ba9e73f6148ba484a3c6581e2397..b85a703819e885496053dea47c4c99d6bbd955e0 100644 (file)
@@ -5,6 +5,7 @@
 
 set_service_name firewall
 
+set_skip_running_check
 set_reload_if_sync
 
 add_sync_file /etc/config/firewall
index 8691872c6dc4ac1263c5f83109c1eee31e2d9e68..57db374e28fcfb760c0369c460b573a353c98c8d 100644 (file)
@@ -31,17 +31,17 @@ _service() {
        [ ! -x "$rc" ] && return
 
        case $1 in
-               start) $rc running || $rc start ;;
-               stop) $rc running && $rc stop ;;
+               start) _service_running_check "$rc" || $rc start ;;
+               stop) _service_running_check "$rc" && $rc stop ;;
                reload)
-                       if $rc running; then
+                       if _service_running_check "$rc"; then
                                $rc reload
                        else
                                $rc start
                        fi
                        ;;
                restart)
-                       if $rc running; then
+                       if _service_running_check "$rc"; then
                                $rc restart
                        else
                                $rc start
@@ -50,6 +50,10 @@ _service() {
        esac
 }
 
+_service_running_check() {
+       skip_running_check || "$1" running
+}
+
 _start_service() {
        _service start
 }
@@ -158,6 +162,14 @@ backup_and_stop() {
        get_var_flag NOTIFY_BACKUP_STOP 1
 }
 
+set_skip_running_check() {
+       set_var NOTIFY_SKIP_RUNNING 1
+}
+
+skip_running_check() {
+       get_var_flag NOTIFY_SKIP_RUNNING
+}
+
 set_reload_if_sync() {
        set_var NOTIFY_SYNC_RELOAD "${1:-1}"
 }