Subversion Repositories ALCASAR

Rev

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

Rev 2712 Rev 3269
Line 1... Line 1...
1
#!/bin/sh
1
#!/bin/sh
2
#
2
#
3
# $Id: alcasar-macup.sh 2712 2019-03-10 23:28:36Z tom.houdayer $
3
# $Id: alcasar-macup.sh 3269 2025-04-21 21:57:13Z rexy $
4
#
4
#
5
# alcasar-macup.sh
5
# alcasar-macup.sh
6
#
6
#
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 20... Line 20...
20
is_connected=$(echo "$chilli_query_res" | awk '{ print $5 }')
20
is_connected=$(echo "$chilli_query_res" | awk '{ print $5 }')
21
current_mac=$CALLING_STATION_ID
21
current_mac=$CALLING_STATION_ID
22
 
22
 
23
if [ $is_connected == '0' ]; then
23
if [ $is_connected == '0' ]; then
24
	db_query="SELECT username, IFNULL((UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(acctstoptime)), 0) AS timeout, acctterminatecause FROM radacct WHERE callingstationid='$current_mac' ORDER BY acctstarttime DESC LIMIT 1;"
24
	db_query="SELECT username, IFNULL((UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(acctstoptime)), 0) AS timeout, acctterminatecause FROM radacct WHERE callingstationid='$current_mac' ORDER BY acctstarttime DESC LIMIT 1;"
25
	db_res=$(mysql -u root -p"$dbRootPass" -D radius -e "$db_query" -Bs)
25
	db_res=$(mariadb -u root -p"$dbRootPass" -D radius -e "$db_query" -Bs)
26
 
26
 
27
	if [ -n "$db_res" ]; then
27
	if [ -n "$db_res" ]; then
28
		username=$(echo "$db_res"           | cut -f1)
28
		username=$(echo "$db_res"           | cut -f1)
29
		timeout=$(echo "$db_res"            | cut -f2)
29
		timeout=$(echo "$db_res"            | cut -f2)
30
		acctterminatecause=$(echo "$db_res" | cut -f3)
30
		acctterminatecause=$(echo "$db_res" | cut -f3)
Line 36... Line 36...
36
				( SELECT attribute, value FROM radreply      WHERE username  = '$USER_NAME' AND (attribute='Alcasar-Reconnect-Timeout') ) UNION \
36
				( SELECT attribute, value FROM radreply      WHERE username  = '$USER_NAME' AND (attribute='Alcasar-Reconnect-Timeout') ) UNION \
37
				( SELECT attribute, value FROM radgroupreply gr LEFT JOIN radusergroup ug ON gr.groupname = ug.groupname WHERE username = '$USER_NAME' AND (attribute='Alcasar-Reconnect-Timeout') ORDER BY ug.priority ) UNION \
37
				( SELECT attribute, value FROM radgroupreply gr LEFT JOIN radusergroup ug ON gr.groupname = ug.groupname WHERE username = '$USER_NAME' AND (attribute='Alcasar-Reconnect-Timeout') ORDER BY ug.priority ) UNION \
38
				$db_query_additionalGroups \
38
				$db_query_additionalGroups \
39
				( SELECT attribute, value FROM radgroupreply WHERE groupname = 'default'    AND (attribute='Alcasar-Reconnect-Timeout') ) \
39
				( SELECT attribute, value FROM radgroupreply WHERE groupname = 'default'    AND (attribute='Alcasar-Reconnect-Timeout') ) \
40
			) attrs GROUP BY attribute;"
40
			) attrs GROUP BY attribute;"
41
			db_res=$(mysql -u root -p"$dbRootPass" -D radius -e "$db_query" -Bs)
41
			db_res=$(mariadb -u root -p"$dbRootPass" -D radius -e "$db_query" -Bs)
42
 
42
 
43
			reconnectTimeout=$(echo "$db_res" | awk '$1 == "Alcasar-Reconnect-Timeout" { print $2 }')
43
			reconnectTimeout=$(echo "$db_res" | awk '$1 == "Alcasar-Reconnect-Timeout" { print $2 }')
44
 
44
 
45
			if [ -n "$reconnectTimeout" ] && [ $timeout -le $reconnectTimeout ]; then
45
			if [ -n "$reconnectTimeout" ] && [ $timeout -le $reconnectTimeout ]; then
46
				for i in {1..10}; do
46
				for i in {1..10}; do