Subversion Repositories ALCASAR

Rev

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