Add file lock for keepalived scripts

They are not blocked callings.
This commit is contained in:
Sheng Yang 2011-06-01 11:55:22 -07:00
parent 2973ab5ef5
commit 819e67b189
3 changed files with 49 additions and 0 deletions

View File

@ -283,6 +283,7 @@ setup_apache2() {
}
setup_redundant_router() {
rm /tmp/rrouter.lock
ip route delete default
cp /root/redundant_router/keepalived.conf.templ /etc/keepalived/keepalived.conf
cp /root/redundant_router/conntrackd.conf.templ /etc/conntrackd/conntrackd.conf

View File

@ -1,8 +1,32 @@
#!/bin/bash
LOCK=/tmp/rrouter.lock
locked=0
# Wait the lock
for i in `seq 1 5`
do
if [ ! -e $LOCK ]
then
touch $LOCK
locked=1
break
fi
sleep 1
echo sleep 1
done
if [ $locked -eq 0 ]
then
echo Status: fail to get the lock! >> /root/keepalived.log
exit
fi
echo To backup called >> /root/keepalived.log
/root/redundant_router/disable_pubip.sh
echo Disable public ip $? >> /root/keepalived.log
/root/redundant_router/primary-backup.sh backup
echo Switch conntrackd mode backup $? >> /root/keepalived.log
echo Status: BACKUP >> /root/keepalived.log
rm $LOCK

View File

@ -1,8 +1,32 @@
#!/bin/bash
LOCK=/tmp/rrouter.lock
locked=0
# Wait the lock
for i in `seq 1 5`
do
if [ ! -e $LOCK ]
then
touch $LOCK
locked=1
break
fi
sleep 1
echo sleep 1
done
if [ $locked -eq 0 ]
then
echo Status: fail to get the lock! >> /root/keepalived.log
exit
fi
echo To master called >> /root/keepalived.log
/root/redundant_router/enable_pubip.sh
echo Enable public ip $? >> /root/keepalived.log
/root/redundant_router/primary-backup.sh primary
echo Switch conntrackd mode primary $? >> /root/keepalived.log
echo Status: MASTER >> /root/keepalived.log
rm $LOCK