Skip to content
This repository was archived by the owner on Jan 16, 2024. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 45 additions & 1 deletion src/etc/one-context.d/loc-15-keepalived##apk
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ get_vrouter_password() {
echo $password
}

get_check_script() {
script="$VROUTER_KEEPALIVED_CHECK_SCRIPT"

echo $script
}

get_iface_var() {
var_name="$1_$2"
var=$(eval "echo \"\${$var_name}\"")
Expand Down Expand Up @@ -81,6 +87,22 @@ EOT
EOT
}

gen_check_script() {
script="$(get_check_script)"

if [ -n "$script" ]; then
cat <<EOT
vrrp_script chk_script {
script "$script"
interval 2
fall 2
rise 2
}

EOT
fi
}

gen_auth() {
password=$(get_vrouter_password)

Expand All @@ -94,6 +116,26 @@ EOT
fi
}

gen_track() {
script="$(get_check_script)"

if [ -n "$script" ]; then
cat <<EOT
track_script {
chk_script
}
EOT
fi
}

gen_preempt() {
script="$(get_check_script)"

if [ -z "$script" ]; then
echo nopreempt
fi
}

gen_instances() {
for interface in $(get_context_interfaces); do
vrouter_ip=$(get_iface_var $interface VROUTER_IP)
Expand All @@ -111,7 +153,8 @@ vrrp_instance $interface {
$vrouter_ip
}
$(gen_auth)
nopreempt
$(gen_track)
$(gen_preempt)
}

EOT
Expand All @@ -133,6 +176,7 @@ fi
(

gen_group
gen_check_script
gen_instances

) > /etc/keepalived/keepalived.conf
Expand Down