Subversion Repositories ALCASAR

Rev

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

Rev 2501 Rev 2510
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
#  $Id: alcasar.sh 2501 2018-02-28 00:34:14Z tom.houdayer $
2
#  $Id: alcasar.sh 2510 2018-03-11 14:38:39Z tom.houdayer $
3
 
3
 
4
# alcasar.sh
4
# alcasar.sh
5
# ALCASAR is a Free and open source NAC created by Franck BOUIJOUX (3abtux), Pascal LEVANT and Richard REY (Rexy)
5
# ALCASAR is a Free and open source NAC created by Franck BOUIJOUX (3abtux), Pascal LEVANT and Richard REY (Rexy)
6
# This script is distributed under the Gnu General Public License (GPL)
6
# This script is distributed under the Gnu General Public License (GPL)
7
#  team@alcasar.net
7
#  team@alcasar.net
Line 998... Line 998...
998
    WHERE username='%{\${key}}' \
998
    WHERE username='%{\${key}}' \
999
    AND UNIX_TIMESTAMP(acctstarttime) + acctsessiontime > '%%b'),0)"
999
    AND UNIX_TIMESTAMP(acctstarttime) + acctsessiontime > '%%b'),0)"
1000
EOF
1000
EOF
1001
	[ -e /etc/raddb/mods-config/sql/counter/mysql/noresetcounter.conf.default ] || cp /etc/raddb/mods-config/sql/counter/mysql/noresetcounter.conf /etc/raddb/mods-config/sql/counter/mysql/noresetcounter.conf.default
1001
	[ -e /etc/raddb/mods-config/sql/counter/mysql/noresetcounter.conf.default ] || cp /etc/raddb/mods-config/sql/counter/mysql/noresetcounter.conf /etc/raddb/mods-config/sql/counter/mysql/noresetcounter.conf.default
1002
	cat << EOF > /etc/raddb/mods-config/sql/counter/mysql/noresetcounter.conf
1002
	cat << EOF > /etc/raddb/mods-config/sql/counter/mysql/noresetcounter.conf
-
 
1003
query = "\
-
 
1004
    SELECT IFNULL(SUM(AcctSessionTime),0) \
-
 
1005
    FROM radacct \
-
 
1006
    WHERE username='%{\${key}}'"
-
 
1007
EOF
1003
# This query was modified for ALCASAR needs (amount of time the voucher is enabled --> rename it in the future : 'Expire_on_login')
1008
	[ -e /etc/raddb/mods-config/sql/counter/mysql/expire_on_login.conf.default ] || cp /etc/raddb/mods-config/sql/counter/mysql/expire_on_login.conf /etc/raddb/mods-config/sql/counter/mysql/expire_on_login.conf.default
-
 
1009
	cat << EOF > /etc/raddb/mods-config/sql/counter/mysql/expire_on_login.conf
1004
query = "\
1010
query = "\
1005
    SELECT IFNULL((SELECT TIME_TO_SEC(TIMEDIFF(NOW(), acctstarttime)) \
1011
    SELECT IFNULL((SELECT TIME_TO_SEC(TIMEDIFF(NOW(), acctstarttime)) \
1006
    FROM radacct \
1012
    FROM radacct \
1007
    WHERE UserName='%{\${key}}' \
1013
    WHERE username='%{\${key}}' \
1008
    ORDER BY acctstarttime \
1014
    ORDER BY acctstarttime \
1009
    LIMIT 1),0)"
1015
    LIMIT 1),0)"
1010
EOF
1016
EOF
1011
# make certain that mysql is up before freeradius start
1017
# make certain that mysql is up before freeradius start
1012
	[ -e /lib/systemd/system/radiusd.service.default ] || cp /lib/systemd/system/radiusd.service /lib/systemd/system/radiusd.service.default
1018
	[ -e /lib/systemd/system/radiusd.service.default ] || cp /lib/systemd/system/radiusd.service /lib/systemd/system/radiusd.service.default