4 # Copyright (C) 2011 Google Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 USAGE_MSG="Usage: $0 {start|stop}"
24 PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin
28 case $CLUSTER_IP_VERSION in
30 ARP_COMMAND="arping -q -U -c 3 -I $MASTER_NETDEV -s $MASTER_IP $MASTER_IP"
33 ARP_COMMAND="ndisc6 -q r 3 $MASTER_IP $MASTER_NETDEV"
36 echo "Invalid cluster IP version specified: $CLUSTER_IP_VERSION" >&2
41 # Check if the master IP address is already configured on this machine
42 if fping -S 127.0.0.1 $MASTER_IP >/dev/null 2>&1; then
43 echo "Master IP address already configured on this machine. Doing nothing."
47 # Check if the master IP address is already configured on another machine
48 if fping $MASTER_IP >/dev/null 2>&1; then
49 echo "Error: master IP address configured on another machine." >&2
53 if ! ip addr add $MASTER_IP/$MASTER_NETMASK \
54 dev $MASTER_NETDEV label $MASTER_NETDEV:0; then
55 echo "Error during the activation of the master IP address" >&2
59 # Send gratuituous ARP to update neighbours' ARP cache
65 # Check if the master IP address is still configured on this machine
66 if ! ip addr show dev $MASTER_NETDEV | \
67 grep -F " $MASTER_IP/$MASTER_NETMASK" >/dev/null 2>&1; then
68 # Check if the master IP address is configured on a wrong device
69 if fping -S 127.0.0.1 $MASTER_IP >/dev/null 2>&1; then
70 echo "Error: master IP address configured on wrong device," \
71 "can't shut it down." >&2
74 echo "Master IP address not configured on this machine. Doing nothing."
79 if ! ip addr del $MASTER_IP/$MASTER_NETMASK dev $MASTER_NETDEV; then
80 echo "Error during the deactivation of the master IP address" >&2