2010-03-06 17:03:32 +00:00
|
|
|
#!/bin/sh /etc/rc.common
|
2010-02-20 10:20:56 +00:00
|
|
|
|
2010-03-06 17:03:32 +00:00
|
|
|
START=50
|
|
|
|
CONF=/etc/ucarp.conf
|
2010-02-20 10:20:56 +00:00
|
|
|
|
2010-03-06 17:03:32 +00:00
|
|
|
start() {
|
|
|
|
. ${CONF}
|
2010-02-20 10:20:56 +00:00
|
|
|
|
2010-03-06 17:03:32 +00:00
|
|
|
[ ${BACKGROUND} = 1 ] && daemon="--daemonize"
|
2010-02-20 10:20:56 +00:00
|
|
|
|
2010-03-06 17:03:32 +00:00
|
|
|
cat > /var/run/ucarp-vip-up <<EOF
|
2010-02-20 10:20:56 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
/bin/ip addr add ${VIP}/${VMASK} dev ${IF}
|
|
|
|
|
|
|
|
EOF
|
2010-03-06 17:03:32 +00:00
|
|
|
for ip in ${PINGIP}
|
|
|
|
do
|
2010-02-20 10:20:56 +00:00
|
|
|
cat >> /var/run/ucarp-vip-up <<EOF
|
2010-03-06 17:03:32 +00:00
|
|
|
/usr/bin/arping -c 2 -I ${IF} -s ${VIP} ${ip}
|
2010-02-20 10:20:56 +00:00
|
|
|
EOF
|
2010-03-06 17:03:32 +00:00
|
|
|
done
|
|
|
|
chmod a+x /var/run/ucarp-vip-up
|
2010-02-20 10:20:56 +00:00
|
|
|
|
2010-03-06 17:03:32 +00:00
|
|
|
cat > /var/run/ucarp-vip-down <<EOF
|
2010-02-20 10:20:56 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
/bin/ip addr del ${VIP}/${VMASK} dev ${IF}
|
|
|
|
|
|
|
|
EOF
|
2010-03-06 17:03:32 +00:00
|
|
|
chmod a+x /var/run/ucarp-vip-down
|
2010-02-20 10:20:56 +00:00
|
|
|
|
2010-03-06 17:03:32 +00:00
|
|
|
/usr/sbin/ucarp --interface=${IF} --srcip=${MYIP} --vhid=1 --pass=${PASSWORD} \
|
|
|
|
--addr=${VIP} --nomcast $daemon \
|
|
|
|
--upscript=/var/run/ucarp-vip-up --downscript=/var/run/ucarp-vip-down
|
|
|
|
}
|
2010-02-20 10:20:56 +00:00
|
|
|
|
2010-03-06 17:03:32 +00:00
|
|
|
stop() {
|
|
|
|
killall ucarp
|
|
|
|
}
|