Line 1... |
Line 1... |
1 |
#!/bin/bash
|
1 |
#!/bin/bash
|
2 |
# $Id: alcasar.sh 2594 2018-08-19 23:11:42Z tom.houdayer $
|
2 |
# $Id: alcasar.sh 2597 2018-08-19 23:34:40Z 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 985... |
Line 985... |
985 |
chown -R radius:radius /etc/raddb/mods-config/sql/main/mysql/queries.conf
|
985 |
chown -R radius:radius /etc/raddb/mods-config/sql/main/mysql/queries.conf
|
986 |
# sqlcounter modifications
|
986 |
# sqlcounter modifications
|
987 |
[ -e /etc/raddb/mods-available/sqlcounter.default ] || cp /etc/raddb/mods-available/sqlcounter /etc/raddb/mods-available/sqlcounter.default
|
987 |
[ -e /etc/raddb/mods-available/sqlcounter.default ] || cp /etc/raddb/mods-available/sqlcounter /etc/raddb/mods-available/sqlcounter.default
|
988 |
cp -f $DIR_CONF/radius/sqlcounter /etc/raddb/mods-available/sqlcounter
|
988 |
cp -f $DIR_CONF/radius/sqlcounter /etc/raddb/mods-available/sqlcounter
|
989 |
chown -R radius:radius /etc/raddb/mods-available/sqlcounter
|
989 |
chown -R radius:radius /etc/raddb/mods-available/sqlcounter
|
990 |
[ -e /etc/raddb/mods-config/sql/counter/mysql/dailycounter.conf.default ] || cp /etc/raddb/mods-config/sql/counter/mysql/dailycounter.conf /etc/raddb/mods-config/sql/counter/mysql/dailycounter.conf.default
|
- |
|
991 |
cat << EOF > /etc/raddb/mods-config/sql/counter/mysql/dailycounter.conf
|
- |
|
992 |
query = "\
|
- |
|
993 |
SELECT IFNULL((SELECT SUM(acctsessiontime - GREATEST((%%b - UNIX_TIMESTAMP(acctstarttime)),0)) \
|
- |
|
994 |
FROM radacct \
|
- |
|
995 |
WHERE username = '%{\${key}}' \
|
- |
|
996 |
AND UNIX_TIMESTAMP(acctstarttime) + acctsessiontime > '%%b'),0)"
|
- |
|
997 |
EOF
|
- |
|
998 |
[ -e /etc/raddb/mods-config/sql/counter/mysql/monthlycounter.conf.default ] || cp /etc/raddb/mods-config/sql/counter/mysql/monthlycounter.conf /etc/raddb/mods-config/sql/counter/mysql/monthlycounter.conf.default
|
- |
|
999 |
cat << EOF > /etc/raddb/mods-config/sql/counter/mysql/monthlycounter.conf
|
- |
|
1000 |
query = "\
|
- |
|
1001 |
SELECT IFNULL((SELECT SUM(acctsessiontime - GREATEST((%%b - UNIX_TIMESTAMP(acctstarttime)), 0)) \
|
- |
|
1002 |
FROM radacct \
|
- |
|
1003 |
WHERE username='%{\${key}}' \
|
- |
|
1004 |
AND UNIX_TIMESTAMP(acctstarttime) + acctsessiontime > '%%b'),0)"
|
- |
|
1005 |
EOF
|
- |
|
1006 |
[ -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
|
- |
|
1007 |
cat << EOF > /etc/raddb/mods-config/sql/counter/mysql/noresetcounter.conf
|
- |
|
1008 |
query = "\
|
- |
|
1009 |
SELECT IFNULL(SUM(AcctSessionTime),0) \
|
- |
|
1010 |
FROM radacct \
|
- |
|
1011 |
WHERE username='%{\${key}}'"
|
- |
|
1012 |
EOF
|
- |
|
1013 |
[ -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
|
- |
|
1014 |
cat << EOF > /etc/raddb/mods-config/sql/counter/mysql/expire_on_login.conf
|
- |
|
1015 |
query = "\
|
- |
|
1016 |
SELECT IFNULL((SELECT TIME_TO_SEC(TIMEDIFF(NOW(), acctstarttime)) \
|
- |
|
1017 |
FROM radacct \
|
- |
|
1018 |
WHERE username='%{\${key}}' \
|
- |
|
1019 |
ORDER BY acctstarttime \
|
- |
|
1020 |
LIMIT 1),0)"
|
- |
|
1021 |
EOF
|
- |
|
1022 |
# make certain that mysql is up before freeradius start
|
990 |
# make certain that mysql is up before freeradius start
|
1023 |
[ -e /lib/systemd/system/radiusd.service.default ] || cp /lib/systemd/system/radiusd.service /lib/systemd/system/radiusd.service.default
|
991 |
[ -e /lib/systemd/system/radiusd.service.default ] || cp /lib/systemd/system/radiusd.service /lib/systemd/system/radiusd.service.default
|
1024 |
$SED "s?^After=.*?After=syslog.target network.target mysqld.service?g" /lib/systemd/system/radiusd.service
|
992 |
$SED "s?^After=.*?After=syslog.target network.target mysqld.service?g" /lib/systemd/system/radiusd.service
|
1025 |
/usr/bin/systemctl daemon-reload
|
993 |
/usr/bin/systemctl daemon-reload
|
1026 |
# Allow apache to change some conf files (ie : ldap on/off)
|
994 |
# Allow apache to change some conf files (ie : ldap on/off)
|
1027 |
chgrp apache /etc/raddb /etc/raddb/sites-available /etc/raddb/mods-available
|
995 |
chgrp apache /etc/raddb /etc/raddb/sites-available /etc/raddb/mods-available
|
1028 |
|
996 |
|
1029 |
} # End freeradius ()
|
997 |
} # End freeradius ()
|
1030 |
|
998 |
|
1031 |
#############################################################################
|
999 |
#############################################################################
|
1032 |
## Function "chilli" ##
|
1000 |
## Function "chilli" ##
|