blob: 22b0742971859d46a8f80b01d25bf0a47ba7a30d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
#!/bin/sh
# sample event script for ctdb
. /etc/sysconfig/ctdb
cmd="$1"
shift
case $cmd in
startup)
# wait for local services to come up
[ -z "$CTDB_WAIT_TCP_PORTS" ] || {
all_ok=0
echo "Waiting for tcp services on $CTDB_WAIT_TCP_PORTS to come up"
while [ $all_ok -eq 0 ]; do
all_ok=1
for p in $CTDB_WAIT_TCP_PORTS; do
/usr/bin/nc -z 127.0.0.1 $p || all_ok=0
done
[ $all_ok -eq 1 ] || sleep 1
done
echo "Local tcp services on $CTDB_WAIT_TCP_PORTS are up"
}
exit 0;
;;
takeip)
if [ $# != 3 ]; then
echo "must supply interface, IP and maskbits"
exit 1
fi
iface=$1
ip=$2
maskbits=$3
/sbin/ip addr add $ip/$maskbits dev $iface || {
echo "Failed to add $ip/$maskbits on dev $iface"
exit 1
}
# if we have a local arp entry for this IP then remove it
/sbin/arp -d $ip 2> /dev/null
exit 0
;;
releaseip)
if [ $# != 3 ]; then
echo "must supply interface, IP and maskbits"
exit 1
fi
iface=$1
ip=$2
maskbits=$3
/sbin/ip addr del $ip dev $iface || {
echo "Failed to del $ip on dev $iface"
exit 1
}
# if we have a local arp entry for this IP then remove it
/sbin/arp -d $ip 2> /dev/null
echo $ip >> /etc/ctdb/released_ips
exit 0
;;
recovered)
# restart any services as necessary, like NFS
#
[ -f /etc/ctdb/released_ips ] && {
( /sbin/service nfs status > /dev/null 2>&1 &&
/sbin/service nfs restart > /dev/null 2>&1 ) &
} > /dev/null 2>&1
/bin/rm -f /etc/ctdb/released_ips
exit 0
;;
shutdown)
# shutdown any services as necessary
exit 0
;;
esac
echo "Invalid command $cmd"
exit 1
|