From 7de4474e1940ca751b4ff7031464c01b1489d71f Mon Sep 17 00:00:00 2001 From: Luiz Otavio O Souza Date: Wed, 24 Feb 2016 10:45:17 -0600 Subject: Fix the rc.carpmaster and rc.carpbackup scripts. Now, they look for main CARP IP and IP aliases running on supplied vhid. --- src/etc/rc.carpbackup | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) (limited to 'src/etc/rc.carpbackup') diff --git a/src/etc/rc.carpbackup b/src/etc/rc.carpbackup index e71f9fa..a65aff4 100755 --- a/src/etc/rc.carpbackup +++ b/src/etc/rc.carpbackup @@ -34,13 +34,14 @@ require_once("notices.inc"); require_once("openvpn.inc"); require_once("interfaces.inc"); -if (isset($_GET)) { +if (isset($_GET['interface'])) { $argument = $_GET['interface']; } else { $argument = str_replace("\n", "", $argv[1]); } if (!strstr($argument, "@")) { log_error("CARP master event triggered from wrong source {$argument}"); + exit; } list($vhid, $iface) = explode("@", $argument); @@ -48,16 +49,17 @@ 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}"; - -if (is_array($vips)) { - foreach ($vips as $vip) { - $notificationmsg = sprintf('HA cluster member "(%1$s): (%2$s)" has resumed CARP state "BACKUP" for vhid %3$s', $argument, $friendly_descr, $vhid); +if (!is_array($vips)) { + log_error("CARP master event triggered from wrong source {$argument} - no associated VIPs"); + exit; +} +foreach ($vips as $vip) { + $notificationmsg = sprintf('HA cluster member "(%1$s@%2$s): (%3$s)" has resumed CARP state "BACKUP" for vhid %4$s', + $vip['subnet'], $iface, $friendly_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. */ @@ -85,20 +87,14 @@ if (is_array($config['openvpn']) && is_array($config['openvpn']['openvpn-client' } } -/* Reconfigure radvd when necessary */ -if (isset($config['dhcpdv6']) && is_array($config['dhcpdv6'])) { - $found = false; - foreach ($config['dhcpdv6'] as $dhcpv6if => $dhcpv6ifconf) { - if ($dhcpv6ifconf['rainterface'] != $carp_iface) { - continue; +if (is_array($config['openvpn']) && is_array($config['openvpn']['openvpn-server'])) { + foreach ($config['openvpn']['openvpn-server'] as $settings) { + foreach ($vips as $vip) { + if ($settings['interface'] == "_vip{$vip['uniqid']}") { + log_error("Stopping OpenVPN instance on {$friendly_descr} because of transition to CARP backup."); + openvpn_restart('server', $settings); + } } - - $found = true; - break; - } - - if ($found === true) { - services_radvd_configure(); } } -- cgit v1.1