Subversion Repositories ALCASAR

Rev

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

Rev 2584 Rev 2585
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
# $Id: alcasar-conf.sh 2584 2018-07-27 22:12:50Z rexy $
2
# $Id: alcasar-conf.sh 2585 2018-07-28 17:29:54Z tom.houdayer $
3
 
3
 
4
# alcasar-conf.sh
4
# alcasar-conf.sh
5
# by REXY
5
# by 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
 
7
 
Line 14... Line 14...
14
#	- load the backup of configuration files during the update process (alcasar-conf -load). If needed, it's here we update files between versions
14
#	- load the backup of configuration files during the update process (alcasar-conf -load). If needed, it's here we update files between versions
15
#	- apply ALCASAR central configuration file "/usr/local/etc/alcasar.conf" when hot modification are needed (alcasar-conf -apply)
15
#	- apply ALCASAR central configuration file "/usr/local/etc/alcasar.conf" when hot modification are needed (alcasar-conf -apply)
16
 
16
 
17
new="$(date +%G%m%d-%Hh%M)"  				# date et heure des fichiers
17
new="$(date +%G%m%d-%Hh%M)"  				# date et heure des fichiers
18
fichier="alcasar-conf-$new.tar.gz"			# nom du fichier de sauvegarde
18
fichier="alcasar-conf-$new.tar.gz"			# nom du fichier de sauvegarde
19
DIR_UPDATE="/var/tmp/conf"					# répertoire de stockage des fichier de conf pour une mise à jour
19
DIR_UPDATE="/var/tmp/conf"				# répertoire de stockage des fichier de conf pour une mise à jour
20
DIR_WEB="/var/www/html"					# répertoire du centre de gestion
20
DIR_WEB="/var/www/html"					# répertoire du centre de gestion
21
DIR_BIN="/usr/local/bin"				# scripts directory
21
DIR_BIN="/usr/local/bin"				# scripts directory
22
DIR_ETC="/usr/local/etc"				# conf directory
22
DIR_ETC="/usr/local/etc"				# conf directory
23
DIR_SHARE="/usr/local/share"				# data directory
23
DIR_SHARE="/usr/local/share"				# data directory
24
DIR_BLACKLIST="/etc/e2guardian/lists/blacklists"	# Toulouse BL directory
24
DIR_BLACKLIST="/etc/e2guardian/lists/blacklists"	# Toulouse BL directory
Line 142... Line 142...
142
## INFO : local hostnames are resolved in /etc/hosts file
142
## INFO : local hostnames are resolved in /etc/hosts file
143
EOF
143
EOF
144
	## rewrite /etc/hosts file managing hostname resolution
144
	## rewrite /etc/hosts file managing hostname resolution
145
			PRIVATE_IP=`grep ^PRIVATE_IP= $CONF_FILE|cut -d"=" -f2|cut -d"/" -f1`
145
			PRIVATE_IP=`grep ^PRIVATE_IP= $CONF_FILE|cut -d"=" -f2|cut -d"/" -f1`
146
			HOSTNAME=`grep ^HOSTNAME= $CONF_FILE|cut -d"=" -f2`
146
			HOSTNAME=`grep ^HOSTNAME= $CONF_FILE|cut -d"=" -f2`
-
 
147
			domainNames="$HOSTNAME $HOSTNAME.$DOMAIN"
-
 
148
			[ "$HOSTNAME" != 'alcasar' ] && domainNames="alcasar $domainNames"
147
			cat << EOF > $DIR_UPDATE/etc/hosts
149
			cat << EOF > $DIR_UPDATE/etc/hosts
148
127.0.0.1	localhost
150
127.0.0.1	localhost
149
$PRIVATE_IP	$HOSTNAME
151
$PRIVATE_IP	$domainNames
150
EOF
152
EOF
151
	## apache & dansguardian are replaced with lighttpd & E²guardian
153
	## apache & dansguardian are replaced with lighttpd & E²guardian
152
			rm_rpm="apache apache-mod_php apache-mod_ssl dansguardian"
154
			rm_rpm="apache apache-mod_php apache-mod_ssl dansguardian"
153
			/usr/sbin/urpme --auto -a $rm_rpm 2>/dev/null
155
			/usr/sbin/urpme --auto -a $rm_rpm 2>/dev/null
154
			/usr/sbin/urpme --auto --auto-orphans
156
			/usr/sbin/urpme --auto --auto-orphans
Line 334... Line 336...
334
ntpd: $PRIVATE_NETWORK_SHORT
336
ntpd: $PRIVATE_NETWORK_SHORT
335
EOF
337
EOF
336
# Set hostname
338
# Set hostname
337
		hostnamectl set-hostname $HOSTNAME.$DOMAIN
339
		hostnamectl set-hostname $HOSTNAME.$DOMAIN
338
# /etc/hosts
340
# /etc/hosts
-
 
341
		domainNames="$HOSTNAME $HOSTNAME.$DOMAIN"
-
 
342
		[ "$HOSTNAME" != 'alcasar' ] && domainNames="alcasar $domainNames"
339
		$SED "/^$PRIVATE_IP\t/d" /etc/hosts
343
		$SED "/^$PRIVATE_IP\t/d"  /etc/hosts
340
		$SED "/$HOSTNAME$/d" /etc/hosts
344
		$SED "/\s$HOSTNAME\s\$/d" /etc/hosts
-
 
345
		[ "$HOSTNAME" != 'alcasar' ] && $SED "/\salcasar\s\$/d" /etc/hosts
341
		echo "$PRIVATE_IP	$HOSTNAME" >> /etc/hosts
346
		echo "$PRIVATE_IP	$domainNames" >> /etc/hosts
342
# Lighttpd
347
# Lighttpd
343
		$SED "s?^server\.bind.*?server\.bind = \"$HOSTNAME.$DOMAIN\"?g" /etc/lighttpd/lighttpd.conf
348
		$SED "s?^server\.bind.*?server\.bind = \"$HOSTNAME.$DOMAIN\"?g" /etc/lighttpd/lighttpd.conf
344
		$SED 's/^$SERVER\["socket"\] == ".*:443.*/$SERVER\["socket"\] == "'"$HOSTNAME.$DOMAIN"':443" {/g' /etc/lighttpd/vhosts.d/alcasar.conf
349
		$SED 's/^$SERVER\["socket"\] == ".*:443.*/$SERVER\["socket"\] == "'"$HOSTNAME.$DOMAIN"':443" {/g' /etc/lighttpd/vhosts.d/alcasar.conf
345
		$SED "s/^\([\t ]*\)var.server_name.*/\1var.server_name = \"$HOSTNAME.$DOMAIN\"/g" /etc/lighttpd/vhosts.d/alcasar.conf
350
		$SED "s/^\([\t ]*\)var.server_name.*/\1var.server_name = \"$HOSTNAME.$DOMAIN\"/g" /etc/lighttpd/vhosts.d/alcasar.conf
346
# FreeRADIUS Web
351
# FreeRADIUS Web