keepalived: only add content to config file if needed

Only add the first two pieces of information to the configuration file if
there is a valid '/etc/config/keepalived'.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
This commit is contained in:
Florian Eckert
2024-12-16 15:35:12 +01:00
committed by Florian Eckert
parent 9db0eab9c5
commit 1d79439834

View File

@@ -600,11 +600,6 @@ process_config() {
local alt_config_file linkbeat_use_polling
rm -f "$KEEPALIVED_CONF"
# First line
printf '! Configuration file for keepalived (autogenerated via init script)\n' > "$KEEPALIVED_CONF"
printf '! Written %s\n\n' "$(date +'%c')" >> "$KEEPALIVED_CONF"
[ -f /etc/config/keepalived ] || return 0
config_load 'keepalived'
config_get alt_config_file globals alt_config_file
@@ -617,6 +612,10 @@ process_config() {
return 0
}
# First line
printf '! Configuration file for keepalived (autogenerated via init script)\n' > "$KEEPALIVED_CONF"
printf '! Written %s\n\n' "$(date +'%c')" >> "$KEEPALIVED_CONF"
config_get_bool linkbeat_use_polling globals linkbeat_use_polling 0
[ "$linkbeat_use_polling" -gt 0 ] && printf 'linkbeat_use_polling\n\n' >> "$KEEPALIVED_CONF"