Bug:CS-16318 Starting password server on the both IPs in RRVM

Reviewed-by: Abhi
This commit is contained in:
Jayapal Reddy 2012-09-12 17:57:03 +05:30
parent 1791d2b52f
commit fa94da1140
6 changed files with 56 additions and 24 deletions

View File

@ -17,12 +17,16 @@ ENABLED=0
start() {
[ "$ENABLED" != 0 ] || exit 0
pid=$(getpid)
[ "$pid" != "" ] && echo "Password server is already running (pid=$pid)" && return 0
nohup bash /opt/cloud/bin/passwd_server&
[ "$pid" != "" ] && echo "Password server is already running (pid=$pid)"
#stop is required for only in the boot up case. on boot up services are started twice.
#so if already passwd server started on one ip, second time RRVM interface got the two ips
#so stop the first process and start the process on both the ips
stop;
nohup bash /opt/cloud/bin/passwd_server
}
getpid() {
pid=$(ps -ef | grep passwd_server | grep -v grep | awk '{print $2}')
pid=$(ps -ef | grep passwd_server_ip | grep -v grep | awk '{print $2}')
echo $pid
}
@ -36,7 +40,7 @@ stop () {
stop_socat
pid=$(getpid)
[ "$pid" != "" ] && kill -9 $pid && echo "Stopped password server (pid=$pid)" && stop_socat && return 0
echo "Password server is not running" && return 0
echo "stop:Password server is not running" && return 0
}
status () {

View File

@ -1,18 +1,6 @@
#!/bin/bash
. /etc/default/cloud-passwd-srvr
#guestIp=$(ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}')
while [ "$ENABLED" == "1" ]
do
socat -lf /var/log/cloud.log TCP4-LISTEN:8080,reuseaddr,crnl,bindtodevice=eth0 SYSTEM:"/opt/cloud/bin/serve_password.sh \"\$SOCAT_PEERADDR\""
rc=$?
if [ $rc -ne 0 ]
then
logger -t cloud "Password server failed with error code $rc. Restarting socat..."
sleep 3
fi
. /etc/default/cloud-passwd-srvr
done
ips=$(ip addr show dev eth0 | grep inet | grep eth0 | awk '{print $2}' ); echo $ips
for ip in $ips; do
addr=$(echo $ip | awk -F'/' '{print $1}')
/opt/cloud/bin/passwd_server_ip $addr &
done;

View File

@ -0,0 +1,15 @@
#!/bin/bash
. /etc/default/cloud-passwd-srvr
addr=$1;
while [ "$ENABLED" == "1" ]
do
socat -lf /var/log/cloud.log TCP4-LISTEN:8080,reuseaddr,crnl,bind=$addr SYSTEM:"/opt/cloud/bin/serve_password.sh \"\$SOCAT_PEERADDR\""
rc=$?
if [ $rc -ne 0 ]
then
logger -t cloud "Password server failed with error code $rc. Restarting socat..."
sleep 3
fi
. /etc/default/cloud-passwd-srvr
done

View File

@ -68,7 +68,7 @@ routing_svcs() {
grep "redundant_router=1" /var/cache/cloud/cmdline > /dev/null
RROUTER=$?
chkconfig cloud off
chkconfig cloud-passwd-srvr on ;
# chkconfig cloud-passwd-srvr on ;
chkconfig haproxy on ;
chkconfig ssh on
chkconfig nfs-common off
@ -76,16 +76,18 @@ routing_svcs() {
if [ $RROUTER -eq 0 ]
then
chkconfig dnsmasq off
chkconfig cloud-passwd-srvr off
chkconfig keepalived on
chkconfig conntrackd on
chkconfig postinit on
echo "keepalived conntrackd postinit" > /var/cache/cloud/enabled_svcs
echo "dnsmasq " > /var/cache/cloud/disabled_svcs
echo "dnsmasq cloud-passwd-srvr" > /var/cache/cloud/disabled_svcs
else
chkconfig dnsmasq on
chkconfig cloud-passwd-srvr on
chkconfig keepalived off
chkconfig conntrackd off
echo "dnsmasq " > /var/cache/cloud/enabled_svcs
echo "dnsmasq cloud-passwd-srvr " > /var/cache/cloud/enabled_svcs
echo "keepalived conntrackd " > /var/cache/cloud/disabled_svcs
fi
echo "cloud-passwd-srvr ssh haproxy apache2" >> /var/cache/cloud/enabled_svcs

View File

@ -17,4 +17,16 @@ echo Switch conntrackd mode backup $? >> [RROUTER_LOG]
echo Status: BACKUP >> [RROUTER_LOG]
releaseLockFile $lock $locked
lock="passwdlock"
locked=$(getLockFile $lock)
if [ "$locked" != "1" ]
then
exit 1
fi
service cloud-passwd-srvr stop
releaseLockFile $lock $locked
exit 0

View File

@ -34,5 +34,16 @@ fi
[RROUTER_BIN_PATH]/arping_gateways.sh
echo Status: MASTER >> [RROUTER_LOG]
releaseLockFile $lock $locked
lock="passwdlock"
locked=$(getLockFile $lock)
if [ "$locked" != "1" ]
then
exit 1
fi
service cloud-passwd-srvr restart
releaseLockFile $lock $locked
exit 0