Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 1077 → Rev 1078

/scripts/sbin/alcasar-load_balancing.sh
14,33 → 14,38
# In this example we have 3 wan links (vlanXXX interfaces) attached to a single
# physical interface because we use a vlan-enabled switch between the balancer
# machine and the ADSL routers we want to balance. The weight parameter should
# be kept to a low integer, in this case the ADSL line connected to vlan101 and
# vlan102 is 4Mbps and the ADSL line connected to vlan100 is 8Mbps (twice fast)
# so the WEIGHT value in vlan100 is 2 because it is two times faster.
# be kept to a low integer.
#
#
# Modified by ALCASAR team :
 
 
prog="alcasar-load_balancing.sh"
pidfile="/var/run/alcasar-load_balancing.pid"
 
###############################
# MAIN PARAMETERs Configuration
###############################
# enable link failover watchdog? set to "yes" or "no".
WATCHDOG="yes"
SLEEP="30"
 
DIR_ETC="/usr/local/etc"
CONF_FILE="$DIR_ETC/alcasar.conf"
MULTIWAN=`grep MULTIWAN= $CONF_FILE|cut -d"=" -f2`
MULTIWAN=${MULTIWAN:=off}
FAILOVER=`grep FAILOVER= $CONF_FILE|cut -d"=" -f2`
FAILOVER=${FAILOVER:=30}
 
 
# space separated list of public IPs to ping in watchdog mode
# set this to some public ip addresses pingable and always on.
TESTIPS="8.8.8.8 192.0.32.10"
 
# set to 1 when testing, set to 0 when happy with the results
VERBOSE=1
VERBOSE=0
 
# CONFIGURATION ENDS HERE
###############################
 
 
 
if [ $(whoami) != "root" ]; then
echo "You must be root to run this!" ; echo ; exit 1
fi
193,7 → 198,7
if [ $VERBOSE -eq 1 ]; then
echo "[] Sleeping, state=$STATE"
fi
sleep $SLEEP
sleep $FAILOVER
IFINDEX=1
DOWN="" # liste des interfaces down
336,35 → 341,65
delete)
delete_eth
;;
fail)
failover
;;
start)
PARAM="add"
create_eth
if [ $WATCHDOG != "yes" ]; then
exit 0
if [ "$MULTIWAN" != "on" ] && [ "$MULTIWAN" != "On" ]; then
echo "The MultiGateway is not activated !"
exit 0
fi
ip route flush cache
# RETVAL=$?
# echo
# [ $RETVAL -eq 0 ] && touch /var/lock/subsys/alcasar-load_balancing
touch /var/lock/subsys/alcasar-load_balancing
failover
PARAM="add"
create_eth
ip route flush cache
if [ $FAILOVER -eq 0 ]; then
echo "The MultiWAN Mode is actived but not failover connectivity !"
exit 0
fi
echo "Starting down $prog: "
pid=`pidof -x "alcasar-load_balancing.sh"`
if [ $pid != "" ]; then
echo $pid > $pidfile
fi
touch /var/lock/subsys/alcasar-load_balancing
failover
;;
stop)
PARAM="del"
prog="alcasar-load_balancing.sh"
gprintf $"Shutting down $prog: "
killproc $prog
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/alcasar-load_balancing
return $RETVAL
ip route
echo "Shutting down $prog: "
if [ -f $pidfile ]; then
pid=`cat $pidfile`
kill -9 $pid
else
echo "$prog is not running."
exit 1
fi
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f $pidfile && rm -f /var/lock/subsys/alcasar-load_balancing
echo "Delete of virtual interfaces"
delete_eth
echo "Network restart"
service network restart 2>&1 > /dev/null
ip route
;;
status)
echo "Checking $prog : "
if [ -f $pidfile ]; then
pid=`cat $pidfile`
CHECK=`ps -p $pid --no-heading | awk {'printf $1'}`
if [ "$CHECK" = "" ]; then
echo "$prog is NOT running."
else
echo "$prog is running !"
fi
else
echo "$prog is Not running."
fi
;;
fail)
failover
;;
*)
echo "Usage: $0 [start|stop|create|delete]" ; echo ; exit 1
echo "Usage: $0 [start|stop|status|create|delete]" ; echo ; exit 1
;;
esac