Subversion Repositories ALCASAR

Compare Revisions

Regard whitespace Rev 2552 → Rev 2549

/alcasar.sh
116,13 → 116,13
echo "-----------------------------------------------------------------------------"
}
 
########################################################
##################################################################
## Function "testing" ##
## - Test Mageia version ##
## - Test ALCASAR version (if already installed) ##
## - Test free space on /var (>10G) ##
## - Test Internet access ##
########################################################
## - Test of Mageia version ##
## - Test of ALCASAR version (if already installed) ##
## - Test of free space on /var (>10G) ##
## - Test of Internet access ##
##################################################################
testing ()
{
# Test of Mageia version
359,11 → 359,11
echo ". : ok"
} # end of testing ()
 
#######################################################################
##################################################################
## Function "init" ##
## - Creation of ALCASAR conf file "/usr/local/etc/alcasar.conf ##
## - Creation of random password for GRUB, mariadb (admin and user) ##
#######################################################################
## - Création du fichier "/root/ALCASAR_parametres.tx ##
## - Installation et modification des scripts du portail ##
##################################################################
init ()
{
if [ "$mode" != "update" ]
437,14 → 437,14
chmod o-rwx $CONF_FILE
} # End of init ()
 
#########################################################
##################################################################
## Function "network" ##
## - Define the several network address ##
## - Define the DNS naming ##
## - INTIF parameters (consultation network) ##
## - Write "/etc/hosts" file ##
## - write "hosts.allow" & "hosts.deny" files ##
#########################################################
## - Définition du plan d'adressage du réseau de consultation ##
## - Nommage DNS du système ##
## - Configuration de l'interface INTIF (réseau de consultation)##
## - Modification du fichier /etc/hosts ##
## - Renseignement des fichiers hosts.allow et hosts.deny ##
##################################################################
network ()
{
header_install
531,11 → 531,12
PUBLIC_NETMASK=`/bin/ipcalc -m $PUBLIC_IP_MASK | cut -d"=" -f2`
PUBLIC_PREFIX=`/bin/ipcalc -p $PUBLIC_IP $PUBLIC_NETMASK|cut -d"=" -f2`
PUBLIC_NETWORK=`/bin/ipcalc -n $PUBLIC_IP/$PUBLIC_PREFIX|cut -d"=" -f2`
# Write network parameters in the conf file
# Wrtie the conf file
echo "EXTIF=$EXTIF" >> $CONF_FILE
echo "INTIF=$INTIF" >> $CONF_FILE
######## Récupération des interfaces du ou des réseaux de consultation supplémentaires #################
INTERFACES=`/usr/sbin/ip link|grep '^[[:digit:]]:'|grep -v "^lo\|$EXTIF\|tun0"|cut -d " " -f2|tr -d ":"`
 
for i in $INTERFACES
do
SUB=`echo ${i:0:2}`
545,6 → 546,7
then LANIF=$i
fi
done
 
if [ -n "$WIFIF" ]
then echo "WIFIF=$WIFIF" >> $CONF_FILE
elif [ -n "$LANIF" ]
551,7 → 553,8
then echo "LANIF=$LANIF" >> $CONF_FILE
fi
#########################################################################################################
IP_SETTING=`grep BOOTPROTO /etc/sysconfig/network-scripts/ifcfg-$EXTIF|cut -d"=" -f2` # test static or dynamic
 
IP_SETTING=`grep BOOTPROTO /etc/sysconfig/network-scripts/ifcfg-$EXTIF|cut -d"=" -f2` # IP setting (static or dynamic)
if [ $IP_SETTING == "dhcp" ]
then
echo "PUBLIC_IP=dhcp" >> $CONF_FILE
577,13 → 580,13
NETWORKING=yes
FORWARD_IPV4=true
EOF
# write "/etc/hosts"
# /etc/hosts config
[ -e /etc/hosts.default ] || cp /etc/hosts /etc/hosts.default
cat <<EOF > /etc/hosts
127.0.0.1 localhost
$PRIVATE_IP $HOSTNAME.$DOMAIN $HOSTNAME
EOF
# write EXTIF (Internet) config
# EXTIF (Internet) config
[ -e /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF ] || cp /etc/sysconfig/network-scripts/ifcfg-$EXTIF /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF
if [ $IP_SETTING == "dhcp" ]
then
623,7 → 626,7
MTU=$MTU
EOF
fi
# write INTIF (consultation LAN) in normal mode
# Config INTIF (consultation LAN) in normal mode
cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-$INTIF
DEVICE=$INTIF
BOOTPROTO=static
636,7 → 639,7
USERCTL=no
EOF
cp -f /etc/sysconfig/network-scripts/ifcfg-$INTIF /etc/sysconfig/network-scripts/default-ifcfg-$INTIF
# write INTIF in bypass mode (see "alcasar-bypass.sh")
# Config of INTIF in bypass mode (see "alcasar-bypass.sh")
cat <<EOF > /etc/sysconfig/network-scripts/bypass-ifcfg-$INTIF
DEVICE=$INTIF
BOOTPROTO=static
680,7 → 683,7
EOF
fi
#########################################################################################################
# write hosts.allow & hosts.deny
# Renseignement des fichiers hosts.allow et hosts.deny
[ -e /etc/hosts.allow.default ] || cp /etc/hosts.allow /etc/hosts.allow.default
cat <<EOF > /etc/hosts.allow
ALL: LOCAL, 127.0.0.1, localhost, $PRIVATE_IP
708,13 → 711,13
# the script "$DIR_DEST_BIN/alcasar-iptables.sh" is launched at the end in order to allow update via ssh
} # End of network ()
 
###################################################
##################################################################
## Function "ACC" ##
## - copy ALCASAR Control Center (ACC) files ##
## - installation of then ALCASAR Control Center (ACC) ) ##
## - configuration of the web server (Lighttpd) ##
## - creation of the first ACC admin account ##
## - secure the ACC access ##
###################################################
## - secure the access ##
##################################################################
ACC ()
{
[ -d $DIR_WEB ] && rm -rf $DIR_WEB
793,7 → 796,7
/usr/bin/systemctl start lighttpd
/usr/bin/systemctl start php-fpm
 
# Creation of the first account (in 'admin' profile)
# Définition du premier compte lié au profil 'admin'
if [ "$mode" = "install" ]
then
header_install
815,10 → 818,10
chmod 664 /var/Save/security/acc_access.log
} # End of ACC ()
 
##################################################################
##########################################################################
## Fonction "CA" ##
## - Creating the CA and the server certificate (lighttpd) ##
##################################################################
##########################################################################
CA ()
{
$DIR_DEST_BIN/alcasar-CA.sh
827,10 → 830,10
chmod -R 750 /etc/pki
} # End of CA ()
 
#############################################################
##################################################################
## Function "time_server" ##
## - Configuring NTP server ##
#############################################################
##################################################################
time_server ()
{
# Set the Internet time server
1336,7 → 1339,7
 
################################################################################
## Function "tinyproxy" ##
## - Set the parameters of tinyproxy (proxy between filtered users and havp) ##
## - Set the parameters of tinyproxy (proxy between filterde users and havp) ##
################################################################################
tinyproxy ()
{
1489,10 → 1492,10
rm -rf /tmp/SURFmap*
} # End of nfsen ()
 
###########################################################
##################################################
## Function "vnstat" ##
## - Initialization of Vnstat and vnstat phpFrontEnd ##
###########################################################
## - Initialization of Vnstat and vnstat phpFE ##
##################################################
vnstat ()
{
[ -e /etc/vnstat.conf.default ] || cp /etc/vnstat.conf /etc/vnstat.conf.default
1613,14 → 1616,9
done
} # End dnsmasq
 
##########################################################
#######################################################
## Function "BL" ##
## - copy Toulouse BL ##
## - adapt this BL to ALCASAR architecture ##
## - domain names for dnsmasq-bl & dnasmasq-wl ##
## - URLs for E²guardian ##
## - IPs for NetFilter ##
##########################################################
#######################################################
BL ()
{
# copy the Toulouse university BL in order to be adapted to ALCASAR architecture (alcasar-bl.sh -adapt)
1677,10 → 1675,9
$DIR_DEST_BIN/alcasar-bl.sh --cat_choice
} # End BL()
 
#######################################################
##########################################################
## Function "cron" ##
## - write all cron & anacron files ##
#######################################################
##########################################################
cron ()
{
# Modif du fichier 'crontab' pour passer les cron à minuit au lieu de 04h00
1767,11 → 1764,11
rm -f /var/spool/cron/*
} # End cron()
 
######################################################################
##################################################################
## Fonction "Fail2Ban" ##
##- Adapt conf file to ALCASAR ##
##- Secure items : DDOS, SSH-Brute-Force, Intercept.php Brute-Force ##
######################################################################
##- Modification de la configuration de fail2ban ##
##- Sécurisation DDOS, SSH-Brute-Force, Intercept.php ... ##
##################################################################
fail2ban()
{
/usr/bin/sh $DIR_CONF/fail2ban.sh
1788,11 → 1785,11
$SED '/After=*/c After=syslog.target network.target lighttpd.service' /usr/lib/systemd/system/fail2ban.service
} # End fail2ban()
 
#########################################################
##################################################################
## Fonction "gammu_smsd" ##
## - Creating of SMS management database ##
## - Write the gammu a gammu_smsd conf files ##
#########################################################
## - Creation de la base de donnée Gammu ##
## - Creation du fichier de config: gammu_smsd_conf ##
##################################################################
gammu_smsd()
{
# Create 'gammu' databse
1801,20 → 1798,18
# Add a gammu database structure
mysql -u$DB_USER -p$radiuspwd $DB_GAMMU < $DIR_CONF/empty-gammu-smsd-db.sql
 
# Config file for the gammu_smsd daemon & gammu (ttyUSB0 as default com port)
cat << EOF > /etc/gammurc
[gammu]
device = /dev/ttyUSB0
connection = at115200
EOF
 
# Config file for the daemon
cat << EOF > /etc/gammu_smsd_conf
[gammu]
port = /dev/ttyUSB0
connection = at115200
 
;########################################################
 
[smsd]
 
PIN = 1234
 
logfile = /var/log/gammu-smsd/gammu-smsd.log
logformat = textall
debuglevel = 0
1839,7 → 1834,7
CheckBattery = 0
EOF
 
chmod 755 /etc/gammu_smsd_conf /etc/gammurc
chmod 755 /etc/gammu_smsd_conf
 
# Log folder for gammu-smsd
[ -e /var/log/gammu-smsd ] || mkdir /var/log/gammu-smsd
1849,23 → 1844,21
$SED "s/^u_db=\".*/u_db=\"$DB_USER\"/g" $DIR_DEST_BIN/alcasar-sms.sh
$SED "s/^p_db=\".*/p_db=\"$radiuspwd\"/g" $DIR_DEST_BIN/alcasar-sms.sh
 
# Udev rule for Modeswitch (switch from "mass_storage" mode to "ttyUSB" modem) needed with some Huawei MODEM (idVendor: 12d1)
# normally not needed now since modeswitch is managed by udev (see Mageia RPM)
# Udev rule for Huawei GSM MODEM (idVendor: 12d1) --> run "modeswitch" to switch from "mass_storage" mode to "ttyUSB" (modem) mode
# normally not needed now since modeswitch is managed by udev (see RPM)
#cat << EOF > /lib/udev/rules.d/66-huawei.rules
#KERNEL=="ttyUSB0",ATTRS{idVendor}=="12d1",RUN+="$DIR_DEST_BIN/alcasar-sms.sh --mode"
#EOF
 
# Udev rule for fixing the enumeration of ttyUSB port on some MODEM (when they switch randomly the order of their ports at boot time)
# example : http://hintshop.ludvig.co.nz/show/persistent-names-usb-serial-devices/
 
} # End gammu_smsd()
 
############################################################
 
##################################################################
## Fonction "msec" ##
## - Apply the "fileserver" security level ##
## - remove the "system request" for rebboting ##
## - Fix several file permissions ##
############################################################
##################################################################
msec()
{
 
1953,7 → 1946,7
## - sudoers config & files security ##
## - log rotate & ANSSI security parameters ##
## - Apply former conf in case of an update ##
##################################################################
##########################################################
post_install()
{
# change the SSH banner
2152,9 → 2145,9
reboot
} # End post_install ()
 
#####################################################################################
#################################
# Main Install loop #
#####################################################################################
#################################
dir_exec=`dirname "$0"`
if [ $dir_exec != "." ]
then