Line 1... |
Line 1... |
1 |
#!/bin/bash
|
1 |
#!/bin/bash
|
2 |
# $Id: alcasar.sh 2421 2017-10-08 21:57:57Z richard $
|
2 |
# $Id: alcasar.sh 2422 2017-10-09 22:10:48Z richard $
|
3 |
|
3 |
|
4 |
# alcasar.sh
|
4 |
# alcasar.sh
|
5 |
|
5 |
|
6 |
# ALCASAR Install script - CopyLeft ALCASAR Team [Rexy + 3abtux + Steweb + Crox + ...]
|
6 |
# ALCASAR Install script - CopyLeft ALCASAR Team [Rexy + 3abtux + Steweb + Crox + ...]
|
7 |
# Ce programme est un logiciel libre ; This software is free and open source
|
7 |
# Ce programme est un logiciel libre ; This software is free and open source
|
Line 1095... |
Line 1095... |
1095 |
chmod 660 /etc/raddb/sites-available/alcasar
|
1095 |
chmod 660 /etc/raddb/sites-available/alcasar
|
1096 |
ln -s /etc/raddb/sites-available/alcasar /etc/raddb/sites-enabled/alcasar
|
1096 |
ln -s /etc/raddb/sites-available/alcasar /etc/raddb/sites-enabled/alcasar
|
1097 |
# INFO : To connect from outside (EAP), add the EAP virtual server (link in sites-enabled) and inner-tunnel modules (link in mods-enabled)
|
1097 |
# INFO : To connect from outside (EAP), add the EAP virtual server (link in sites-enabled) and inner-tunnel modules (link in mods-enabled)
|
1098 |
|
1098 |
|
1099 |
# Set modules
|
1099 |
# Set modules
|
1100 |
# Set only usefull modules for ALCASAR
|
1100 |
# Set only usefull modules for ALCASAR (ldap is enabled only via ACC)
|
1101 |
rm -rf /etc/raddb/mods-enabled/*
|
1101 |
rm -rf /etc/raddb/mods-enabled/*
|
1102 |
for mods in sql sqlcounter attr_filter expiration logintime ldap pap
|
1102 |
for mods in sql sqlcounter attr_filter expiration logintime pap
|
1103 |
do
|
1103 |
do
|
1104 |
ln -s /etc/raddb/mods-available/$mods /etc/raddb/mods-enabled/$mods
|
1104 |
ln -s /etc/raddb/mods-available/$mods /etc/raddb/mods-enabled/$mods
|
1105 |
done
|
1105 |
done
|
1106 |
# Configure SQL mod (TODO :and SQL counter)
|
1106 |
# Configure SQL mod (TODO :and SQL counter)
|
1107 |
[ -e /etc/raddb/mods-available/sql.default ] || cp /etc/raddb/mods-available/sql /etc/raddb/mods-available/sql.default
|
1107 |
[ -e /etc/raddb/mods-available/sql.default ] || cp /etc/raddb/mods-available/sql /etc/raddb/mods-available/sql.default
|
Line 1125... |
Line 1125... |
1125 |
cp -f $DIR_CONF/radius/queries.conf /etc/raddb/mods-config/sql/main/mysql/queries.conf
|
1125 |
cp -f $DIR_CONF/radius/queries.conf /etc/raddb/mods-config/sql/main/mysql/queries.conf
|
1126 |
chown -R radius:radius /etc/raddb/mods-config/sql/main/mysql/queries.conf
|
1126 |
chown -R radius:radius /etc/raddb/mods-config/sql/main/mysql/queries.conf
|
1127 |
# sqlcounter modifications
|
1127 |
# sqlcounter modifications
|
1128 |
[ -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
|
1128 |
[ -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
|
1129 |
cat << EOF > /etc/raddb/mods-config/sql/counter/mysql/dailycounter.conf
|
1129 |
cat << EOF > /etc/raddb/mods-config/sql/counter/mysql/dailycounter.conf
|
- |
|
1130 |
query = "\
|
1130 |
query = "SELECT IFNULL((SELECT SUM(acctsessiontime - \
|
1131 |
SELECT IFNULL((SELECT SUM(acctsessiontime - GREATEST((%%b - UNIX_TIMESTAMP(acctstarttime)),0)) \
|
1131 |
GREATEST((%b - UNIX_TIMESTAMP(acctstarttime)),0)) \
|
1132 |
FROM radacct \
|
1132 |
FROM radacct WHERE username = '%{${key}}' AND \
|
1133 |
WHERE username = '%{\${key}}' \
|
1133 |
UNIX_TIMESTAMP(acctstarttime) + acctsessiontime > '%b'),0)"
|
1134 |
AND UNIX_TIMESTAMP(acctstarttime) + acctsessiontime > '%%b'),0)"
|
1134 |
EOF
|
1135 |
EOF
|
1135 |
[ -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
|
1136 |
[ -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
|
1136 |
cat << EOF > /etc/raddb/mods-config/sql/counter/mysql/monthlycounter.conf
|
1137 |
cat << EOF > /etc/raddb/mods-config/sql/counter/mysql/monthlycounter.conf
|
1137 |
query = "SELECT IFNULL((SELECT SUM(acctsessiontime - \
|
1138 |
query = "\
|
1138 |
GREATEST((%b - UNIX_TIMESTAMP(acctstarttime)), 0)) \
|
1139 |
SELECT IFNULL((SELECT SUM(acctsessiontime - GREATEST((%%b - UNIX_TIMESTAMP(acctstarttime)), 0)) \
|
- |
|
1140 |
FROM radacct \
|
1139 |
FROM radacct WHERE username='%{${key}}' AND \
|
1141 |
WHERE username='%{\${key}}' \
|
1140 |
UNIX_TIMESTAMP(acctstarttime) + acctsessiontime > '%b'),0)"
|
1142 |
AND UNIX_TIMESTAMP(acctstarttime) + acctsessiontime > '%%b'),0)"
|
1141 |
EOF
|
1143 |
EOF
|
1142 |
[ -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
|
1144 |
[ -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
|
1143 |
cat << EOF > /etc/raddb/mods-config/sql/counter/mysql/noresetcounter.conf
|
1145 |
cat << EOF > /etc/raddb/mods-config/sql/counter/mysql/noresetcounter.conf
|
1144 |
# This is the query modified for ALCASAR needs (thanks to Daniel Laliberte --> authorized period after the first connection)
|
1146 |
# This is the query modified for ALCASAR needs (thanks to Daniel Laliberte --> authorized period after the first connection)
|
- |
|
1147 |
query = "\
|
1145 |
query = "SELECT IFNULL((SELECT TIME_TO_SEC(TIMEDIFF(NOW(), acctstarttime)) \
|
1148 |
SELECT IFNULL((SELECT TIME_TO_SEC(TIMEDIFF(NOW(), acctstarttime)) \
|
1146 |
FROM radacct \
|
1149 |
FROM radacct \
|
1147 |
WHERE UserName='%{${key}}' \
|
1150 |
WHERE UserName='%{\${key}}' \
|
1148 |
ORDER BY acctstarttime \
|
1151 |
ORDER BY acctstarttime \
|
1149 |
LIMIT 1),0)"
|
1152 |
LIMIT 1),0)"
|
1150 |
EOF
|
1153 |
EOF
|
1151 |
# make certain that mysql is up before freeradius start
|
1154 |
# make certain that mysql is up before freeradius start
|
1152 |
[ -e /lib/systemd/system/radiusd.service.default ] || cp /lib/systemd/system/radiusd.service /lib/systemd/system/radiusd.service.default
|
1155 |
[ -e /lib/systemd/system/radiusd.service.default ] || cp /lib/systemd/system/radiusd.service /lib/systemd/system/radiusd.service.default
|