keepalived: add enabled option

To prevent the keepalived service from starting if there is no valid
configuration yet, the new option enabled is added. This must be set to
true for keepalived to start.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
This commit is contained in:
Florian Eckert
2024-12-16 15:54:23 +01:00
committed by Florian Eckert
parent 1d79439834
commit 71dbf1cc0d
2 changed files with 11 additions and 5 deletions

View File

@@ -1,4 +1,5 @@
config globals 'globals'
option enabled '0'
# option alt_config_file "/etc/keepalived/keepalived.conf"
# list notification_email "acassen@firewall.loc"
# list notification_email "failover@firewall.loc"

View File

@@ -600,7 +600,6 @@ process_config() {
local alt_config_file linkbeat_use_polling
rm -f "$KEEPALIVED_CONF"
[ -f /etc/config/keepalived ] || return 0
config_load 'keepalived'
config_get alt_config_file globals alt_config_file
@@ -654,14 +653,20 @@ reload_service() {
}
start_service() {
local enabled
[ -f /etc/config/keepalived ] || return 0
config_load 'keepalived'
config_get_bool enabled globals enabled 1
[ "$enabled" = "0" ] && return 0
process_config
procd_open_instance
procd_set_param command /usr/sbin/keepalived
procd_append_param command -n # don't daemonize, procd will handle that for us
procd_append_param command -f "$KEEPALIVED_CONF"
process_config
# set auto respawn behavior
procd_set_param respawn
procd_close_instance
}