Subversion Repositories ALCASAR

Rev

Rev 673 | Rev 681 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
672 richard 1
#/bin/bash
64 franck 2
# $Id: alcasar-conf.sh 675 2011-07-18 21:24:19Z richard $
672 richard 3
 
4
# alcasar-conf.sh
5
# by Richard REY
6
# This script is distributed under the Gnu General Public License (GPL)
7
 
8
# Ce script permet la mise à jour ALCASAR 
9
#	- création et chargement de l'archive des fichiers de configuration (/tmp/alcasar-conf.tar.gz)
10
#	- application des directives du fichier de conf central (/usr/local/etc/alcasar.conf)
11
# This script allows ALCASAR update 
12
#	- create and load the configuration files backup (/tmp/alcasar-conf.tar.gz)
13
#	- apply ALCASAR central configuration file (/usr/local/etc/alcasar.conf)
14
 
8 franck 15
DIR_UPDATE="/tmp/conf"				# répertoire de stockage des fichier de conf pour une mise à jour
16
DIR_WEB="/var/www/html"				# répertoire du centre de gestion
478 richard 17
DIR_BIN="/usr/local/bin"			# répertoire des scripts d'admin
346 richard 18
DIR_SBIN="/usr/local/sbin"			# répertoire des scripts d'admin
19
DIR_ETC="/usr/local/etc"			# répertoire des fichiers de conf
628 richard 20
CONF_FILE="$DIR_ETC/alcasar.conf"		# main alcasar conf file
510 richard 21
VERSION="/var/www/html/VERSION"			# contient la version en cours
628 richard 22
EXTIF="eth0"					# ETH0 est l'interface connectée à Internet (Box FAI)
23
INTIF="eth1"					# ETH1 est l'interface connectée au réseau local de consultation
24
HOSTNAME="alcasar"
369 richard 25
DB_USER="radius"
504 richard 26
radiuspwd=""
384 richard 27
SED="/bin/sed -i"
510 richard 28
RUNNING_VERSION=`cat $VERSION|cut -d" " -f1`
29
MAJ_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f1`
30
MIN_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f2|cut -c1`
31
UPD_RUNNING_VERSION=`echo $RUNNING_VERSION|cut -d"." -f3`
628 richard 32
DATE=`date '+%d %B %Y - %Hh%M'`
33
private_network_calc ()
34
{
35
	PRIVATE_PREFIX=`/bin/ipcalc -p $PRIVATE_IP $PRIVATE_NETMASK |cut -d"=" -f2`		# prefixe du réseau (ex. 24)
36
	PRIVATE_NETWORK=`/bin/ipcalc -n $PRIVATE_IP $PRIVATE_NETMASK| cut -d"=" -f2`		# @ réseau de consultation (ex.: 192.168.182.0)
37
	PRIVATE_NETWORK_MASK=$PRIVATE_NETWORK/$PRIVATE_PREFIX					# @ + masque du réseau de consult (192.168.182.0/24)
38
	classe=$((PRIVATE_PREFIX/8)); classe_sup=`expr $classe + 1`; classe_sup_sup=`expr $classe + 2`		# classes de réseau (ex.: 2=classe B, 3=classe C)
39
	PRIVATE_NETWORK_SHORT=`echo $PRIVATE_NETWORK | cut -d"." -f1-$classe`.			# @ compatible hosts.allow et hosts.deny (ex.: 192.168.182.)
40
	PRIVATE_BROADCAST=`/bin/ipcalc -b $PRIVATE_NETWORK_MASK | cut -d"=" -f2`		# @ broadcast réseau de consultation (ex.: 192.168.182.255)
41
	tmp_mask=`echo $PRIVATE_NETWORK_MASK|cut -d"/" -f2`; half_mask=`expr $tmp_mask + 1`	# masque du 1/2 réseau de consultation (ex.: 25)
42
	PRIVATE_STAT_IP=$PRIVATE_NETWORK/$half_mask						# plage des adresses statiques (ex.: 192.168.182.0/25)
43
	private_network_ending=`echo $PRIVATE_NETWORK | cut -d"." -f$classe_sup`		# dernier octet de l'@ de réseau
44
	private_broadcast_ending=`echo $PRIVATE_BROADCAST | cut -d"." -f$classe_sup`		# dernier octet de l'@ de broadcast
45
	private_plage=`expr $private_broadcast_ending - $private_network_ending + 1`
46
	private_half_plage=`expr $private_plage / 2`
47
	private_dyn=`expr $private_half_plage + $private_network_ending`
48
	private_dyn_ip_network=`echo $PRIVATE_NETWORK | cut -d"." -f1-$classe`"."$private_dyn"."`echo $PRIVATE_NETWORK | cut -d"." -f$classe_sup_sup-5`
49
	PRIVATE_DYN_IP=`echo $private_dyn_ip_network | cut -d"." -f1-4`/$half_mask					# @ réseau (CIDR) de la plage des adresses dynamiques (ex.: 192.168.182.128/25)
50
	private_dyn_ip_ending=`echo $private_dyn_ip_network | cut -d"." -f4`
51
	PRIVATE_DYN_FIRST_IP=`echo $private_dyn_ip_network | cut -d"." -f1-3`"."`expr $private_dyn_ip_ending + 1`	# 1ère adresse de la plage dynamique (ex.: 192.168.182.129)
52
	PRIVATE_DYN_LAST_IP=`echo $PRIVATE_BROADCAST | cut -d"." -f1-3`"."`expr $private_broadcast_ending - 1`		# dernière adresse de la plage dynamique (ex.: 192.168.182.254)
53
}
8 franck 54
 
628 richard 55
usage="Usage: alcasar-conf.sh --create | --load | --apply"
8 franck 56
nb_args=$#
57
args=$1
58
if [ $nb_args -eq 0 ]
59
then
60
	nb_args=1
61
	args="-h"
62
fi
63
case $args in
64
	-\? | -h* | --h*)
65
		echo "$usage"
66
		exit 0
67
		;;
389 franck 68
	--create|-create)	
8 franck 69
		DIR_UPDATE="/tmp/conf"				# répertoire de stockage des fichier de conf pour une mise à jour
70
		[ -d $DIR_UPDATE ] && rm -rf $DIR_UPDATE
71
		mkdir $DIR_UPDATE
72
# Sauvegarde de la base des usagers
411 richard 73
		/usr/local/sbin/alcasar-mysql.sh -dump
8 franck 74
		cp /var/Save/base/`ls /var/Save/base|tail -1` $DIR_UPDATE
75
# Sauvegarde du logo
76
		cp -f $DIR_WEB/images/organisme.png $DIR_UPDATE
310 richard 77
# Sauvegarde des fichiers exploités par dansguardian 
78
		cp -f /etc/dansguardian/lists/exceptioniplist $DIR_UPDATE
79
		cp -f /etc/dansguardian/lists/exceptionsitelist $DIR_UPDATE
80
		cp -f /etc/dansguardian/lists/bannedsitelist $DIR_UPDATE
81
		cp -f /etc/dansguardian/lists/exceptionurllist $DIR_UPDATE
82
		cp -f /etc/dansguardian/lists/bannedurllist $DIR_UPDATE
83
		cp -rf /etc/dansguardian/lists/blacklists/ossi $DIR_UPDATE
612 richard 84
# sauvegarde des fichiers : de conf, de filtrage, d'exception, digest, etc.
8 franck 85
		mkdir $DIR_UPDATE/etc/
346 richard 86
		cp -rf $DIR_ETC/* $DIR_UPDATE/etc/
510 richard 87
# particularité des versions
636 richard 88
# si version <= 2.0
89
		if [ $MAJ_RUNNING_VERSION -lt 2 ] || ([ $MAJ_RUNNING_VERSION -eq 2 ] && [ $MIN_RUNNING_VERSION -eq 0 ])
510 richard 90
		then
91
			rm -f $DIR_UPDATE/etc/alcasar-dns-name		# changement de format
92
			rm -f $DIR_UPDATE/etc/alcasar-macallowed	# ajout d'un commentaire par @MAC
93
			rm -rf $DIR_UPDATE/etc/digest			# hostname=alcasar
638 richard 94
			if [ -e $DIR_UPDATE/etc/alcasar-uamallowed ]; then
95
				uamallowed=`cat $DIR_UPDATE/etc/alcasar-uamallowed`
96
				if [ $uamallowed == "uamallowed=\"\"" ]
97
					then rm -f $DIR_UPDATE/etc/alcasar-uamallowed		# un uamallowed 'vide' perturbe coova
98
				fi
618 richard 99
			fi
638 richard 100
			if [ -e $DIR_UPDATE/etc/alcasar-uamdomain ]; then
101
				uamdomain=`cat $DIR_UPDATE/etc/alcasar-uamdomain`
102
				if [ $uamdomain == "uamdomain=\"\"" ]
103
					then rm -f $DIR_UPDATE/etc/alcasar-uamdomain		# un uamdomain 'vide' perturbe coova
104
				fi
618 richard 105
			fi
510 richard 106
		else
605 richard 107
# si version >= 2.1 : sauvegarde des certificats (serveur et CA)
510 richard 108
			mkdir $DIR_UPDATE/pki/
109
			cert_date=`/usr/bin/openssl x509 -noout -in /etc/pki/tls/certs/alcasar.crt -dates|grep After|cut -d"=" -f2`
110
			cp -f /etc/pki/tls/certs/alcasar.crt $DIR_UPDATE
111
			cp -f /etc/pki/tls/private/alcasar.key $DIR_UPDATE
112
			cp -f /etc/pki/CA/alcasar-ca.crt $DIR_UPDATE
113
			cp -f /etc/pki/CA/private/alcasar-ca.key $DIR_UPDATE
675 richard 114
			if [ -e /etc/pki/tls/certs/server-chain.crt ]; then
115
				cp -f /etc/pki/tls/certs/server-chain.crt $DIR_UPDATE
116
			else
117
				cp -f /etc/pki/tls/certs/alcasar.crt $DIR_UPDATE/server-chain.crt
118
			fi
510 richard 119
		fi
605 richard 120
# si version < 2.2
636 richard 121
		if [ $MAJ_RUNNING_VERSION -lt 2 ] || ([ $MAJ_RUNNING_VERSION -eq 2 ] && [ $MIN_RUNNING_VERSION -lt 2 ])
605 richard 122
		then
636 richard 123
			ORGANISM=`cat $DIR_WEB/intercept.php|grep '$organisme =' | cut -d"=" -f2|tr -d ";\" "` # Sauvegarde du nom d'organisme
628 richard 124
			rm -f $DIR_UPDATE/etc/alcasar-ethers		# This file doesn't contain comments
125
			# Create the initial conf file (doesn't exist in earlier versions)
126
			cat <<EOF > $CONF_FILE
127
##########################################
128
##                                      ##
129
##          ALCASAR Parameters          ##
130
##                                      ##
131
##########################################
132
 
133
INSTALL_DATE=$DATE
134
VERSION=$RUNNING_VERSION
632 richard 135
ORGANISM=$ORGANISM
628 richard 136
EOF
636 richard 137
			PUBLIC_IP=`grep IPADDR /etc/sysconfig/network-scripts/ifcfg-$EXTIF|cut -d"=" -f2` 	# @ip du portail (côté Internet)
138
			PUBLIC_NETMASK=`grep NETMASK /etc/sysconfig/network-scripts/ifcfg-$EXTIF|cut -d"=" -f2`
139
			PUBLIC_PREFIX=`/bin/ipcalc -p $PUBLIC_IP $PUBLIC_NETMASK |cut -d"=" -f2`		# prefixe du réseau (ex. 24)
140
			PUBLIC_GATEWAY=`grep GATEWAY /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF|cut -d"=" -f2`
141
			DNS1=`grep DNS1 /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF|cut -d"=" -f2` 	# @ip 1er DNS
142
			DNS2=`grep DNS2 /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF|cut -d"=" -f2` 	# @ip 2ème DNS
143
			DNS1=${DNS1:=208.67.220.220}
144
			DNS2=${DNS2:=208.67.222.222}
145
			PRIVATE_IP=`grep IPADDR /etc/sysconfig/network-scripts/ifcfg-$INTIF|cut -d"=" -f2` 	# @ip du portail (côté LAN)
146
			PRIVATE_NETMASK=`grep NETMASK /etc/sysconfig/network-scripts/ifcfg-$INTIF|cut -d"=" -f2`
147
			private_network_calc
148
			echo "PUBLIC_IP=$PUBLIC_IP/$PUBLIC_PREFIX" >> $CONF_FILE 
149
			echo "GW=$PUBLIC_GATEWAY" >> $CONF_FILE
150
			echo "DNS1=$DNS1" >> $CONF_FILE
151
			echo "DNS2=$DNS2" >> $CONF_FILE 
152
			echo "PRIVATE_IP=$PRIVATE_IP/$PRIVATE_PREFIX" >> $CONF_FILE 
153
			echo "DHCP=on" >> $CONF_FILE
154
			if [ -r /var/run/sshd.pid ]; then
155
				echo "SSH=on" >> $CONF_FILE
156
			else
157
				echo "SSH=off" >> $CONF_FILE
158
			fi
159
			echo "QOS=off" >> $CONF_FILE
637 richard 160
			echo "WEB_ANTIVIRUS=on" >> $CONF_FILE
636 richard 161
			if [ `grep ^ldap /etc/raddb/sites-available/alcasar | wc -l` -eq "0" ];	then
162
				echo "LDAP=off" >> $CONF_FILE
163
			else
164
				echo "LDAP=on" >> $CONF_FILE
165
			fi
637 richard 166
			PROTOCOLS_FILTERING=`grep ^FILTERING /usr/local/bin/alcasar-iptables.sh | cut -d"=" -f2`
167
			PROTOCOLS_FILTERING=${PROTOCOLS_FILTERING:="no"}
638 richard 168
			if [ $PROTOCOLS_FILTERING = "no" ]; then
637 richard 169
				echo "PROTOCOLS_FILTERING=off" >> $CONF_FILE
170
			else
171
				echo "PROTOCOLS_FILTERING=on" >> $CONF_FILE
172
			fi
638 richard 173
			DNS_FILTERING=`grep ^reportinglevel /etc/dansguardian/dansguardian.conf | cut -d"=" -f2 | tr -d " "`
637 richard 174
			DNS_FILTERING=${DNS_FILTERING:="-1"}
638 richard 175
			if [ $DNS_FILTERING -eq "-1" ]; then
637 richard 176
				echo "DNS_FILTERING=off" >> $CONF_FILE
177
			else
178
				echo "DNS_FILTERING=on" >> $CONF_FILE
179
			fi
636 richard 180
			cp $CONF_FILE $DIR_UPDATE/etc/
605 richard 181
		fi
8 franck 182
# création de l'archive
183
		cd /tmp
184
		tar -cf alcasar-conf.tar conf/
185
		gzip -f alcasar-conf.tar
186
		rm -rf $DIR_UPDATE
187
		;;
389 franck 188
	--load|-load)
8 franck 189
		cd /tmp
30 richard 190
		tar -xf /tmp/alcasar-conf.tar.gz
8 franck 191
# Récupération du logo
510 richard 192
		[ -e $DIR_UPDATE/organisme.png ] && cp -f $DIR_UPDATE/organisme.png $DIR_WEB/images/
8 franck 193
		chown apache:apache $DIR_WEB/images/organisme.png $DIR_WEB/intercept.php
194
# Récupération des certificats (CA et serveur)
510 richard 195
		[ -e $DIR_UPDATE/alcasar-ca.crt ] && cp -f $DIR_UPDATE/alcasar-ca.crt /etc/pki/CA/
196
		[ -e $DIR_UPDATE/alcasar-ca.key ] && cp -f $DIR_UPDATE/alcasar-ca.key /etc/pki/CA/private/
197
		[ -e $DIR_UPDATE/alcasar.crt ] && cp -f $DIR_UPDATE/alcasar.crt /etc/pki/tls/certs/
198
		[ -e $DIR_UPDATE/alcasar.key ] && cp -f $DIR_UPDATE/alcasar.key /etc/pki/tls/private/
675 richard 199
		[ -e $DIR_UPDATE/server-chain.crt ] &&	cp -f $DIR_UPDATE/server-chain.crt /etc/pki/tls/certs/
8 franck 200
		chown -R root:apache /etc/pki
201
		chmod -R 750 /etc/pki
202
# Import de la dernière base usagers
203
		mysql -u$DB_USER -p$radiuspwd < `ls $DIR_UPDATE/radius*`
612 richard 204
# Récupération des paramêtres locaux (fichier de conf, règles de filtrage, fichiers d'exception, comptes de gestion, etc.)
205
		[ -d $DIR_UPDATE/etc ] && cp -rf $DIR_UPDATE/etc/* $DIR_ETC/
310 richard 206
# Récupération des fichiers de Dansguardian
510 richard 207
		[ -e $DIR_UPDATE/exceptioniplist ] && cp -f $DIR_UPDATE/exceptioniplist /etc/dansguardian/lists/
208
		[ -e $DIR_UPDATE/exceptionsitelist ] && cp -f $DIR_UPDATE/exceptionsitelist /etc/dansguardian/lists/
209
		[ -e $DIR_UPDATE/bannedsitelist ] && cp -f $DIR_UPDATE/bannedsitelist /etc/dansguardian/lists/ 
210
		[ -e $DIR_UPDATE/exceptionurllist ] && cp -f $DIR_UPDATE/exceptionurllist /etc/dansguardian/lists/
211
		[ -e $DIR_UPDATE/bannedurllist ] && cp -f $DIR_UPDATE/bannedurllist /etc/dansguardian/lists/
212
		[ -d $DIR_UPDATE/ossi ] && cp -rf $DIR_UPDATE/ossi /etc/dansguardian/lists/blacklists/
8 franck 213
		chown -R dansguardian:apache /etc/dansguardian/lists
214
		chmod -R g+rw /etc/dansguardian/lists
634 richard 215
# Start / Stop DNS/URL filtering
637 richard 216
		PARENT_SCRIPT=$0
217
		export PARENT_SCRIPT
654 richard 218
		$DIR_SBIN/alcasar-bl.sh -reload
434 richard 219
# Prise en compte des comptes de gestion (admin + manager + backup)
395 franck 220
		$DIR_SBIN/alcasar-profil.sh --list
634 richard 221
# Start / Stop SSH Daemon
222
		ssh_active=`grep SSH $CONF_FILE|cut -d"=" -f2`
223
		if [ $ssh_active = "on" ]
224
		then
225
			/sbin/chkconfig --add sshd
226
		else
227
			/sbin/chkconfig --del sshd
228
		fi
226 franck 229
# Effacement du répertoire d'update
8 franck 230
		rm -rf $DIR_UPDATE
231
		;;
628 richard 232
	--apply|-apply)
233
		PTN="\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/[012]?[0-9]\b"
234
		PRIVATE_IP_MASK=`grep PRIVATE_IP $CONF_FILE|cut -d"=" -f2`
235
		check=$(echo $PRIVATE_IP_MASK | egrep $PTN)
236
		if [[ "$?" -ne 0 ]]
237
		then 
238
			echo "Syntax error for PRIVATE_IP_MASK ($PRIVATE_IP_MASK)"
239
			exit 0
240
		fi
241
		PUBLIC_IP_MASK=`grep PUBLIC_IP $CONF_FILE|cut -d"=" -f2`
242
		check=$(echo $PUBLIC_IP_MASK | egrep $PTN)
243
		if [[ "$?" -ne 0 ]]
244
		then 
245
			echo "Syntax error for PUBLIC_IP_MASK ($PUBLIC_IP_MASK)"
246
			exit 0
247
		fi
248
		PTN="\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b"
249
		PUBLIC_GATEWAY=`grep GW $CONF_FILE|cut -d"=" -f2`
250
		check=$(echo $PUBLIC_GATEWAY | egrep $PTN)
251
		if [[ "$?" -ne 0 ]]
252
			then 
253
			echo "Syntax error for the Gateway IP ($PUBLIC_GATEWAY)"
254
			exit 0
255
		fi
256
		DNS1=`grep DNS1 $CONF_FILE|cut -d"=" -f2`
673 richard 257
		check=$(echo $DNS1 | egrep $PTN)
628 richard 258
		if [[ "$?" -ne 0 ]]
259
		then 
260
			echo "Syntax error for the IP address of the first DNS server ($DNS1)"
261
			exit 0
262
		fi
263
		DNS2=`grep DNS2 $CONF_FILE|cut -d"=" -f2`
673 richard 264
		check=$(echo $DNS2 | egrep $PTN)
628 richard 265
		if [[ "$?" -ne 0 ]]
266
		then 
267
			echo "Syntax error for the IP address of the second DNS server ($DNS2)"
268
			exit 0
269
		fi
632 richard 270
		PUBLIC_IP=`echo $PUBLIC_IP_MASK | cut -d"/" -f1`
271
		PUBLIC_NETMASK=`/bin/ipcalc -m $PUBLIC_IP_MASK | cut -d"=" -f2`
631 richard 272
		PRIVATE_IP=`echo $PRIVATE_IP_MASK | cut -d"/" -f1`
632 richard 273
		PRIVATE_NETMASK=`/bin/ipcalc -m $PRIVATE_IP_MASK | cut -d"=" -f2`
628 richard 274
		private_network_calc
632 richard 275
		VERSION=`grep VERSION $CONF_FILE|cut -d"=" -f2`
276
		INSTALL_DATE=`grep INSTALL_DATE $CONF_FILE|cut -d"=" -f2`
277
		ORGANISME=`grep ORGANISM $CONF_FILE|cut -d"=" -f2`
634 richard 278
# Logout everybody
279
		$DIR_SBIN/alcasar-logout.sh all		
280
# Services stop
281
		for i in squid ntpd chilli httpd sshd network
282
		do
283
			[ -e /etc/init.d/$i ] && /etc/init.d/$i stop && killall $i 2>/dev/null
284
		done
628 richard 285
 
286
# /etc/hosts
287
		cat <<EOF > /etc/hosts
288
127.0.0.1	localhost
289
$PRIVATE_IP	$HOSTNAME 
290
EOF
291
 
292
# Networt Cards config
293
		$SED "s?^IPADDR=.*?IPADDR=$PUBLIC_IP?" /etc/sysconfig/network-scripts/ifcfg-$EXTIF
294
		$SED "s?^NETMASK=.*?NETMASK=$PUBLIC_NETMASK?" /etc/sysconfig/network-scripts/ifcfg-$EXTIF
295
		$SED "s?^GATEWAY=.*?GATEWAY=$PUBLIC_GATEWAY?" /etc/sysconfig/network-scripts/ifcfg-$EXTIF
296
		$SED "s?^IPADDR=.*?IPADDR=$PRIVATE_IP?" /etc/sysconfig/network-scripts/ifcfg-$INTIF
297
		$SED "s?^NETMASK=.*?NETMASK=$PRIVATE_NETMASK?" /etc/sysconfig/network-scripts/ifcfg-$INTIF
298
# NTP server
632 richard 299
		$SED "/127.0.0.1/!s?^restrict.*?restrict $PRIVATE_NETWORK mask $PRIVATE_NETMASK nomodify notrap?g" /etc/ntp.conf
628 richard 300
# host.allow 
301
		cat <<EOF > /etc/hosts.allow
302
ALL: LOCAL, 127.0.0.1, localhost, $PRIVATE_IP
303
sshd: ALL
304
ntpd: $PRIVATE_NETWORK_SHORT
305
EOF
632 richard 306
# Alcasar Control Center
634 richard 307
		echo "$VERSION du $INSTALL_DATE" > /var/www/html/VERSION; chown apache:apache /var/www/html/VERSION
308
		$SED "s?^Listen.*?Listen $PRIVATE_IP:80?g" /etc/httpd/conf/httpd.conf
309
		FIC_MOD_SSL=`find /etc/httpd/modules.d/ -type f -name *mod_ssl.conf`
310
		$SED "s?^Listen.*?Listen $PRIVATE_IP:443?g" $FIC_MOD_SSL
311
		$SED "/127.0.0.1/!s?Allow from .*?Allow from $PRIVATE_NETWORK_MASK?g" /etc/httpd/conf/webapps.d/alcasar.conf
632 richard 312
# Dialup_Admin
634 richard 313
		$SED "s?^nas1_name:.*?nas1_name: alcasar-$ORGANISME?g" /etc/freeradius-web/naslist.conf
314
		$SED "s?^nas1_ip:.*?nas1_ip: $PRIVATE_IP?g" /etc/freeradius-web/naslist.conf
632 richard 315
# coova
634 richard 316
		$SED "s?ifconfig.*?ifconfig \$HS_LANIF $PRIVATE_IP?g" /etc/init.d/chilli
317
		$SED "s?^net.*?net\t\t$PRIVATE_NETWORK_MASK?g" /etc/chilli.conf
318
		$SED "s?^dynip.*?dynip\t\t$PRIVATE_DYN_IP?g" /etc/chilli.conf
319
		$SED "s?^statip.*?statip\t\t$PRIVATE_STAT_IP?g" /etc/chilli.conf
320
		$SED "s?^dns1.*?dns1\t\t$PRIVATE_IP?g" /etc/chilli.conf
321
		$SED "s?^dns2.*?dns2\t\t$PRIVATE_IP?g" /etc/chilli.conf
322
		$SED "s?^uamlisten.*?uamlisten\t$PRIVATE_IP?g" /etc/chilli.conf
323
		$SED "s?^\$organisme = .*?\$organisme = \"$ORGANISME\";?g" /var/www/html/intercept.php /var/www/html/status.php
632 richard 324
# awstat
634 richard 325
		$SED "s?^HostAliases=.*?HostAliases=\"$PRIVATE_IP\"?g" /etc/awstats/awstats.conf
632 richard 326
# dnsmasq
634 richard 327
		$SED "/127.0.0.1/!s?^listen-address=.*?listen-address=$PRIVATE_IP?g" /etc/dnsmasq.conf /etc/dnsmasq-blackhole.conf
673 richard 328
		for i in /etc/dnsmasq.conf /etc/dnsmasq-blackhole.conf
329
		do
330
			$SED "/^server=/d" $i
331
			echo "server=$DNS1" >> $i
332
			echo "server=$DNS2" >> $i
333
		done
634 richard 334
		$SED "s?^dhcp-range=.*?dhcp-range=$PRIVATE_DYN_FIRST_IP,$PRIVATE_DYN_LAST_IP,$PRIVATE_NETMASK,12h?g" /etc/dnsmasq.conf
335
		$SED "s?^dhcp-option=option:router.*?dhcp-option=option:router,$PRIVATE_IP?g" /etc/dnsmasq.conf
336
# DG + BL
337
		$SED "s?^IP_RETOUR=.*?IP_RETOUR=\"$PRIVATE_IP\"?g" $DIR_SBIN/alcasar-bl.sh
338
		$SED "s?^filterip.*?filterip = $PRIVATE_IP?g" /etc/dansguardian/dansguardian.conf
339
# Watchdog
340
		$SED "s?^PRIVATE_IP=.*?PRIVATE_IP=\"$PRIVATE_IP\"?g" $DIR_BIN/alcasar-watchdog.sh
341
# SSHD
342
		$SED "s?^#ListenAddress 0\.0\.0\.0?ListenAddress $PRIVATE_IP?g" /etc/ssh/sshd_config
343
		$SED "/^ListenAddress $PRIVATE_IP/a\ListenAddress $PUBLIC_IP" /etc/ssh/sshd_config
344
# Prompts
345
		$SED "s?^ORGANISME.*?ORGANISME=$ORGANISME?g" /etc/bashrc
346
# sudoers
347
		$SED "s?^Host_Alias.*?Host_Alias	LAN_ORG=$PRIVATE_NETWORK/$PRIVATE_NETMASK,localhost		#réseau de l'organisme?g" /etc/sudoers
348
# Services start
349
		for i in network squid ntpd chilli httpd 
350
		do
351
			[ -e /etc/init.d/$i ] && /etc/init.d/$i start 2>/dev/null
352
		done
628 richard 353
# Start / Stop SSH Daemon
634 richard 354
		ssh_active=`grep SSH $CONF_FILE|cut -d"=" -f2`
355
		if [ $ssh_active = "on" ]
356
		then
357
			/sbin/chkconfig --add sshd
358
			/etc/init.d/sshd start
359
		else
360
			/sbin/chkconfig --del sshd
361
		fi
362
# Reload BL (restart DG, dnsmasq & iptables)
363
		$DIR_SBIN/alcasar-bl.sh -reload
628 richard 364
		;;
8 franck 365
	*)
366
		echo "Argument inconnu :$1";
367
		echo "$usage"
368
		exit 1
369
		;;
370
esac
371