From ea092363d93ea74799a610d2ac2e6710ae0dd3e2 Mon Sep 17 00:00:00 2001 From: Francesco Benini Date: Sun, 20 Oct 2024 00:36:07 +0200 Subject: [PATCH] keepalived: add option to override service running check 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 --- net/keepalived/Makefile | 2 +- .../etc/hotplug.d/keepalived/511-firewall | 1 + .../files/lib/functions/keepalived/hotplug.sh | 20 +++++++++++++++---- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/net/keepalived/Makefile b/net/keepalived/Makefile index f020e11f82..21ec9f73da 100644 --- a/net/keepalived/Makefile +++ b/net/keepalived/Makefile @@ -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 diff --git a/net/keepalived/files/etc/hotplug.d/keepalived/511-firewall b/net/keepalived/files/etc/hotplug.d/keepalived/511-firewall index d8619e9f18..b85a703819 100644 --- a/net/keepalived/files/etc/hotplug.d/keepalived/511-firewall +++ b/net/keepalived/files/etc/hotplug.d/keepalived/511-firewall @@ -5,6 +5,7 @@ set_service_name firewall +set_skip_running_check set_reload_if_sync add_sync_file /etc/config/firewall diff --git a/net/keepalived/files/lib/functions/keepalived/hotplug.sh b/net/keepalived/files/lib/functions/keepalived/hotplug.sh index 8691872c6d..57db374e28 100644 --- a/net/keepalived/files/lib/functions/keepalived/hotplug.sh +++ b/net/keepalived/files/lib/functions/keepalived/hotplug.sh @@ -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}" }