3,13 → 3,13 |
# $Id$ |
# |
# alcasar-conup.sh |
# by Rexy |
# by Rexy & Pierre RIVAULT |
# This script is distributed under the Gnu General Public License (GPL) |
|
# This script is started by coova after each successfull login |
# Ce script est démarré par coova à chaque connexion d'usager (authentification réussi) |
|
|
CONF_FILE="/usr/local/etc/alcasar.conf" |
PASSWD_FILE="/root/ALCASAR-passwords.txt" |
DB_USER=`cat $PASSWD_FILE|grep ^db_user=|cut -d'=' -f2` |
DB_PASSWORD=`cat $PASSWD_FILE|grep ^db_password=|cut -d'=' -f2` |
67,6 → 67,27 |
echo "$FRAMED_IP_ADDRESS:PERM" >> $current_users_file |
fi |
|
# set the user_ip to an gw_ipset for load-balancing |
gw_min="gw0" |
weight=`grep ^PUBLIC_WEIGHT= $CONF_FILE | cut -d"=" -f2` |
already=`ipset list $gw_min | grep Number\ of\ entries: | cut -d":" -f2` |
#The *1000 is here to avoid working on floats in bash |
gw_min_value=$((1000 * $already / $weight)) |
|
nb_gw=`grep ^WAN $CONF_FILE | wc -l` |
for (( i = 1 ; i <= $nb_gw ; i++ ));do |
gw="gw${i}" |
weight=`grep ^WAN$i= $CONF_FILE | awk -F'"' '{ print $2 }' | awk -F ',' '{ print $2 }'` |
already=`ipset list $gw | grep Number\ of\ entries: | cut -d":" -f2` |
value=$((1000 * $already / $weight)) |
if [ $value -lt $gw_min_value ] |
then |
gw_min_value=$value |
gw_min=$gw |
fi |
done |
ipset add $gw_min $FRAMED_IP_ADDRESS |
|
############################# |
## Debug : show all the coova parse variables (+ ALCASAR-Filter + ALCASAR-Protocols-Filter + Alcasar-Status-Page-Must-Stay-Open). |
## see "/src/chilli.c" for the complete list of parse variables |