#!/usr/local/bin/php<?phprequire_once("config.inc");require_once("interfaces.inc");require_once("util.inc");$subsystem = !empty($argv[1]) ? $argv[1] : '';$type = !empty($argv[2]) ? $argv[2] : '';if ($type != 'MASTER' && $type != 'BACKUP') { log_error("Carp '$type' event unknown from source '{$subsystem}'"); exit(1);}if (!strstr($subsystem, '@')) { log_error("Carp '$type' event triggered from wrong source '{$subsystem}'"); exit(1);}foreach($config['interfaces'] as $ifkey => $interface) { if ($ifkey=='opt3') { if ($type == 'MASTER') { log_msg("Carp Status is now Master!"); log_msg("Enabling interface: $ifkey - {$interface['if']}"); shell_exec("/sbin/ifconfig {$interface['if']} up"); $config['interfaces'][$ifkey]['enable'] = '1'; write_config("enable interface '$ifkey' due CARP event '$type'", false); interface_configure(false, $ifkey, false, false); sleep(1); log_msg("Restarting DHCPD"); shell_exec('pluginctl -s dhcpd restart'); sleep(1); log_msg("Issueing dhclient command to request a DHCP lease"); shell_exec("dhclient {$interface['if']}"); } else if ($type == 'BACKUP') { log_msg("Carp Status is now Backup!"); log_msg("Disabling interface: $ifkey - {$interface['if']}"); shell_exec("/sbin/ifconfig {$interface['if']} down"); unset($config['interfaces'][$ifkey]['enable']); write_config("disable interface '$ifkey' due CARP event '$type'", false); interface_configure(false, $ifkey, false, false); log_msg("Stopping DHCPD"); shell_exec('pluginctl -s dhcpd stop'); } }}?>