diff options
Diffstat (limited to 'etc/rc.carpbackup')
-rwxr-xr-x | etc/rc.carpbackup | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/etc/rc.carpbackup b/etc/rc.carpbackup index 4ecd1c9..19da7a4 100755 --- a/etc/rc.carpbackup +++ b/etc/rc.carpbackup @@ -45,21 +45,26 @@ if (!strstr($argument, "@")) list($vhid, $iface) = explode("@", $argument); $friendly = convert_real_interface_to_friendly_interface_name($iface); +$friendly_descr = convert_friendly_interface_to_friendly_descr($friendly); +$vips = link_interface_to_vips($friendly, '', $vhid); $carp_iface = "{$friendly}_vip{$vhid}"; -$friendly_descr = convert_friendly_interface_to_friendly_descr($carp_iface); -$notificationmsg = sprintf('Carp cluster member "%2$s (%1$s)" has resumed the state "BACKUP" for vhid %s', $argument, $friendly_descr, $vhid); +foreach ($vips as $vip) { + $notificationmsg = sprintf('Carp cluster member "{$friendly_descr)(%2$s): {$vip['subnet']} (%1$s)" has resumed the state "BACKUP" for vhid %s', $argument, $vip['descr'], $vhid); -notify_via_smtp($notificationmsg); -notify_via_growl($notificationmsg); -log_error($notificationmsg); + notify_via_smtp($notificationmsg); + notify_via_growl($notificationmsg); + log_error($notificationmsg); +} /* Stop OpenVPN clients running on this VIP, since multiple active OpenVPN clients on a CARP cluster can be problematic. */ global $config; if (is_array($config['openvpn']) && is_array($config['openvpn']['openvpn-client'])) { foreach ($config['openvpn']['openvpn-client'] as $settings) { - if ($settings['interface'] == $carp_iface) { - log_error("Stopping OpenVPN client instance on {$friendly_descr} because of transition to CARP backup."); - openvpn_restart('client', $settings); + foreach ($vips as $vip) { + if ($settings['interface'] == "_vip{$vip['uniqid']}") { + log_error("Stopping OpenVPN client instance on {$friendly_descr} because of transition to CARP backup."); + openvpn_restart('client', $settings); + } } } } |