Subversion Repositories ALCASAR

Rev

Rev 2454 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2454 Rev 2474
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
# $Id: alcasar-load_balancing.sh 2454 2017-12-09 18:59:31Z tom.houdayer $
2
# $Id: alcasar-load_balancing.sh 2474 2017-12-30 02:00:04Z tom.houdayer $
3
 
3
 
4
# Generic Load balancer for multiple WAN links - version 1.1 (04 Feb 2011)
4
# Generic Load balancer for multiple WAN links - version 1.1 (04 Feb 2011)
5
# (c) 2011 Pau Oliva Fora - http://pof.eslack.org
5
# (c) 2011 Pau Oliva Fora - http://pof.eslack.org
6
#
6
#
7
# Licensed under GPLv3 - for full terms see:
7
# Licensed under GPLv3 - for full terms see:
Line 27... Line 27...
27
# MAIN PARAMETERs Configuration
27
# MAIN PARAMETERs Configuration
28
###############################
28
###############################
29
 
29
 
30
DIR_ETC="/usr/local/etc"
30
DIR_ETC="/usr/local/etc"
31
CONF_FILE="$DIR_ETC/alcasar.conf"
31
CONF_FILE="$DIR_ETC/alcasar.conf"
32
MULTIWAN=`grep MULTIWAN= $CONF_FILE|cut -d"=" -f2`
32
MULTIWAN=`grep ^MULTIWAN= $CONF_FILE|cut -d"=" -f2`
33
MULTIWAN=${MULTIWAN:=off}
33
MULTIWAN=${MULTIWAN:=off}
34
FAILOVER=`grep FAILOVER= $CONF_FILE|cut -d"=" -f2`
34
FAILOVER=`grep ^FAILOVER= $CONF_FILE|cut -d"=" -f2`
35
FAILOVER=${FAILOVER:=30}
35
FAILOVER=${FAILOVER:=30}
36
EXTIF=`grep ^EXTIF= $CONF_FILE|cut -d"=" -f2`				# INTernal InterFace
36
EXTIF=`grep ^EXTIF= $CONF_FILE|cut -d"=" -f2`				# INTernal InterFace
37
 
37
 
38
 
38
 
39
# space separated list of public IPs to ping in watchdog mode
39
# space separated list of public IPs to ping in watchdog mode
Line 55... Line 55...
55
CONF_FILE="/usr/local/etc/alcasar.conf"
55
CONF_FILE="/usr/local/etc/alcasar.conf"
56
 
56
 
57
# Virtual interfaces creating
57
# Virtual interfaces creating
58
function create_eth () {
58
function create_eth () {
59
	routecmd="ip route replace default scope global"
59
	routecmd="ip route replace default scope global"
60
	NBIFACE=`grep "^WAN" $CONF_FILE | wc -l`	# Nbre interfaces virtuelles
60
	NBIFACE=`grep "^WAN=" $CONF_FILE | wc -l`	# Nbre interfaces virtuelles
61
	i=0
61
	i=0
62
	while [ $i -le $NBIFACE ]
62
	while [ $i -le $NBIFACE ]
63
	do
63
	do
64
		INT="WAN$i"
64
		INT="WAN$i"
65
		echo $INT
65
		echo $INT
Line 179... Line 179...
179
	# 0 == all links ok, 1 == some link down
179
	# 0 == all links ok, 1 == some link down
180
	STATE=0
180
	STATE=0
181
 
181
 
182
	DOWNCOUNT_BAK=0
182
	DOWNCOUNT_BAK=0
183
	DOWN_BAK=""
183
	DOWN_BAK=""
184
	NBIFACE=`grep "^WAN" $CONF_FILE | wc -l`	# Nbre interfaces virtuelles
184
	NBIFACE=`grep "^WAN=" $CONF_FILE | wc -l`	# Nbre interfaces virtuelles
185
	echo "Nombre interfaces =  "$NBIFACE
185
	echo "Nombre interfaces =  "$NBIFACE
186
	WANIFACE[0]="$EXTIF"
186
	WANIFACE[0]="$EXTIF"
187
	c=0
187
	c=0
188
	while [ $c -le $NBIFACE ]; do
188
	while [ $c -le $NBIFACE ]; do
189
		ITH=(`grep "WAN$c=" $CONF_FILE | awk -F'"' '{ print $2 }' | awk -F, '{ print $2}'`)	# IFACE
189
		ITH=(`grep "^WAN$c=" $CONF_FILE | awk -F'"' '{ print $2 }' | awk -F, '{ print $2}'`)	# IFACE
190
		echo $ITH
190
		echo $ITH
191
		WANIFACE="${WANIFACE} $ITH"
191
		WANIFACE="${WANIFACE} $ITH"
192
		echo $WANIFACE
192
		echo $WANIFACE
193
		c=$(($c + 1))
193
		c=$(($c + 1))
194
	done
194
	done