Subversion Repositories ALCASAR

Rev

Rev 2308 | Rev 2324 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log

Rev 2308 Rev 2314
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
#  $Id: alcasar.sh 2308 2017-06-26 14:30:48Z tom.houdayer $ 
2
#  $Id: alcasar.sh 2314 2017-06-28 10:26:30Z 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 1765... Line 1765...
1765
	chmod -R g+rw $DIR_DG $DIR_DEST_SHARE
1765
	chmod -R g+rw $DIR_DG $DIR_DEST_SHARE
1766
# adapt the Toulouse BL to ALCASAR architecture
1766
# adapt the Toulouse BL to ALCASAR architecture
1767
	$DIR_DEST_BIN/alcasar-bl.sh --adapt
1767
	$DIR_DEST_BIN/alcasar-bl.sh --adapt
1768
# enable the default categories
1768
# enable the default categories
1769
	$DIR_DEST_BIN/alcasar-bl.sh --cat_choice
1769
	$DIR_DEST_BIN/alcasar-bl.sh --cat_choice
1770
}
1770
} # End BL()
1771
 
1771
 
1772
##########################################################
1772
##########################################################
1773
##		Fonction "cron"				##
1773
##		Fonction "cron"				##
1774
## - Mise en place des différents fichiers de cron	##
1774
## - Mise en place des différents fichiers de cron	##
1775
##########################################################
1775
##########################################################
Line 1855... Line 1855...
1855
@daily root $DIR_DEST_BIN/alcasar-letsencrypt.sh --cron > /dev/null 2>&1
1855
@daily root $DIR_DEST_BIN/alcasar-letsencrypt.sh --cron > /dev/null 2>&1
1856
EOF
1856
EOF
1857
 
1857
 
1858
# removing the users crons
1858
# removing the users crons
1859
	rm -f /var/spool/cron/*
1859
	rm -f /var/spool/cron/*
1860
} # End cron
1860
} # End cron()
1861
 
1861
 
1862
##################################################################
1862
##################################################################
1863
## 			Fonction "Fail2Ban"			##
1863
## 			Fonction "Fail2Ban"			##
1864
##- Modification de la configuration de fail2ban		##
1864
##- Modification de la configuration de fail2ban		##
1865
##- Sécurisation DDOS, SSH-Brute-Force, Intercept.php ...	##
1865
##- Sécurisation DDOS, SSH-Brute-Force, Intercept.php ...	##
Line 1876... Line 1876...
1876
# fail2ban unit
1876
# fail2ban unit
1877
[ -e /lib/systemd/system/fail2ban.service.default ] || cp /lib/systemd/system/fail2ban.service /lib/systemd/system/fail2ban.service.default
1877
[ -e /lib/systemd/system/fail2ban.service.default ] || cp /lib/systemd/system/fail2ban.service /lib/systemd/system/fail2ban.service.default
1878
$SED '/ExecStart=/a\ExecStop=/usr/bin/fail2ban-client stop' /usr/lib/systemd/system/fail2ban.service
1878
$SED '/ExecStart=/a\ExecStop=/usr/bin/fail2ban-client stop' /usr/lib/systemd/system/fail2ban.service
1879
$SED '/Type=/a\PIDFile=/var/run/fail2ban/fail2ban.pid' /usr/lib/systemd/system/fail2ban.service
1879
$SED '/Type=/a\PIDFile=/var/run/fail2ban/fail2ban.pid' /usr/lib/systemd/system/fail2ban.service
1880
$SED '/After=*/c After=syslog.target network.target httpd.service' /usr/lib/systemd/system/fail2ban.service
1880
$SED '/After=*/c After=syslog.target network.target httpd.service' /usr/lib/systemd/system/fail2ban.service
1881
} #Fin de fail2ban_install()
1881
} # End fail2ban()
1882
 
1882
 
1883
##################################################################
1883
##################################################################
1884
## 			Fonction "gammu_smsd"			##
1884
## 			Fonction "gammu_smsd"			##
1885
## - Creation de la base de donnée Gammu			##
1885
## - Creation de la base de donnée Gammu			##
1886
## - Creation du fichier de config: gammu_smsd_conf		##
1886
## - Creation du fichier de config: gammu_smsd_conf		##
Line 1891... Line 1891...
1891
MYSQL="/usr/bin/mysql -uroot -p$mysqlpwd --exec"
1891
MYSQL="/usr/bin/mysql -uroot -p$mysqlpwd --exec"
1892
	$MYSQL="CREATE DATABASE IF NOT EXISTS $DB_GAMMU;GRANT ALL ON $DB_GAMMU.* TO $DB_USER@localhost IDENTIFIED BY '$radiuspwd';FLUSH PRIVILEGES"
1892
	$MYSQL="CREATE DATABASE IF NOT EXISTS $DB_GAMMU;GRANT ALL ON $DB_GAMMU.* TO $DB_USER@localhost IDENTIFIED BY '$radiuspwd';FLUSH PRIVILEGES"
1893
# Add a gammu database structure
1893
# Add a gammu database structure
1894
	mysql -u$DB_USER -p$radiuspwd $DB_GAMMU < $DIR_CONF/empty-gammu-smsd-db.sql
1894
	mysql -u$DB_USER -p$radiuspwd $DB_GAMMU < $DIR_CONF/empty-gammu-smsd-db.sql
1895
 
1895
 
1896
# config file for the daemon
1896
# Config file for the daemon
1897
cat << EOF > /etc/gammu_smsd_conf
1897
cat << EOF > /etc/gammu_smsd_conf
1898
[gammu]
1898
[gammu]
1899
port = /dev/ttyUSB0
1899
port = /dev/ttyUSB0
1900
connection = at115200
1900
connection = at115200
1901
 
1901
 
Line 1929... Line 1929...
1929
CheckBattery = 0
1929
CheckBattery = 0
1930
EOF
1930
EOF
1931
 
1931
 
1932
chmod 755 /etc/gammu_smsd_conf
1932
chmod 755 /etc/gammu_smsd_conf
1933
 
1933
 
1934
#Creation dossier de log Gammu-smsd
1934
# Log folder for gammu-smsd
1935
[ -e /var/log/gammu-smsd ] || mkdir /var/log/gammu-smsd
1935
[ -e /var/log/gammu-smsd ] || mkdir /var/log/gammu-smsd
1936
chmod 755 /var/log/gammu-smsd
1936
chmod 755 /var/log/gammu-smsd
1937
 
1937
 
1938
#Edition du script sql gammu <-> radius
1938
# Write radius credentials in the gammu script
1939
$SED "s/^u_db=\".*/u_db=\"$DB_USER\"/g" $DIR_DEST_BIN/alcasar-sms.sh
1939
$SED "s/^u_db=\".*/u_db=\"$DB_USER\"/g" $DIR_DEST_BIN/alcasar-sms.sh
1940
$SED "s/^p_db=\".*/p_db=\"$radiuspwd\"/g" $DIR_DEST_BIN/alcasar-sms.sh
1940
$SED "s/^p_db=\".*/p_db=\"$radiuspwd\"/g" $DIR_DEST_BIN/alcasar-sms.sh
1941
 
1941
 
1942
#Création de la règle udev pour les Huawei // idVendor: 12d1
1942
# Udev rule for Huawei GSM MODEM (idVendor: 12d1) --> run "modeswitch" to switch from "mass_storage" mode to "ttyUSB" (modem) mode
1943
cat << EOF > /etc/udev/rules.d/66-huawei.rules
1943
cat << EOF > /lib/udev/rules.d/66-huawei.rules
1944
KERNEL=="ttyUSB0",ATTRS{idVendor}=="12d1",RUN+="$DIR_DEST_BIN/alcasar-sms.sh --mode"
1944
KERNEL=="ttyUSB0",ATTRS{idVendor}=="12d1",RUN+="$DIR_DEST_BIN/alcasar-sms.sh --mode"
1945
EOF
1945
EOF
1946
 
1946
 
1947
} # END gammu_smsd()
1947
} # End gammu_smsd()
1948
 
1948
 
1949
 
1949
 
1950
##################################################################
1950
##################################################################
1951
##			Fonction "msec"				##
1951
##			Fonction "msec"				##
1952
## - Apply the "fileserver" security level			##
1952
## - Apply the "fileserver" security level			##
Line 1984... Line 1984...
1984
EOF
1984
EOF
1985
# apply now hourly & daily checks 
1985
# apply now hourly & daily checks 
1986
/usr/sbin/msec
1986
/usr/sbin/msec
1987
/etc/cron.weekly/msec
1987
/etc/cron.weekly/msec
1988
 
1988
 
1989
} # END msec()
1989
} # End msec()
1990
 
1990
 
1991
 
1991
 
1992
##################################################################
1992
##################################################################
1993
##			Fonction "letsencrypt"			##
1993
##			Fonction "letsencrypt"			##
1994
## - Install Let's Encrypt client				##
1994
## - Install Let's Encrypt client				##