4
# Copyright (C) 2005 Horms <horms@verge.net.au>
6
# License: GNU General Public License (GPL)
7
# Support: linux-ha@lists.linux-ha.org
9
# This script manages the LVS synchronisation daemon
11
# Please note that as of 2.4.29, this is no longer needed
12
# as both the master and backup daemon can run simultaneously
14
# usage: $0 {master|backup} {interface} {start|stop|status|monitor|cleanup}
16
# The first argument, master or backup, is the YING.
17
# The YANG is internally calculated to be which ever or master and
20
# e.g $0 LVSSyncDaemonSwap master start # YING=master YANG=backup
21
# $0 LVSSyncDaemonSwap backup start # YING=backup YANG=master
24
# "start" will stop the YANG if it is running and starts the YING
25
# "stop" will stop the YING if it is running and starts the YANG
26
# "cleanup" is a non-standard target stop the YING if it is running
27
# an stop the YANG if it is running
36
exec_prefix=@exec_prefix@
37
. @sysconfdir@/ha.d/shellfuncs
39
USAGE="usage: $0 {master|backup} {interface} {start|stop|status|monitor|cleanup}\n\nNote: $0 only works on Linux";
41
# This is consistent with ldirectord's behaviour
42
# Except that this script does not have a debug mode
43
if [ -x "/sbin/ipvsadm" ]; then
44
IPVSADM="/sbin/ipvsadm";
45
elif [ -x "/usr/sbin/ipvsadm" ]; then
46
IPVSADM="/usr/sbin/ipvsadm";
48
ha_log "ERROR: Can not find ipvsadm";
52
IPVSADM_VERSION=$($IPVSADM --version | cut -d " " -f 2)
55
if echo $PS | grep " \[ipvs[ _]sync$1\]$" > /dev/null; then
69
pid=$(echo "$PS" | sed -e '/ \[ipvs[ _]syncmaster\]$/!d' -e 's/^ *//' -e 's/ .*$//')
70
if [ ! -z "$pid" ]; then
71
echo "(ipvs_syncmaster pid: $pid)"
74
pid=$(echo "$PS" | sed -e '/ \[ipvs[ _]syncbackup\]$/!d' -e 's/^ *//' -e 's/ .*$//')
75
if [ ! -z "$pid" ]; then
76
echo "(ipvs_syncbackup pid: $pid)"
85
if [ $rc -ne 0 ]; then
86
echo "ERROR: ipvsadm $@ failed."
94
if [ "$1" = "master" ]; then
105
if [ $(get_status $YING) = "running" ]; then
109
if [ $(get_status $YANG) = "running" ]; then
110
if [ "$IPVSADM_VERSION" = "v1.21" ]; then
111
run_ipvsadm --stop-daemon || return $?
113
run_ipvsadm --stop-daemon $YANG || return $?
115
ha_log "info: ipvs_sync$YANG down"
118
run_ipvsadm --start-daemon $YING --mcast-interface=$IFACE || return $?
120
ha_log "info: ipvs_sync$YING up"
125
start_stop $1 $(ying_yan $1) || return $?
126
ha_log "info: ipvs_sync$YING obtained"
131
start_stop $(ying_yan $1) $1 || return $?
132
ha_log "info: ipvs_sync$YANG released"
137
if [ $(get_status master) = "running" ]; then
139
elif [ $(get_status backup) = "running" ]; then
146
run_ipvsadm --stop-daemon || return $?
147
if [ "$IPVSADM_VERSION" = "v1.21" ]; then
148
run_ipvsadm --stop-daemon || return $?
150
run_ipvsadm --stop-daemon $YANG || return $?
152
ha_log "info: ipvs_sync$YING down"
161
[ $# -lt 2 -o $# -gt 3 ]
167
PS=$(ps ax | grep " \[ipvs[ _]sync")