Line 1... |
Line 1... |
1 |
#!/bin/bash
|
1 |
#!/bin/bash
|
2 |
# $Id: alcasar.sh 2521 2018-04-02 19:46:16Z armand.ito $
|
2 |
# $Id: alcasar.sh 2541 2018-05-03 22:16:31Z rexy $
|
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 859... |
Line 859... |
859 |
chown -R ntp:ntp /var/lib/ntp
|
859 |
chown -R ntp:ntp /var/lib/ntp
|
860 |
# Synchronize now
|
860 |
# Synchronize now
|
861 |
ntpd -q -g &
|
861 |
ntpd -q -g &
|
862 |
} # End of time_server ()
|
862 |
} # End of time_server ()
|
863 |
|
863 |
|
864 |
##########################################################################################
|
864 |
#####################################################################
|
865 |
## Fonction "init_db" ##
|
865 |
## Function "init_db" ##
|
866 |
## - Initialisation de la base Mysql ##
|
866 |
## - Mysql initialization ##
|
867 |
## - Affectation du mot de passe de l'administrateur (root) ##
|
867 |
## - Set admin (root) password ##
|
868 |
## - Suppression des bases et des utilisateurs superflus ##
|
868 |
## - Remove unused users & databases ##
|
869 |
## - Création de la base 'radius' ##
|
- |
|
870 |
## - Installation du schéma de cette base ##
|
869 |
## - Radius database creation ##
|
871 |
## - Import des tables de comptabilité (mtotacct, totacct) et info_usagers (userinfo) ##
|
870 |
## - Copy of accounting tables (mtotacct, totacct) & userinfo ##
|
872 |
## ces table proviennent de 'dialupadmin' (paquetage freeradius-web) ##
|
- |
|
873 |
##########################################################################################
|
871 |
#####################################################################
|
874 |
init_db ()
|
872 |
init_db ()
|
875 |
{
|
873 |
{
|
876 |
if [ `systemctl is-active mysqld` == "active" ]
|
874 |
if [ `systemctl is-active mysqld` == "active" ]
|
877 |
then
|
875 |
then
|
878 |
systemctl stop mysqld
|
876 |
systemctl stop mysqld
|
Line 1026... |
Line 1024... |
1026 |
chgrp apache /etc/raddb /etc/raddb/sites-available /etc/raddb/mods-available
|
1024 |
chgrp apache /etc/raddb /etc/raddb/sites-available /etc/raddb/mods-available
|
1027 |
|
1025 |
|
1028 |
} # End freeradius ()
|
1026 |
} # End freeradius ()
|
1029 |
|
1027 |
|
1030 |
#############################################################################
|
1028 |
#############################################################################
|
1031 |
## Fonction "chilli" ##
|
1029 |
## Function "chilli" ##
|
1032 |
## - Creation of the conf file and init file (systemd) for coova-chilli ##
|
1030 |
## - Creation of the conf file and init file (systemd) for coova-chilli ##
|
1033 |
## - Adapt the authentication web page (intercept.php) ##
|
1031 |
## - Adapt the authentication web page (intercept.php) ##
|
1034 |
#############################################################################
|
1032 |
#############################################################################
|
1035 |
chilli ()
|
1033 |
chilli ()
|
1036 |
{
|
1034 |
{
|
Line 1222... |
Line 1220... |
1222 |
fi
|
1220 |
fi
|
1223 |
groupadd -f chilli
|
1221 |
groupadd -f chilli
|
1224 |
useradd -r -g chilli -s /bin/false -c "system user for coova-chilli" chilli
|
1222 |
useradd -r -g chilli -s /bin/false -c "system user for coova-chilli" chilli
|
1225 |
} # End of chilli ()
|
1223 |
} # End of chilli ()
|
1226 |
|
1224 |
|
1227 |
##################################################################
|
1225 |
################################################################
|
1228 |
## Function "e2guardian" ##
|
1226 |
## Function "e2guardian" ##
|
1229 |
## - Set the parameters of this HTML proxy (as controler) ##
|
1227 |
## - Set the parameters of this HTML proxy (as controler) ##
|
1230 |
##################################################################
|
1228 |
################################################################
|
1231 |
e2guardian ()
|
1229 |
e2guardian ()
|
1232 |
{
|
1230 |
{
|
1233 |
mkdir -p /var/e2guardian /var/log/e2guardian
|
1231 |
mkdir -p /var/e2guardian /var/log/e2guardian
|
1234 |
chown -R e2guardian /var/e2guardian /var/log/e2guardian
|
1232 |
chown -R e2guardian /var/e2guardian /var/log/e2guardian
|
1235 |
$SED "s?^ExecStart=.*?ExecStart=/usr/sbin/e2guardian -c /etc/e2guardian/e2guardian.conf?g" /lib/systemd/system/e2guardian.service
|
1233 |
$SED "s?^ExecStart=.*?ExecStart=/usr/sbin/e2guardian -c /etc/e2guardian/e2guardian.conf?g" /lib/systemd/system/e2guardian.service
|
Line 1493... |
Line 1491... |
1493 |
rm -rf /tmp/nfsen-*
|
1491 |
rm -rf /tmp/nfsen-*
|
1494 |
rm -rf /tmp/SURFmap*
|
1492 |
rm -rf /tmp/SURFmap*
|
1495 |
} # End of nfsen ()
|
1493 |
} # End of nfsen ()
|
1496 |
|
1494 |
|
1497 |
##################################################
|
1495 |
##################################################
|
1498 |
## Function "vnstat" ##
|
1496 |
## Function "vnstat" ##
|
1499 |
## Initialization of Vnstat and vnstat phpFE ##
|
1497 |
## - Initialization of Vnstat and vnstat phpFE ##
|
1500 |
##################################################
|
1498 |
##################################################
|
1501 |
vnstat ()
|
1499 |
vnstat ()
|
1502 |
{
|
1500 |
{
|
1503 |
[ -e /etc/vnstat.conf.default ] || cp /etc/vnstat.conf /etc/vnstat.conf.default
|
1501 |
[ -e /etc/vnstat.conf.default ] || cp /etc/vnstat.conf /etc/vnstat.conf.default
|
1504 |
$SED "s?Interface.*?Interface \"$EXTIF\"?g" /etc/vnstat.conf
|
1502 |
$SED "s?Interface.*?Interface \"$EXTIF\"?g" /etc/vnstat.conf
|
Line 1506... |
Line 1504... |
1506 |
$SED "s?\$iface_list =.*?\$iface_list = array('$EXTIF');?" $DIR_ACC/manager/stats/config.php
|
1504 |
$SED "s?\$iface_list =.*?\$iface_list = array('$EXTIF');?" $DIR_ACC/manager/stats/config.php
|
1507 |
$SED "s?\$iface_title\['.*?\$iface_title\['$EXTIF'\] = \$title;?" $DIR_ACC/manager/stats/config.php
|
1505 |
$SED "s?\$iface_title\['.*?\$iface_title\['$EXTIF'\] = \$title;?" $DIR_ACC/manager/stats/config.php
|
1508 |
/usr/bin/vnstat -u -i $EXTIF
|
1506 |
/usr/bin/vnstat -u -i $EXTIF
|
1509 |
} # End of vnstat
|
1507 |
} # End of vnstat
|
1510 |
|
1508 |
|
1511 |
##################################################
|
1509 |
################################################################
|
1512 |
## Function "dnsmasq" ##
|
1510 |
## Function "dnsmasq" ##
|
- |
|
1511 |
## - creation of the conf files of the 4 intances of dnsmasq ##
|
1513 |
##################################################
|
1512 |
################################################################
|
1514 |
dnsmasq ()
|
1513 |
dnsmasq ()
|
1515 |
{
|
1514 |
{
|
1516 |
[ -d /var/log/dnsmasq ] || mkdir /var/log/dnsmasq
|
1515 |
[ -d /var/log/dnsmasq ] || mkdir /var/log/dnsmasq
|
1517 |
# 1st dnsmasq listen on udp 53 ("dnsmasq - forward"). It's used as dhcp server only if "alcasar-bypass" is on.
|
1516 |
# 1st dnsmasq listen on udp 53 ("dnsmasq - forward"). It's used as dhcp server only if "alcasar-bypass" is on.
|
1518 |
[ -e /etc/dnsmasq.conf.default ] || cp /etc/dnsmasq.conf /etc/dnsmasq.conf.default
|
1517 |
[ -e /etc/dnsmasq.conf.default ] || cp /etc/dnsmasq.conf /etc/dnsmasq.conf.default
|
Line 1615... |
Line 1614... |
1615 |
$SED "s?^ExecStart=.*?ExecStart=/usr/sbin/dnsmasq -C /etc/dnsmasq-$list.conf?g" /lib/systemd/system/dnsmasq-$list.service
|
1614 |
$SED "s?^ExecStart=.*?ExecStart=/usr/sbin/dnsmasq -C /etc/dnsmasq-$list.conf?g" /lib/systemd/system/dnsmasq-$list.service
|
1616 |
$SED "s?^PIDFile=.*?PIDFile=/var/run/dnsmasq-$list.pid?g" /lib/systemd/system/dnsmasq-$list.service
|
1615 |
$SED "s?^PIDFile=.*?PIDFile=/var/run/dnsmasq-$list.pid?g" /lib/systemd/system/dnsmasq-$list.service
|
1617 |
done
|
1616 |
done
|
1618 |
} # End dnsmasq
|
1617 |
} # End dnsmasq
|
1619 |
|
1618 |
|
1620 |
##########################################################
|
1619 |
#######################################################
|
1621 |
## Fonction "BL" ##
|
1620 |
## Function "BL" ##
|
1622 |
##########################################################
|
1621 |
#######################################################
|
1623 |
BL ()
|
1622 |
BL ()
|
1624 |
{
|
1623 |
{
|
1625 |
# copy the Toulouse university BL in order to be adapted to ALCASAR architecture (alcasar-bl.sh -adapt)
|
1624 |
# copy the Toulouse university BL in order to be adapted to ALCASAR architecture (alcasar-bl.sh -adapt)
|
1626 |
rm -rf $DIR_DG/lists/blacklists
|
1625 |
rm -rf $DIR_DG/lists/blacklists
|
1627 |
mkdir -p /tmp/blacklists
|
1626 |
mkdir -p /tmp/blacklists
|
Line 1675... |
Line 1674... |
1675 |
# enable the default categories
|
1674 |
# enable the default categories
|
1676 |
$DIR_DEST_BIN/alcasar-bl.sh --cat_choice
|
1675 |
$DIR_DEST_BIN/alcasar-bl.sh --cat_choice
|
1677 |
} # End BL()
|
1676 |
} # End BL()
|
1678 |
|
1677 |
|
1679 |
##########################################################
|
1678 |
##########################################################
|
1680 |
## Fonction "cron" ##
|
- |
|
1681 |
## - Mise en place des différents fichiers de cron ##
|
1679 |
## Function "cron" ##
|
1682 |
##########################################################
|
1680 |
##########################################################
|
1683 |
cron ()
|
1681 |
cron ()
|
1684 |
{
|
1682 |
{
|
1685 |
# Modif du fichier 'crontab' pour passer les cron à minuit au lieu de 04h00
|
1683 |
# Modif du fichier 'crontab' pour passer les cron à minuit au lieu de 04h00
|
1686 |
[ -e /etc/crontab.default ] || cp /etc/crontab /etc/crontab.default
|
1684 |
[ -e /etc/crontab.default ] || cp /etc/crontab /etc/crontab.default
|
Line 2136... |
Line 2134... |
2136 |
echo "- The ALCASAR Control Center (ACC) is at http://alcasar.localdomain"
|
2134 |
echo "- The ALCASAR Control Center (ACC) is at http://alcasar.localdomain"
|
2137 |
echo
|
2135 |
echo
|
2138 |
echo " Hit 'Enter' to continue"
|
2136 |
echo " Hit 'Enter' to continue"
|
2139 |
fi
|
2137 |
fi
|
2140 |
sleep 2
|
2138 |
sleep 2
|
2141 |
if [ "$mode" != "update" ]
|
2139 |
if [ "$mode" != "update" ] && [ "$DEBUG_ALCASAR" != "on" ]
|
2142 |
then
|
2140 |
then
|
2143 |
read a
|
2141 |
read a
|
2144 |
fi
|
2142 |
fi
|
2145 |
clear
|
2143 |
clear
|
2146 |
reboot
|
2144 |
reboot
|