diff --git a/patches/systemvm/debian/config/etc/init.d/cloud-early-config b/patches/systemvm/debian/config/etc/init.d/cloud-early-config index 0f97ebf5cee..2eeb951d366 100755 --- a/patches/systemvm/debian/config/etc/init.d/cloud-early-config +++ b/patches/systemvm/debian/config/etc/init.d/cloud-early-config @@ -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 diff --git a/patches/systemvm/debian/config/root/redundant_router/backup.sh b/patches/systemvm/debian/config/root/redundant_router/backup.sh index db7811e0ce3..8efe190028d 100644 --- a/patches/systemvm/debian/config/root/redundant_router/backup.sh +++ b/patches/systemvm/debian/config/root/redundant_router/backup.sh @@ -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 diff --git a/patches/systemvm/debian/config/root/redundant_router/master.sh b/patches/systemvm/debian/config/root/redundant_router/master.sh index 22ac940e21d..76253c0042f 100644 --- a/patches/systemvm/debian/config/root/redundant_router/master.sh +++ b/patches/systemvm/debian/config/root/redundant_router/master.sh @@ -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