Subversion Repositories ALCASAR

Rev

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

Rev 2293 Rev 2304
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
#  $Id: alcasar.sh 2293 2017-06-20 15:31:12Z tom.houdayer $ 
2
#  $Id: alcasar.sh 2304 2017-06-26 12:56:14Z tom.houdayer $ 
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 45... Line 45...
45
#	BL			: Adaptation of Toulouse University BlackList : split into 3 BL (for Dnsmasq, for dansguardian and for Netfilter)
45
#	BL			: Adaptation of Toulouse University BlackList : split into 3 BL (for Dnsmasq, for dansguardian and for Netfilter)
46
#	cron			: Logs export + watchdog + connexion statistics
46
#	cron			: Logs export + watchdog + connexion statistics
47
#	fail2ban		: Fail2ban IDS installation and configuration
47
#	fail2ban		: Fail2ban IDS installation and configuration
48
#	gammu_smsd		: Autoregister addon via SMS (gammu-smsd)
48
#	gammu_smsd		: Autoregister addon via SMS (gammu-smsd)
49
#	msec			: Mandriva security package configuration
49
#	msec			: Mandriva security package configuration
-
 
50
#	letsencrypt		: Let's Encrypt client
50
#	post_install		: Security, log rotation, etc.
51
#	post_install		: Security, log rotation, etc.
51
 
52
 
52
DATE=`date '+%d %B %Y - %Hh%M'`
53
DATE=`date '+%d %B %Y - %Hh%M'`
53
DATE_SHORT=`date '+%d/%m/%Y'`
54
DATE_SHORT=`date '+%d/%m/%Y'`
54
Lang=`echo $LANG|cut -c 1-2`
55
Lang=`echo $LANG|cut -c 1-2`
Line 1846... Line 1847...
1846
	cat << EOF > /etc/cron.d/alcasar-rsync-bl
1847
	cat << EOF > /etc/cron.d/alcasar-rsync-bl
1847
# Automatic update of BL via rsync every 12 hours. The categories are listed in the file '/usr/local/etc/update_cat.conf' (no sync if empty). 
1848
# Automatic update of BL via rsync every 12 hours. The categories are listed in the file '/usr/local/etc/update_cat.conf' (no sync if empty). 
1848
0 */12 * * * root $DIR_DEST_BIN/alcasar-bl.sh --update_cat > /dev/null 2>&1
1849
0 */12 * * * root $DIR_DEST_BIN/alcasar-bl.sh --update_cat > /dev/null 2>&1
1849
EOF
1850
EOF
1850
 
1851
 
-
 
1852
# Renew the Let's Encrypt certificate
-
 
1853
	cat <<EOF > /etc/cron.d/alcasar-letsencrypt
-
 
1854
# Automatic renew of the Let's Encrypt certificate
-
 
1855
@daily root $DIR_DEST_BIN/alcasar-letsencrypt.sh --cron > /dev/null 2>&1
-
 
1856
EOF
-
 
1857
 
1851
# removing the users crons
1858
# removing the users crons
1852
	rm -f /var/spool/cron/*
1859
	rm -f /var/spool/cron/*
1853
} # End cron
1860
} # End cron
1854
 
1861
 
1855
##################################################################
1862
##################################################################
Line 1979... Line 1986...
1979
/usr/sbin/msec
1986
/usr/sbin/msec
1980
/etc/cron.weekly/msec
1987
/etc/cron.weekly/msec
1981
 
1988
 
1982
} # END msec()
1989
} # END msec()
1983
 
1990
 
-
 
1991
 
-
 
1992
##################################################################
-
 
1993
##			Fonction "letsencrypt"			##
-
 
1994
## - Install Let's Encrypt client				##
-
 
1995
## - Prepare Let's Encrypt ALCASAR configuration file		##
-
 
1996
##################################################################
-
 
1997
letsencrypt()
-
 
1998
{
-
 
1999
	echo "Installing Let's Encrypt client..."
-
 
2000
 
-
 
2001
	# Extract acme.sh
-
 
2002
	tar xzf ./conf/letsencrypt-client/acme.sh-*.tar.gz -C /tmp/
-
 
2003
 
-
 
2004
	pwdInstall=$(pwd)
-
 
2005
	cd /tmp/acme.sh-*
-
 
2006
 
-
 
2007
	acmesh_installDir="/opt/acme.sh"
-
 
2008
	acmesh_confDir="/usr/local/etc/letsencrypt"
-
 
2009
	acmesh_userAgent="ALCASAR/$VERSION"
-
 
2010
 
-
 
2011
	# Install acme.sh
-
 
2012
	./acme.sh --install \
-
 
2013
		--home $acmesh_installDir \
-
 
2014
		--config-home $acmesh_confDir/data \
-
 
2015
		--certhome $acmesh_confDir/certs \
-
 
2016
		--accountkey $acmesh_confDir/ca/account.key \
-
 
2017
		--accountconf $acmesh_confDir/data/account.conf \
-
 
2018
		--useragent $acmesh_userAgent \
-
 
2019
		--nocron
-
 
2020
 
-
 
2021
	if [ $? -ne 0 ]; then
-
 
2022
		echo "Error during installation of Let's Encrypt client (acme.sh)."
-
 
2023
	fi
-
 
2024
 
-
 
2025
	# Create configuration file
-
 
2026
	cat <<EOF > /usr/local/etc/alcasar-letsencrypt
-
 
2027
email=
-
 
2028
dateIssueRequest=
-
 
2029
domainRequest=
-
 
2030
challenge=
-
 
2031
dateIssued=
-
 
2032
dnsapi=
-
 
2033
dateNextRenewal=
-
 
2034
EOF
-
 
2035
 
-
 
2036
	cd $pwdInstall
-
 
2037
	rm -rf /tmp/acme.sh-*
-
 
2038
 
-
 
2039
} # END letsencrypt()
-
 
2040
 
1984
##################################################################
2041
##################################################################
1985
##		Fonction "post_install"			##
2042
##		Fonction "post_install"			##
1986
## - Modifying banners (locals et ssh) & prompts	##
2043
## - Modifying banners (locals et ssh) & prompts	##
1987
## - SSH config						##
2044
## - SSH config						##
1988
## - sudoers config & files security			##
2045
## - sudoers config & files security			##
Line 2266... Line 2323...
2266
			MAJ_PREVIOUS_VERSION=`echo $PREVIOUS_VERSION|cut -d"." -f1`
2323
			MAJ_PREVIOUS_VERSION=`echo $PREVIOUS_VERSION|cut -d"." -f1`
2267
			MIN_PREVIOUS_VERSION=`echo $PREVIOUS_VERSION|cut -d"." -f2|cut -c1`
2324
			MIN_PREVIOUS_VERSION=`echo $PREVIOUS_VERSION|cut -d"." -f2|cut -c1`
2268
			UPD_PREVIOUS_VERSION=`echo $PREVIOUS_VERSION|cut -d"." -f3`
2325
			UPD_PREVIOUS_VERSION=`echo $PREVIOUS_VERSION|cut -d"." -f3`
2269
			mode="update"
2326
			mode="update"
2270
		fi
2327
		fi
2271
		for func in init network ACC CA time_server init_db radius chilli dansguardian antivirus tinyproxy ulogd nfsen vnstat dnsmasq BL cron fail2ban gammu_smsd msec post_install
2328
		for func in init network ACC CA time_server init_db radius chilli dansguardian antivirus tinyproxy ulogd nfsen vnstat dnsmasq BL cron fail2ban gammu_smsd msec letsencrypt post_install
2272
		do
2329
		do
2273
			$func
2330
			$func
2274
# echo "*** 'debug' : end of function $func ***"; read a
2331
# echo "*** 'debug' : end of function $func ***"; read a
2275
		done
2332
		done
2276
		;;
2333
		;;