Last active
August 29, 2015 14:05
-
-
Save kanazux/d3c04c1a96ca5f172c4d to your computer and use it in GitHub Desktop.
path shutdown carp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ ! -f /usr/local/bin/shutdown_interface_vip.php ]; then | |
cat <<EOF >/usr/local/bin/shutdown_interface_vip.php | |
<?php | |
require_once('interfaces.inc'); | |
require_once('config.inc'); | |
\$ifaces = \$config['virtualip']['vip']; | |
if(is_array(\$ifaces)){ | |
foreach(\$ifaces as \$iface){ | |
if(\$iface['mode'] == 'carp') | |
exec("/sbin/ifconfig vip{\$iface['vhid']} down"); | |
} | |
} | |
?> | |
EOF | |
chmod +x /usr/local/bin/shutdown_interface_vip.php | |
fi | |
if [ -f /etc/rc.halt ]; then | |
sed -i.bak 's/\/sbin\/shutdown -p now//g' /etc/rc.halt | |
cat <<EOF >>/etc/rc.halt | |
if [ `/sbin/ifconfig | egrep '^vip[0-9]' | egrep -ic 'carp.*master` -gt 0 ] && [ -f /usr/local/bin/shutdown_interface_vip.php ]; then | |
/usr/local/bin/php -f shutdown_interface_vip.php | |
fi | |
/sbin/shutdown -p now | |
EOF | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# $Id$ | |
if ! /usr/bin/lockf -s -t 30 /tmp/config.lock /usr/bin/true; then | |
echo "Cannot halt at this moment, a config write operation is in progress and 30 seconds have passed." | |
exit -1 | |
fi | |
sleep 1 | |
if [ `/sbin/ifconfig | egrep '^vip[0-9]' | egrep -ic 'carp.*master` -gt 0 ] && [ -f /usr/local/bin/shutdown_interface_vip.php ]; then | |
/usr/local/bin/php -f shutdown_interface_vip.php | |
fi | |
/sbin/shutdown -p now |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once('interfaces.inc'); | |
require_once('config.inc'); | |
$ifaces = $config['virtualip']['vip']; | |
if(is_array($ifaces)){ | |
foreach($ifaces as $iface){ | |
if($iface['mode'] == 'carp') | |
exec("/sbin/ifconfig vip{$iface['vhid']} down"); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment