Subversion Repositories ALCASAR

Rev

Rev 2692 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log

Rev 2692 Rev 2712
Line 1... Line 1...
1
#!/bin/sh
1
#!/bin/sh
2
#
2
#
3
# $Id: alcasar-macup.sh 2692 2019-01-25 23:18:50Z tom.houdayer $
3
# $Id: alcasar-macup.sh 2712 2019-03-10 23:28:36Z tom.houdayer $
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 28... Line 28...
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)
31
 
31
 
32
                if [ "$acctterminatecause" != "User-Request" ]; then
32
                if [ "$acctterminatecause" != "User-Request" ]; then
-
 
33
                        db_query_additionalGroups=''
-
 
34
                        [ -n "$FILTER_ID" ] && db_query_additionalGroups="( SELECT attribute, value FROM radgroupreply WHERE groupname = '$FILTER_ID' AND (attribute='Alcasar-Reconnect-Timeout') ) UNION "
-
 
35
                        db_query="SELECT attribute, value FROM ( \
-
 
36
                                ( SELECT attribute, value FROM radreply      WHERE username  = '$USER_NAME' AND (attribute='Alcasar-Reconnect-Timeout') ) UNION \
33
                        db_query="SELECT attribute, value FROM ((SELECT attribute, value FROM radreply WHERE (attribute='Alcasar-Reconnect-Timeout') AND username='$username') UNION (SELECT attribute, value FROM radgroupreply gr LEFT JOIN radusergroup ug ON gr.groupname = ug.groupname WHERE (attribute='Alcasar-Reconnect-Timeout') AND username = '$username' ORDER BY ug.priority) UNION (SELECT attribute, value FROM radgroupreply WHERE groupname = 'ldap' AND (attribute='Alcasar-Reconnect-Timeout'))) attrs GROUP BY attribute;"
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 \
-
 
39
                                ( SELECT attribute, value FROM radgroupreply WHERE groupname = 'default'    AND (attribute='Alcasar-Reconnect-Timeout') ) \
-
 
40
                        ) attrs GROUP BY attribute;"
34
                        db_res=$(mysql -u root -p"$dbRootPass" -D radius -e "$db_query" -Bs)
41
                        db_res=$(mysql -u root -p"$dbRootPass" -D radius -e "$db_query" -Bs)
35
 
42
 
36
                        reconnectTimeout=$(echo "$db_res" | awk '$1 == "Alcasar-Reconnect-Timeout" { print $2 }')
43
                        reconnectTimeout=$(echo "$db_res" | awk '$1 == "Alcasar-Reconnect-Timeout" { print $2 }')
37
 
44
 
38
                        if [ -n "$reconnectTimeout" ] && [ $timeout -le $reconnectTimeout ]; then
45
                        if [ -n "$reconnectTimeout" ] && [ $timeout -le $reconnectTimeout ]; then