Subversion Repositories ALCASAR

Rev

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

Rev 2886 Rev 2956
Line 1... Line 1...
1
#!/bin/sh
1
#!/bin/sh
2
#
2
#
3
# $Id: alcasar-conup.sh 2886 2020-11-23 22:50:01Z rexy $
3
# $Id: alcasar-conup.sh 2956 2021-05-24 19:57:17Z rexy $
4
#
4
#
5
# alcasar-conup.sh
5
# alcasar-conup.sh
6
# by Rexy
6
# by Rexy & Pierre RIVAULT
7
# This script is distributed under the Gnu General Public License (GPL)
7
# This script is distributed under the Gnu General Public License (GPL)
8
 
8
 
9
# This script is started by coova after each successfull login
9
# This script is started by coova after each successfull login
10
# Ce script est démarré par coova à chaque connexion d'usager (authentification réussi)
10
# Ce script est démarré par coova à chaque connexion d'usager (authentification réussi)
11
 
11
 
12
 
-
 
-
 
12
CONF_FILE="/usr/local/etc/alcasar.conf"
13
PASSWD_FILE="/root/ALCASAR-passwords.txt"
13
PASSWD_FILE="/root/ALCASAR-passwords.txt"
14
DB_USER=`cat $PASSWD_FILE|grep ^db_user=|cut -d'=' -f2`
14
DB_USER=`cat $PASSWD_FILE|grep ^db_user=|cut -d'=' -f2`
15
DB_PASSWORD=`cat $PASSWD_FILE|grep ^db_password=|cut -d'=' -f2`
15
DB_PASSWORD=`cat $PASSWD_FILE|grep ^db_password=|cut -d'=' -f2`
16
 
16
 
17
if [ -z $FRAMED_IP_ADDRESS ]; then
17
if [ -z $FRAMED_IP_ADDRESS ]; then
Line 65... Line 65...
65
		touch $current_users_file && chown root:apache $current_users_file && chmod 660 $current_users_file
65
		touch $current_users_file && chown root:apache $current_users_file && chmod 660 $current_users_file
66
    fi
66
    fi
67
	echo "$FRAMED_IP_ADDRESS:PERM" >> $current_users_file
67
	echo "$FRAMED_IP_ADDRESS:PERM" >> $current_users_file
68
fi
68
fi
69
 
69
 
-
 
70
# set the user_ip to an gw_ipset for load-balancing
-
 
71
gw_min="gw0"
-
 
72
weight=`grep ^PUBLIC_WEIGHT= $CONF_FILE | cut -d"=" -f2`
-
 
73
already=`ipset list $gw_min | grep Number\ of\ entries: | cut -d":" -f2`
-
 
74
#The *1000 is here to avoid working on floats in bash
-
 
75
gw_min_value=$((1000 * $already / $weight))
-
 
76
 
-
 
77
nb_gw=`grep ^WAN $CONF_FILE | wc -l`
-
 
78
for (( i = 1 ; i <= $nb_gw ; i++ ));do
-
 
79
	gw="gw${i}"
-
 
80
	weight=`grep ^WAN$i= $CONF_FILE | awk -F'"' '{ print $2 }' | awk -F ',' '{ print $2 }'`
-
 
81
	already=`ipset list $gw | grep Number\ of\ entries: | cut -d":" -f2`
-
 
82
	value=$((1000 * $already / $weight))
-
 
83
	if [ $value -lt $gw_min_value ]
-
 
84
	then
-
 
85
		gw_min_value=$value
-
 
86
		gw_min=$gw
-
 
87
	fi
-
 
88
done
-
 
89
ipset add $gw_min $FRAMED_IP_ADDRESS
-
 
90
 
70
#############################
91
#############################
71
## Debug : show all the coova parse variables (+ ALCASAR-Filter + ALCASAR-Protocols-Filter + Alcasar-Status-Page-Must-Stay-Open).
92
## Debug : show all the coova parse variables (+ ALCASAR-Filter + ALCASAR-Protocols-Filter + Alcasar-Status-Page-Must-Stay-Open).
72
## see "/src/chilli.c" for the complete list of parse variables
93
## see "/src/chilli.c" for the complete list of parse variables
73
#debug_file="/tmp/debug-conup.txt"
94
#debug_file="/tmp/debug-conup.txt"
74
#echo "-----------------------------------------------" >> $debug_file
95
#echo "-----------------------------------------------" >> $debug_file