Subversion Repositories ALCASAR

Rev

Rev 2505 | Rev 2712 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2505 Rev 2692
1
#!/bin/sh
1
#!/bin/sh
2
#
2
#
3
# $Id: alcasar-condown.sh 2505 2018-03-11 13:41:00Z tom.houdayer $
3
# $Id: alcasar-condown.sh 2692 2019-01-25 23:18:50Z tom.houdayer $
4
#
4
#
5
# alcasar-condown.sh
5
# alcasar-condown.sh
6
# by Rexy
6
# by Rexy
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 launched by coova after each logout
9
# This script is launched by coova after each logout
10
# Ce script est lancé par coova à chaque déconnexion d'usager
10
# Ce script est lancé par coova à chaque déconnexion d'usager
11
 
11
 
12
PASSWD_FILE="/root/ALCASAR-passwords.txt"
12
PASSWD_FILE="/root/ALCASAR-passwords.txt"
13
 
13
 
14
if [ -z $FRAMED_IP_ADDRESS ]; then
14
if [ -z $FRAMED_IP_ADDRESS ]; then
15
	exit 1
15
	exit 1
16
fi
16
fi
17
 
17
 
18
# Remove user from his IPSET
18
# Remove user from his IPSET
19
 
19
 
20
db_query="SELECT attribute, value FROM (( SELECT attribute, value FROM radreply WHERE (attribute='Alcasar-Filter' OR attribute='Alcasar-Protocols-Filter' OR attribute='Alcasar-Status-Page-Must-Stay-Open') AND username='$USER_NAME') UNION ( SELECT attribute, value FROM radgroupreply gr LEFT JOIN radusergroup ug ON gr.groupname = ug.groupname WHERE (attribute='Alcasar-Filter' OR attribute='Alcasar-Protocols-Filter' OR attribute='Alcasar-Status-Page-Must-Stay-Open') AND username = '$USER_NAME' ORDER BY ug.priority)) attrs GROUP BY attribute;"
20
db_query="SELECT attribute, value FROM (( SELECT attribute, value FROM radreply WHERE (attribute IN ('Alcasar-Filter', 'Alcasar-Protocols-Filter')) AND username='$USER_NAME') UNION ( SELECT attribute, value FROM radgroupreply gr LEFT JOIN radusergroup ug ON gr.groupname = ug.groupname WHERE (attribute IN ('Alcasar-Filter', 'Alcasar-Protocols-Filter')) AND username = '$USER_NAME' ORDER BY ug.priority) UNION (SELECT attribute, value FROM radgroupreply WHERE groupname = 'ldap' AND (attribute IN ('Alcasar-Filter', 'Alcasar-Protocols-Filter')))) attrs GROUP BY attribute;"
21
db_res=$(mysql -u root -p$(cat $PASSWD_FILE | grep ^db_root= | cut -d'=' -f2-) -D radius -e "$db_query" -Ns)
21
db_res=$(mysql -u root -p$(cat $PASSWD_FILE | grep ^db_root= | cut -d'=' -f2-) -D radius -e "$db_query" -Ns)
22
 
22
 
23
filter=$(echo "$db_res"             | awk '$1 == "Alcasar-Filter"               { print $2 }')
23
filter=$(echo "$db_res"             | awk '$1 == "Alcasar-Filter"           { print $2 }')
24
filterProto=$(echo "$db_res"        | awk '$1 == "Alcasar-Protocols-Filter"         { print $2 }')
24
filterProto=$(echo "$db_res"        | awk '$1 == "Alcasar-Protocols-Filter" { print $2 }')
25
statusOpenRequired=$(echo "$db_res" | awk '$1 == "Alcasar-Status-Page-Must-Stay-Open" { print $2 }')
-
 
26
 
25
 
27
if [ "$filter" == '4' ]; then	# HAVP_WL
26
if [ "$filter" == '4' ]; then	# HAVP_WL
28
	set_filter="havp_wl"
27
	set_filter="havp_wl"
29
elif [ "$filter" == '3' ]; then	# HAVP_BL
28
elif [ "$filter" == '3' ]; then	# HAVP_BL
30
	set_filter="havp_bl"
29
	set_filter="havp_bl"
31
elif [ "$filter" == '2' ]; then	# HAVP
30
elif [ "$filter" == '2' ]; then	# HAVP
32
	set_filter="havp"
31
	set_filter="havp"
33
else				# NOT_FILTERED
32
else				# NOT_FILTERED
34
	set_filter="not_filtered"
33
	set_filter="not_filtered"
35
fi
34
fi
36
 
35
 
37
if [ "$filterProto" == '4' ]; then	# PROFILE 3 (Custom)
36
if [ "$filterProto" == '4' ]; then	# PROFILE 3 (Custom)
38
	set_filterProto="proto_3";
37
	set_filterProto="proto_3";
39
elif [ "$filterProto" == '3' ]; then	# PROFILE 2 (WEB + Mail + Remote access)
38
elif [ "$filterProto" == '3' ]; then	# PROFILE 2 (WEB + Mail + Remote access)
40
	set_filterProto="proto_2";
39
	set_filterProto="proto_2";
41
elif [ "$filterProto" == '2' ]; then	# PROFILE 1 (WEB)
40
elif [ "$filterProto" == '2' ]; then	# PROFILE 1 (WEB)
42
	set_filterProto="proto_1";
41
	set_filterProto="proto_1";
43
else					# PROFILE 0 (Not filtered)
42
else					# PROFILE 0 (Not filtered)
44
	set_filterProto="proto_0";
43
	set_filterProto="proto_0";
45
fi
44
fi
46
 
45
 
47
ipset del $set_filter      $FRAMED_IP_ADDRESS
46
ipset del $set_filter      $FRAMED_IP_ADDRESS
48
ipset del $set_filterProto $FRAMED_IP_ADDRESS
47
ipset del $set_filterProto $FRAMED_IP_ADDRESS
49
 
48
 
50
# Remove IP address from active users
49
# Remove IP address from active users
51
current_users_file="/var/tmp/havp/current_users.txt"
50
current_users_file="/var/tmp/havp/current_users.txt"
52
[ -e $current_users_file ] && sed -i "/^$FRAMED_IP_ADDRESS:/d" $current_users_file
51
[ -e $current_users_file ] && sed -i "/^$FRAMED_IP_ADDRESS:/d" $current_users_file
53
 
52
 
54
# Debug : show all the coova parse variables (+ $set_filter + $set_filterProto).
53
# Debug : show all the coova parse variables (+ $set_filter + $set_filterProto).
55
# see "/src/chilli.c" for the complete list of parse variables
54
# see "/src/chilli.c" for the complete list of parse variables
56
#echo "-----------------------------------------------" >> /tmp/debug-condown.txt
55
#echo "-----------------------------------------------" >> /tmp/debug-condown.txt
57
#echo `date` >> /tmp/debug-condown.txt
56
#echo `date` >> /tmp/debug-condown.txt
58
#for i in LAYER3 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 WISPR-SESSION_TERMINATE_TIME CHILLISPOT_MAX_INPUT_OCTETS CHILLISPOT_MAX_OUTPUT_OCTETS CHILLISPOT_MAX_TOTAL_OCTETS INPUT_OCTETS OUTPUT_OCTETS SESSION_TIME IDLE_TIME LOCATION OLD_LOCATION TERMINATE_CAUSE
57
#for i in LAYER3 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 WISPR-SESSION_TERMINATE_TIME CHILLISPOT_MAX_INPUT_OCTETS CHILLISPOT_MAX_OUTPUT_OCTETS CHILLISPOT_MAX_TOTAL_OCTETS INPUT_OCTETS OUTPUT_OCTETS SESSION_TIME IDLE_TIME LOCATION OLD_LOCATION TERMINATE_CAUSE
59
#do
58
#do
60
#	echo "$i : ${!i}" >> /tmp/debug-condown.txt
59
#	echo "$i : ${!i}" >> /tmp/debug-condown.txt
61
#done
60
#done
62
#echo "set_filter : $set_filter" >> /tmp/debug-condown.txt
61
#echo "set_filter : $set_filter" >> /tmp/debug-condown.txt
63
#echo "set_filterProto : $set_filterProto" >> /tmp/debug-condown.txt
62
#echo "set_filterProto : $set_filterProto" >> /tmp/debug-condown.txt
64
 
63
 
65
 
64
 
66

Generated by GNU Enscript 1.6.6.
65

Generated by GNU Enscript 1.6.6.
67
 
66
 
68
 
67
 
69
 
68