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-05-17 20:05:32 +00:00
|
|
|
IP=$(which ip)
|
|
|
|
UCARP=$(which ucarp)
|
|
|
|
ARPING=$(which arping)
|
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
|
|
|
|
|
2010-05-17 20:05:32 +00:00
|
|
|
$IP addr add ${VIP}/${VMASK} dev ${IF}
|
2010-02-20 10:20:56 +00:00
|
|
|
|
|
|
|
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-05-17 20:05:32 +00:00
|
|
|
$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
|
|
|
|
|
2010-05-17 20:05:32 +00:00
|
|
|
$IP addr del ${VIP}/${VMASK} dev ${IF}
|
2010-02-20 10:20:56 +00:00
|
|
|
|
|
|
|
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-05-17 20:05:32 +00:00
|
|
|
$UCARP --interface=${IF} --srcip=${MYIP} --vhid=1 --pass=${PASSWORD} \
|
2010-03-06 17:03:32 +00:00
|
|
|
--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
|
|
|
|
}
|