net/keepalived: add notify hotplug-call script handling
authorFlorian Eckert <redacted>
Mon, 6 Nov 2017 14:47:00 +0000 (15:47 +0100)
committerFlorian Eckert <redacted>
Wed, 8 Nov 2017 10:36:58 +0000 (11:36 +0100)
During keepalived config generation for the vrrp_instance and vrrp_sync_group
the notify_* sections are automatic added to the runtime keepalived.conf.
This could be used for service which want to react on keepalived notifications.

Signed-off-by: Florian Eckert <redacted>
net/keepalived/files/keepalived.init

index 41e311d545311356f556acc87df21b60d1367d64..778777b671a166546c74425091cb0eb6820f7633 100644 (file)
@@ -79,6 +79,18 @@ print_list_indent() {
        printf "$indent}\n" >> $KEEPALIVED_CONF
 }
 
+print_notify() {
+       local type=$1
+       shift
+       local name=$1
+       shift
+       for notify in $*; do
+               printf "$INDENT_1$notify" >> $KEEPALIVED_CONF
+               notify=$(echo $notify | tr 'a-z' 'A-Z')
+               printf " \"/bin/busybox env -i ACTION=$notify TYPE=$type NAME=$name /sbin/hotplug-call keepalived\"\n" >> $KEEPALIVED_CONF
+       done
+}
+
 global_defs() {
        local linkbeat_use_polling notification_email
 
@@ -242,8 +254,11 @@ vrrp_sync_group() {
        group="$valid_group"
        print_list_indent group
 
-       print_elems_indent $1 $INDENT_1 notify_backup notify_master notify_fault \
-               notify no_val_smtp_alert no_val_global_tracking
+       print_elems_indent $1 $INDENT_1 no_val_smtp_alert no_val_global_tracking
+
+       print_notify "GROUP" "$name" notify_backup notify_master \
+               notify_fault notify
+
        config_section_close
 }
 
@@ -266,13 +281,15 @@ vrrp_instance() {
 
        print_elems_indent $1 $INDENT_1 use_vmac state interface \
                mcast_src_ip unicast_src_ip virtual_router_id version priority \
-               advert_int preempt_delay debug notify_backup \
-               notify_master notify_fault notify_stop notify \
+               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
 
+       print_notify "INSTANCE" "$name" notify_backup notify_master \
+               notify_fault notify_stop notify
+
        # Handle virtual_ipaddress & virtual_ipaddress_excluded lists
        for opt in virtual_ipaddress virtual_ipaddress_excluded; do
                config_get $opt $1 $opt
git clone https://git.99rst.org/PROJECT