Subversion Repositories ALCASAR

Rev

Rev 2841 | Rev 2886 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2841 Rev 2883
Line 1... Line 1...
1
#!/bin/sh
1
#!/bin/sh
2
#
2
#
3
# $Id: alcasar-condown.sh 2841 2020-06-28 21:49:00Z rexy $
3
# $Id: alcasar-condown.sh 2883 2020-11-15 21:14:52Z rexy $
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
 
Line 14... Line 14...
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
db_query_additionalGroups=''
19
db_query_additionalGroups=''  # before alcasar-3.4, filter types was in "FILTER_ID" attribute
20
[ -n "$FILTER_ID" ] && db_query_additionalGroups="( SELECT attribute, value FROM radgroupreply WHERE groupname = '$FILTER_ID' AND (attribute IN ('Alcasar-Filter', 'Alcasar-Protocols-Filter')) ) UNION "
20
[ -n "$FILTER_ID" ] && db_query_additionalGroups="( SELECT attribute, value FROM radgroupreply WHERE groupname = '$FILTER_ID' AND (attribute IN ('Alcasar-Filter', 'Alcasar-Protocols-Filter')) ) UNION "
21
db_query="SELECT attribute, value FROM ( \
21
db_query="SELECT attribute, value FROM ( \
22
	( SELECT attribute, value FROM radreply      WHERE username  = '$USER_NAME' AND (attribute IN ('Alcasar-Filter', 'Alcasar-Protocols-Filter')) ) UNION \
22
	( SELECT attribute, value FROM radreply WHERE username = '$USER_NAME' AND (attribute IN ('Alcasar-Filter', 'Alcasar-Protocols-Filter')) ) UNION \
23
	( SELECT attribute, value FROM radgroupreply gr LEFT JOIN radusergroup ug ON gr.groupname = ug.groupname WHERE username = '$USER_NAME' AND (attribute IN ('Alcasar-Filter', 'Alcasar-Protocols-Filter')) ORDER BY ug.priority ) UNION \
23
	( SELECT attribute, value FROM radgroupreply gr LEFT JOIN radusergroup ug ON gr.groupname = ug.groupname WHERE username = '$USER_NAME' AND (attribute IN ('Alcasar-Filter', 'Alcasar-Protocols-Filter')) ORDER BY ug.priority ) UNION \
24
	$db_query_additionalGroups \
24
	$db_query_additionalGroups \
25
	( SELECT attribute, value FROM radgroupreply WHERE groupname = 'default'    AND (attribute IN ('Alcasar-Filter', 'Alcasar-Protocols-Filter')) ) \
25
	( SELECT attribute, value FROM radgroupreply WHERE groupname = 'default' AND (attribute IN ('Alcasar-Filter', 'Alcasar-Protocols-Filter')) ) \
26
) attrs GROUP BY attribute;"
26
) attrs GROUP BY attribute;"
27
db_res=$(mysql -u root -p$(cat $PASSWD_FILE | grep ^db_root= | cut -d'=' -f2-) -D radius -e "$db_query" -Ns)
27
db_res=$(mysql -u root -p$(cat $PASSWD_FILE | grep ^db_root= | cut -d'=' -f2-) -D radius -e "$db_query" -Ns)
28
 
28
 
29
filter=$(echo "$db_res"      | awk '$1 == "Alcasar-Filter"           { print $2 }')
29
filter=$(echo "$db_res"      | awk '$1 == "Alcasar-Filter"           { print $2 }')
30
filterProto=$(echo "$db_res" | awk '$1 == "Alcasar-Protocols-Filter" { print $2 }')
30
filterProto=$(echo "$db_res" | awk '$1 == "Alcasar-Protocols-Filter" { print $2 }')
Line 54... Line 54...
54
 
54
 
55
# Remove IP address from active users
55
# Remove IP address from active users
56
current_users_file="/tmp/current_users.txt"
56
current_users_file="/tmp/current_users.txt"
57
[ -e $current_users_file ] && sed -i "/^$FRAMED_IP_ADDRESS:/d" $current_users_file
57
[ -e $current_users_file ] && sed -i "/^$FRAMED_IP_ADDRESS:/d" $current_users_file
58
 
58
 
-
 
59
#############################
59
# Debug : show all the coova parse variables (+ $set_filter + $set_filterProto).
60
## Debug : show all the coova parse variables (+ $set_filter + $set_filterProto).
60
# see "/src/chilli.c" for the complete list of parse variables
61
## see "/src/chilli.c" for the complete list of parse variables
-
 
62
#debug_file="/tmp/debug-condown.txt"
61
#echo "-----------------------------------------------" >> /tmp/debug-condown.txt
63
#echo "-----------------------------------------------" >> $debug_file
62
#echo `date` >> /tmp/debug-condown.txt
64
#echo `date` >> $debug_file
63
#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
65
#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
64
#do
66
#do
-
 
67
#	echo -n "$i=" >> $debug_file
-
 
68
#	if [[ -v $i ]];
-
 
69
#	then
65
#	echo "$i : ${!i}" >> /tmp/debug-condown.txt
70
#		echo -n "${!i}; " >> $debug_file
-
 
71
#	else
-
 
72
#		echo -n "not defined; " >> $debug_file
-
 
73
#	fi
66
#done
74
#done
-
 
75
#echo >> $debug_file
67
#echo "set_filter : $set_filter" >> /tmp/debug-condown.txt
76
#echo "set_filter : $set_filter" >> $debug_file
68
#echo "set_filterProto : $set_filterProto" >> /tmp/debug-condown.txt
77
#echo "set_filterProto : $set_filterProto" >> $debug_file
-
 
78
## END Debug
-
 
79
#################################