3 # This script can be called from a cronjob to automatically drop/release
4 # all public ip addresses if CTDBD has crashed or stopped running.
7 [ -z "$CTDB_BASE" ] && {
11 [ -z "$CTDB_PUBLIC_ADDRESSES" ] && {
12 CTDB_PUBLIC_ADDRESSES
=$CTDB_BASE/public_addresses
15 [ ! -f "$CTDB_PUBLIC_ADDRESSES" ] && {
16 echo "No public addresses file found. Cant cleanup."
20 # if ctdb is running, just return
21 ctdb status
2>/dev
/null
&& {
25 (cat /etc
/{sysconfig
,default
}/ctdb |
egrep "^CTDB_NATGW_PUBLIC_IP" |
sed -e "s/.*=//" -e "s/\/.*//";cat "$CTDB_PUBLIC_ADDRESSES" | cut
-d/ -f1) |
while read _IP
; do
26 _IP_HELD
=`/sbin/ip addr show | grep "inet $_IP/"`
27 [ -z "$_IP_HELD" ] ||
{
28 _IFACE
=`echo $_IP_HELD | sed -e "s/.*\s//"`
29 _NM
=`echo $_IP_HELD | sed -e "s/.*$_IP\///" -e "s/\s.*//"`
30 logger
"Removing public address $_IP/$_NM from device $_IFACE"
31 /sbin
/ip addr del
$_IP/$_NM dev
$_IFACE