Subversion Repositories ALCASAR

Rev

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

Rev 631 Rev 632
Line 1... Line 1...
1
#/bin/sh
1
#/bin/sh
2
# $Id: alcasar-conf.sh 631 2011-06-12 10:34:00Z richard $
2
# $Id: alcasar-conf.sh 632 2011-06-12 17:48:40Z richard $
3
# $Author: richard $
3
# $Author: richard $
4
# by rexy
4
# by rexy
5
# Ce script permet de créer ou de charger l'archive des fichiers de configuration (/tmp/alcasar-conf.tar.gz)
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
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
7
DIR_WEB="/var/www/html"				# répertoire du centre de gestion
Line 61... Line 61...
61
		[ -d $DIR_UPDATE ] && rm -rf $DIR_UPDATE
61
		[ -d $DIR_UPDATE ] && rm -rf $DIR_UPDATE
62
		mkdir $DIR_UPDATE
62
		mkdir $DIR_UPDATE
63
# Sauvegarde de la base des usagers
63
# Sauvegarde de la base des usagers
64
		/usr/local/sbin/alcasar-mysql.sh -dump
64
		/usr/local/sbin/alcasar-mysql.sh -dump
65
		cp /var/Save/base/`ls /var/Save/base|tail -1` $DIR_UPDATE
65
		cp /var/Save/base/`ls /var/Save/base|tail -1` $DIR_UPDATE
66
# Sauvegarde du nom d'organisme
-
 
67
		echo `cat /root/ALCASAR-parameters.txt|grep Organism|cut -d":" -f2|tr -d " "` > $DIR_UPDATE/organisme
-
 
68
# Sauvegarde du logo
66
# Sauvegarde du logo
69
		cp -f $DIR_WEB/images/organisme.png $DIR_UPDATE
67
		cp -f $DIR_WEB/images/organisme.png $DIR_UPDATE
70
# Sauvegarde des fichiers exploités par dansguardian 
68
# Sauvegarde des fichiers exploités par dansguardian 
71
		cp -f /etc/dansguardian/lists/exceptioniplist $DIR_UPDATE
69
		cp -f /etc/dansguardian/lists/exceptioniplist $DIR_UPDATE
72
		cp -f /etc/dansguardian/lists/exceptionsitelist $DIR_UPDATE
70
		cp -f /etc/dansguardian/lists/exceptionsitelist $DIR_UPDATE
Line 102... Line 100...
102
			cp -f /etc/pki/CA/private/alcasar-ca.key $DIR_UPDATE
100
			cp -f /etc/pki/CA/private/alcasar-ca.key $DIR_UPDATE
103
		fi
101
		fi
104
# si version < 2.2
102
# si version < 2.2
105
		if ([ $MAJ_RUNNING_VERSION -lt 2 ] || ([ $MAJ_RUNNING_VERSION -eq 2 ] && [ $MIN_RUNNING_VERSION -lt 2 ]))
103
		if ([ $MAJ_RUNNING_VERSION -lt 2 ] || ([ $MAJ_RUNNING_VERSION -eq 2 ] && [ $MIN_RUNNING_VERSION -lt 2 ]))
106
		then
104
		then
-
 
105
			ORGANISM=`cat /root/ALCASAR-parameters.txt|grep Organism|cut -d":" -f2|tr -d " "` # Sauvegarde du nom d'organisme
107
			rm -f $DIR_UPDATE/etc/alcasar-ethers		# This file doesn't contain comments
106
			rm -f $DIR_UPDATE/etc/alcasar-ethers		# This file doesn't contain comments
108
			# Create the initial conf file (doesn't exist in earlier versions)
107
			# Create the initial conf file (doesn't exist in earlier versions)
109
			cat <<EOF > $CONF_FILE
108
			cat <<EOF > $CONF_FILE
110
##########################################
109
##########################################
111
##                                      ##
110
##                                      ##
Line 113... Line 112...
113
##                                      ##
112
##                                      ##
114
##########################################
113
##########################################
115
 
114
 
116
INSTALL_DATE=$DATE
115
INSTALL_DATE=$DATE
117
VERSION=$RUNNING_VERSION
116
VERSION=$RUNNING_VERSION
118
ORGANISM=
117
ORGANISM=$ORGANISM
119
EOF
118
EOF
120
		PUBLIC_IP=`grep IPADDR /etc/sysconfig/network-scripts/ifcfg-$EXTIF|cut -d"=" -f2` 	# @ip du portail (côté Internet)
119
		PUBLIC_IP=`grep IPADDR /etc/sysconfig/network-scripts/ifcfg-$EXTIF|cut -d"=" -f2` 	# @ip du portail (côté Internet)
121
		PUBLIC_NETMASK=`grep NETMASK /etc/sysconfig/network-scripts/ifcfg-$EXTIF|cut -d"=" -f2`
120
		PUBLIC_NETMASK=`grep NETMASK /etc/sysconfig/network-scripts/ifcfg-$EXTIF|cut -d"=" -f2`
122
		PUBLIC_PREFIX=`/bin/ipcalc -p $PUBLIC_IP $PUBLIC_NETMASK |cut -d"=" -f2`		# prefixe du réseau (ex. 24)
121
		PUBLIC_PREFIX=`/bin/ipcalc -p $PUBLIC_IP $PUBLIC_NETMASK |cut -d"=" -f2`		# prefixe du réseau (ex. 24)
123
		PUBLIC_GATEWAY=`grep GATEWAY /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF|cut -d"=" -f2`
122
		PUBLIC_GATEWAY=`grep GATEWAY /etc/sysconfig/network-scripts/default-ifcfg-$EXTIF|cut -d"=" -f2`
Line 227... Line 226...
227
		if [[ "$?" -ne 0 ]]
226
		if [[ "$?" -ne 0 ]]
228
		then 
227
		then 
229
			echo "Syntax error for the IP address of the second DNS server ($DNS2)"
228
			echo "Syntax error for the IP address of the second DNS server ($DNS2)"
230
			exit 0
229
			exit 0
231
		fi
230
		fi
-
 
231
		PUBLIC_IP=`echo $PUBLIC_IP_MASK | cut -d"/" -f1`
-
 
232
		PUBLIC_NETMASK=`/bin/ipcalc -m $PUBLIC_IP_MASK | cut -d"=" -f2`
232
		PRIVATE_IP=`echo $PRIVATE_IP_MASK | cut -d"/" -f1`
233
		PRIVATE_IP=`echo $PRIVATE_IP_MASK | cut -d"/" -f1`
233
		PRIVATE_NETMASK=`/bin/ipcalc -m $PRIVATE_IP_MASK | cut -d"=" -f2`	# @ masque du réseau de consult (255.255.255.0)
234
		PRIVATE_NETMASK=`/bin/ipcalc -m $PRIVATE_IP_MASK | cut -d"=" -f2`
234
		private_network_calc
235
		private_network_calc
-
 
236
		VERSION=`grep VERSION $CONF_FILE|cut -d"=" -f2`
-
 
237
		INSTALL_DATE=`grep INSTALL_DATE $CONF_FILE|cut -d"=" -f2`
-
 
238
		ORGANISME=`grep ORGANISM $CONF_FILE|cut -d"=" -f2`
235
 
239
 
236
# /etc/hosts
240
# /etc/hosts
237
		cat <<EOF > /etc/hosts
241
		cat <<EOF > /etc/hosts
238
127.0.0.1	localhost
242
127.0.0.1	localhost
239
$PRIVATE_IP	$HOSTNAME 
243
$PRIVATE_IP	$HOSTNAME 
Line 243... Line 247...
243
		$SED "s?^IPADDR=.*?IPADDR=$PUBLIC_IP?" /etc/sysconfig/network-scripts/ifcfg-$EXTIF
247
		$SED "s?^IPADDR=.*?IPADDR=$PUBLIC_IP?" /etc/sysconfig/network-scripts/ifcfg-$EXTIF
244
		$SED "s?^NETMASK=.*?NETMASK=$PUBLIC_NETMASK?" /etc/sysconfig/network-scripts/ifcfg-$EXTIF
248
		$SED "s?^NETMASK=.*?NETMASK=$PUBLIC_NETMASK?" /etc/sysconfig/network-scripts/ifcfg-$EXTIF
245
		$SED "s?^GATEWAY=.*?GATEWAY=$PUBLIC_GATEWAY?" /etc/sysconfig/network-scripts/ifcfg-$EXTIF
249
		$SED "s?^GATEWAY=.*?GATEWAY=$PUBLIC_GATEWAY?" /etc/sysconfig/network-scripts/ifcfg-$EXTIF
246
		$SED "s?^IPADDR=.*?IPADDR=$PRIVATE_IP?" /etc/sysconfig/network-scripts/ifcfg-$INTIF
250
		$SED "s?^IPADDR=.*?IPADDR=$PRIVATE_IP?" /etc/sysconfig/network-scripts/ifcfg-$INTIF
247
		$SED "s?^NETMASK=.*?NETMASK=$PRIVATE_NETMASK?" /etc/sysconfig/network-scripts/ifcfg-$INTIF
251
		$SED "s?^NETMASK=.*?NETMASK=$PRIVATE_NETMASK?" /etc/sysconfig/network-scripts/ifcfg-$INTIF
248
 
-
 
249
echo "NIC ok"
-
 
250
# NTP server
252
# NTP server
251
		$SED "s?^restrict.*?restrict $PRIVATE_NETWORK mask $PRIVATE_NETMASK nomodify notrap\nrestrict 127.0.0.1?" /etc/ntp.conf
253
		$SED "/127.0.0.1/!s?^restrict.*?restrict $PRIVATE_NETWORK mask $PRIVATE_NETMASK nomodify notrap?g" /etc/ntp.conf
252
 
-
 
253
# host.allow 
254
# host.allow 
254
		cat <<EOF > /etc/hosts.allow
255
		cat <<EOF > /etc/hosts.allow
255
ALL: LOCAL, 127.0.0.1, localhost, $PRIVATE_IP
256
ALL: LOCAL, 127.0.0.1, localhost, $PRIVATE_IP
256
sshd: ALL
257
sshd: ALL
257
ntpd: $PRIVATE_NETWORK_SHORT
258
ntpd: $PRIVATE_NETWORK_SHORT
258
EOF
259
EOF
259
 
-
 
260
# Alcasar control center
260
# Alcasar Control Center
-
 
261
echo "$VERSION du $INSTALL_DATE" > /var/www/html/VERSION; chown apache:apache /var/www/html/VERSION
261
$SED "s?^Listen.*?Listen $PRIVATE_IP:80?g" /etc/httpd/conf/httpd.conf
262
$SED "s?^Listen.*?Listen $PRIVATE_IP:80?g" /etc/httpd/conf/httpd.conf
262
FIC_MOD_SSL=`find /etc/httpd/modules.d/ -type f -name *mod_ssl.conf`
263
FIC_MOD_SSL=`find /etc/httpd/modules.d/ -type f -name *mod_ssl.conf`
263
$SED "s?^Listen.*?Listen $PRIVATE_IP:443?g" $FIC_MOD_SSL
264
$SED "s?^Listen.*?Listen $PRIVATE_IP:443?g" $FIC_MOD_SSL
264
$SED '/127.0.0.1/!s?Allow from .*?Allow from $PRIVATE_NETWORK_MASK?g'
265
$SED "/127.0.0.1/!s?Allow from .*?Allow from $PRIVATE_NETWORK_MASK?g" /etc/httpd/conf/webapps.d/alcasar.conf
-
 
266
# Dialup_Admin
-
 
267
$SED "s?^nas1_name:.*?nas1_name: alcasar-$ORGANISME?g" /etc/freeradius-web/naslist.conf
-
 
268
$SED "s?^nas1_ip:.*?nas1_ip: $PRIVATE_IP?g" /etc/freeradius-web/naslist.conf
265
 
269
# coova
-
 
270
$SED "s?ifconfig.*?ifconfig \$HS_LANIF $PRIVATE_IP?g" /etc/init.d/chilli
-
 
271
$SED "s?^net.*?net\t\t$PRIVATE_NETWORK_MASK?g" /etc/chilli.conf
-
 
272
$SED "s?^dynip.*?dynip\t\t$PRIVATE_DYN_IP?g" /etc/chilli.conf
-
 
273
$SED "s?^statip.*?statip\t\t$PRIVATE_STAT_IP?g" /etc/chilli.conf
-
 
274
$SED "s?^dns1.*?dns1\t\t$PRIVATE_IP?g" /etc/chilli.conf
-
 
275
$SED "s?^dns2.*?dns2\t\t$PRIVATE_IP?g" /etc/chilli.conf
-
 
276
$SED "s?^uamlisten.*?uamlisten\t$PRIVATE_IP?g" /etc/chilli.conf
-
 
277
$SED "s?^\$organisme = .*?\$organisme = \"$ORGANISME\";?g" /var/www/html/intercept.php /var/www/html/status.php
266
 
278
# awstat
-
 
279
$SED "s?^HostAliases=.*?HostAliases=\"$PRIVATE_IP\"?g" /etc/awstats/awstats.conf
-
 
280
# dnsmasq
-
 
281
$SED "/127.0.0.1/!s?^listen-address=.*?listen-address=$PRIVATE_IP?g" /etc/dnsmasq.conf /etc/dnsmasq-blackhole.conf
-
 
282
$SED "s?^server=.*?server=$DNS1?g" /etc/dnsmasq.conf /etc/dnsmasq-blackhole.conf
-
 
283
$SED "/$DNS1/!s?^server=.*?server=$DNS2?g" /etc/dnsmasq.conf /etc/dnsmasq-blackhole.conf
-
 
284
$SED "s?^dhcp-range=.*?dhcp-range=$PRIVATE_DYN_FIRST_IP,$PRIVATE_DYN_LAST_IP,$PRIVATE_NETMASK,12h?g" /etc/dnsmasq.conf
-
 
285
$SED "s?^dhcp-option=option:router.*?dhcp-option=option:router,$PRIVATE_IP?g" /etc/dnsmasq.conf
267
 
286
 
268
# Start / Stop SSH Daemon
287
# Start / Stop SSH Daemon
269
ssh_active=`grep SSH $CONF_FILE|cut -d"=" -f2`
288
ssh_active=`grep SSH $CONF_FILE|cut -d"=" -f2`
270
if [ $ssh_active = "on" ]
289
if [ $ssh_active = "on" ]
271
	then
290
	then
Line 273... Line 292...
273
else
292
else
274
/sbin/chkconfig --del sshd
293
/sbin/chkconfig --del sshd
275
fi
294
fi
276
 
295
 
277
 
296
 
278
$DIR_DEST_BIN/alcasar-iptables.sh
297
$DIR_BIN/alcasar-iptables.sh
279
		;;
298
		;;
280
	*)
299
	*)
281
		echo "Argument inconnu :$1";
300
		echo "Argument inconnu :$1";
282
		echo "$usage"
301
		echo "$usage"
283
		exit 1
302
		exit 1