Redundant Router: Restart vpn related services when redundant router fail-over

This commit is contained in:
Sheng Yang 2012-11-13 19:03:36 -08:00
parent 9f257aa60b
commit 5eba489198
5 changed files with 70 additions and 5 deletions

View File

@ -477,6 +477,7 @@ setup_redundant_router() {
cp /root/redundant_router/check_bumpup.sh $rrouter_bin_path/
cp /root/redundant_router/disable_pubip.sh $rrouter_bin_path/
cp /root/redundant_router/checkrouter.sh.templ /opt/cloud/bin/checkrouter.sh
cp /root/redundant_router/services.sh $rrouter_bin_path/
sed -i "s/\[ROUTER_ID\]/$NAME/g" /etc/keepalived/keepalived.conf
sed -i "s/\[ROUTER_IP\]/$GUEST_GW\/$GUEST_CIDR_SIZE/g" /etc/keepalived/keepalived.conf
sed -i "s/\[BOARDCAST\]/$GUEST_BRD/g" /etc/keepalived/keepalived.conf

View File

@ -21,5 +21,3 @@ while read i
do
ifconfig $i down
done < /tmp/iflist
service cloud-passwd-srvr stop
service dnsmasq stop

View File

@ -30,6 +30,4 @@ do
ifconfig $i up
fi
done < /tmp/iflist
ip route add default via [GATEWAY] dev eth2 && \
service cloud-passwd-srvr restart && \
service dnsmasq restart
ip route add default via [GATEWAY] dev eth2

View File

@ -28,12 +28,18 @@ fi
echo To master called >> [RROUTER_LOG]
[RROUTER_BIN_PATH]/enable_pubip.sh >> [RROUTER_LOG] 2>&1
ret=$?
if [ $ret -eq 0 ]
then
[RROUTER_BIN_PATH]/services.sh restart >> [RROUTER_LOG] 2>&1
ret=$?
fi
last_msg=`tail -n 1 [RROUTER_LOG]`
echo Enable public ip returned $ret >> [RROUTER_LOG]
if [ $ret -ne 0 ]
then
echo Fail to enable public ip! >> [RROUTER_LOG]
[RROUTER_BIN_PATH]/disable_pubip.sh >> [RROUTER_LOG] 2>&1
[RROUTER_BIN_PATH]/services.sh stop >> [RROUTER_LOG] 2>&1
service keepalived stop >> [RROUTER_LOG] 2>&1
service conntrackd stop >> [RROUTER_LOG] 2>&1
echo Status: FAULT \($last_msg\) >> [RROUTER_LOG]

View File

@ -0,0 +1,62 @@
#!/bin/bash
# Copyright 2012 Citrix Systems, Inc. Licensed under the
# Apache License, Version 2.0 (the "License"); you may not use this
# file except in compliance with the License. Citrix Systems, Inc.
# reserves all rights not expressly granted by the License.
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
vpn_service() {
ps aux|grep ipsec | grep -v grep > /dev/null
no_vpn=$?
if [ $no_vpn -eq 1 ]
then
return 0
fi
r=0
case "$1" in
stop)
service ipsec stop && \
service xl2tpd stop
r=$?
;;
restart)
service ipsec restart && \
service xl2tpd restart
r=$?
;;
esac
return $r
}
ret=0
case "$1" in
start)
vpn_service restart && \
service cloud-passwd-srvr start && \
service dnsmasq start
ret=$?
;;
stop)
vpn_service stop && \
service cloud-passwd-srvr stop && \
service dnsmasq stop
ret=$?
;;
restart)
vpn_service restart && \
service cloud-passwd-srvr restart && \
service dnsmasq restart
ret=$?
;;
*)
echo "Usage: services {start|stop|restart}"
exit 1
;;
esac
exit $ret