|
|
@ -123,13 +123,17 @@ print_ipaddress_indent() { |
|
|
|
# Default indent |
|
|
|
[ -z "$indent" ] && indent=$INDENT_1 |
|
|
|
|
|
|
|
# If no address or device exit |
|
|
|
[ -z "$address" -o -z "$device" ] && return 0 |
|
|
|
# If no address exit |
|
|
|
[ -z "$address" ] && return 0 |
|
|
|
|
|
|
|
# Add IP address/netmask and device |
|
|
|
printf "$indent$address dev $device" >> $KEEPALIVED_CONF |
|
|
|
# Add scope |
|
|
|
[ -n "$scope" ] && printf " scope $scope" >> $KEEPALIVED_CONF |
|
|
|
if [ -z "$device" ]; then |
|
|
|
printf "$indent$address" >> $KEEPALIVED_CONF |
|
|
|
else |
|
|
|
# Add IP address/netmask and device |
|
|
|
printf "$indent$address dev $device" >> $KEEPALIVED_CONF |
|
|
|
# Add scope |
|
|
|
[ -n "$scope" ] && printf " scope $scope" >> $KEEPALIVED_CONF |
|
|
|
fi |
|
|
|
|
|
|
|
printf "\n" >> $KEEPALIVED_CONF |
|
|
|
} |
|
|
@ -279,16 +283,17 @@ vrrp_instance() { |
|
|
|
printf "$INDENT_1}\n" >> $KEEPALIVED_CONF |
|
|
|
} |
|
|
|
|
|
|
|
print_elems_indent $1 $INDENT_1 use_vmac state interface \ |
|
|
|
print_elems_indent $1 $INDENT_1 state interface \ |
|
|
|
mcast_src_ip unicast_src_ip virtual_router_id version priority \ |
|
|
|
advert_int preempt_delay debug \ |
|
|
|
lvs_sync_daemon_interface garp_master_delay garp_master_refresh \ |
|
|
|
garp_master_repeat garp_master_refresh_repeat \ |
|
|
|
no_val_vmac_xmit_base no_val_native_ipv6 no_val_accept \ |
|
|
|
no_val_dont_track_primary no_val_smtp_alert no_val_nopreempt |
|
|
|
no_val_dont_track_primary no_val_smtp_alert no_val_nopreempt \ |
|
|
|
no_val_use_vmac |
|
|
|
|
|
|
|
print_notify "INSTANCE" "$name" notify_backup notify_master \ |
|
|
|
notify_fault notify_stop notify |
|
|
|
notify_fault notify_stop |
|
|
|
|
|
|
|
# Handle virtual_ipaddress & virtual_ipaddress_excluded lists |
|
|
|
for opt in virtual_ipaddress virtual_ipaddress_excluded; do |
|
|
@ -367,7 +372,8 @@ process_config() { |
|
|
|
rm -f $KEEPALIVED_CONF |
|
|
|
|
|
|
|
# First line |
|
|
|
printf "! Configuration File for keepalived (autogenerated via init script)\n\n" > $KEEPALIVED_CONF |
|
|
|
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' |
|
|
@ -398,31 +404,14 @@ process_config() { |
|
|
|
return 0 |
|
|
|
} |
|
|
|
|
|
|
|
service_running() { |
|
|
|
pgrep -x /usr/sbin/keepalived &> /dev/null |
|
|
|
} |
|
|
|
|
|
|
|
conf_md5() { |
|
|
|
echo "$(md5sum $KEEPALIVED_CONF | awk '{print $1}')" |
|
|
|
service_triggers() { |
|
|
|
procd_add_reload_trigger "keepalived" |
|
|
|
} |
|
|
|
|
|
|
|
reload_service() { |
|
|
|
local cur_md5="$(conf_md5)" |
|
|
|
running && { |
|
|
|
process_config |
|
|
|
|
|
|
|
# Return without performing the reload if config |
|
|
|
# file md5sum has not changed |
|
|
|
local new_md5="$(conf_md5)" |
|
|
|
[ "$new_md5" == "$cur_md5" ] && return 0; |
|
|
|
|
|
|
|
# SIGHUP is used by keepalived to do init.d reload |
|
|
|
# Get the oldest process (assumption is that it's the parent process) |
|
|
|
PID=$(pgrep -o /usr/sbin/keepalived) |
|
|
|
kill -SIGHUP $PID |
|
|
|
return 0 |
|
|
|
} |
|
|
|
return 1 |
|
|
|
process_config |
|
|
|
#SIGHUP is used by keepalived to do init.d reload |
|
|
|
procd_send_signal keepalived |
|
|
|
} |
|
|
|
|
|
|
|
start_service() { |
|
|
|