| 1294 |
richard |
1 |
#!/bin/sh
|
| 2234 |
richard |
2 |
#
|
|
|
3 |
# $Id: alcasar-condown.sh 3302 2025-10-20 22:47:58Z rexy $
|
|
|
4 |
#
|
| 2068 |
richard |
5 |
# alcasar-condown.sh
|
| 2956 |
rexy |
6 |
# by Rexy & Pierre RIVAULT
|
| 1294 |
richard |
7 |
# This script is distributed under the Gnu General Public License (GPL)
|
|
|
8 |
|
| 2886 |
rexy |
9 |
# This script is started by coova after each logout
|
| 2184 |
richard |
10 |
# Ce script est lancé par coova à chaque déconnexion d'usager
|
| 1294 |
richard |
11 |
|
| 2965 |
rexy |
12 |
CONF_FILE="/usr/local/etc/alcasar.conf"
|
| 2501 |
tom.houday |
13 |
PASSWD_FILE="/root/ALCASAR-passwords.txt"
|
| 2886 |
rexy |
14 |
DB_USER=`cat $PASSWD_FILE|grep ^db_user=|cut -d'=' -f2`
|
|
|
15 |
DB_PASSWORD=`cat $PASSWD_FILE|grep ^db_password=|cut -d'=' -f2`
|
| 2501 |
tom.houday |
16 |
|
| 2234 |
richard |
17 |
if [ -z $FRAMED_IP_ADDRESS ]; then
|
|
|
18 |
exit 1
|
| 2184 |
richard |
19 |
fi
|
| 1294 |
richard |
20 |
|
| 3302 |
rexy |
21 |
# Remove the user from their IPSETs
|
|
|
22 |
for set_filter in av_wl av_bl av not_filtered
|
|
|
23 |
do
|
|
|
24 |
ipset del -exist $set_filter $FRAMED_IP_ADDRESS
|
|
|
25 |
done
|
|
|
26 |
for set_filterProto in proto_0 proto_1 proto_2 proto_3
|
|
|
27 |
do
|
|
|
28 |
ipset del -exist $set_filterProto $FRAMED_IP_ADDRESS
|
|
|
29 |
done
|
| 2006 |
raphael.pi |
30 |
|
| 2501 |
tom.houday |
31 |
|
| 2896 |
rexy |
32 |
# Remove IP address from active users list
|
| 2841 |
rexy |
33 |
current_users_file="/tmp/current_users.txt"
|
| 2394 |
tom.houday |
34 |
[ -e $current_users_file ] && sed -i "/^$FRAMED_IP_ADDRESS:/d" $current_users_file
|
| 2376 |
tom.houday |
35 |
|
| 3302 |
rexy |
36 |
# Remove user_IP from load-balancing ipset
|
| 2956 |
rexy |
37 |
nb_gw=`grep ^WAN $CONF_FILE | wc -l`
|
|
|
38 |
for (( i = 0 ; i <= $nb_gw ; i++ ));do
|
|
|
39 |
gw="gw$i"
|
|
|
40 |
ipset test $gw $FRAMED_IP_ADDRESS 1>/dev/null 2>&1
|
|
|
41 |
if [ $? -eq 0 ];then
|
|
|
42 |
ipset del $gw $FRAMED_IP_ADDRESS
|
|
|
43 |
break
|
|
|
44 |
fi
|
|
|
45 |
done
|
|
|
46 |
|
| 2883 |
rexy |
47 |
#############################
|
| 2886 |
rexy |
48 |
## Debug : show all the coova parse variables (+ ALCASAR-Filter + ALCASAR-Protocols-Filter).
|
| 2883 |
rexy |
49 |
## see "/src/chilli.c" for the complete list of parse variables
|
|
|
50 |
#debug_file="/tmp/debug-condown.txt"
|
|
|
51 |
#echo "-----------------------------------------------" >> $debug_file
|
|
|
52 |
#echo `date` >> $debug_file
|
|
|
53 |
#for i in DEV NET MASK ADDR USER_NAME NAS_IP_ADDRESS SERVICE_TYPE FRAMED_IP_ADDRESS FILTER_ID STATE CLASS CUI SESSION_TIMEOUT IDLE_TIMEOUT CALLING_STATION_ID CALLED_STATION_ID NAS_ID NAS_PORT_TYPE ACCT_SESSION_ID ACCT_INTERIM_INTERVAL WISPR_LOCATION_ID WISPR_LOCATION_NAME WISPR_BANDWIDTH_MAX_UP WISPR_BANDWIDTH_MAX_DOWN COOVACHILLI_MAX_INPUT_OCTETS COOVACHILLI_MAX_OUTPUT_OCTETS COOVACHILLI_MAX_TOTAL_OCTETS INPUT_OCTETS OUTPUT_OCTETS INPUT_PACKETS OUTPUT_PACKETS SESSION_TIME IDLE_TIME LOCATION OLD_LOCATION TERMINATE_CAUSE
|
| 2184 |
richard |
54 |
#do
|
| 2883 |
rexy |
55 |
# echo -n "$i=" >> $debug_file
|
|
|
56 |
# if [[ -v $i ]];
|
|
|
57 |
# then
|
|
|
58 |
# echo -n "${!i}; " >> $debug_file
|
|
|
59 |
# else
|
|
|
60 |
# echo -n "not defined; " >> $debug_file
|
|
|
61 |
# fi
|
| 2184 |
richard |
62 |
#done
|
| 2883 |
rexy |
63 |
#echo >> $debug_file
|
| 2886 |
rexy |
64 |
#echo "ALCASAR-Filter : $set_filter" >> $debug_file
|
|
|
65 |
#echo "ALCASAR-Protocols-Filter : $set_filterProto" >> $debug_file
|
| 2883 |
rexy |
66 |
## END Debug
|
|
|
67 |
#################################
|