Subversion Repositories ALCASAR

Rev

Rev 637 | Rev 648 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

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