Subversion Repositories ALCASAR

Rev

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

Rev 2282 Rev 2290
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
#  $Id: alcasar.sh 2282 2017-06-20 07:25:16Z richard $ 
2
#  $Id: alcasar.sh 2290 2017-06-20 10:00:17Z richard $ 
3
 
3
 
4
# alcasar.sh
4
# alcasar.sh
5
 
5
 
6
# ALCASAR Install script -  CopyLeft ALCASAR Team [Rexy + 3abtux + Steweb + Crox + ...] 
6
# ALCASAR Install script -  CopyLeft ALCASAR Team [Rexy + 3abtux + Steweb + Crox + ...] 
7
# Ce programme est un logiciel libre ; This software is free and open source
7
# Ce programme est un logiciel libre ; This software is free and open source
Line 222... Line 222...
222
		fi
222
		fi
223
		exit 0
223
		exit 0
224
	fi
224
	fi
225
	if [ ! -d /var/log/netflow/porttracker ]
225
	if [ ! -d /var/log/netflow/porttracker ]
226
		then
226
		then
227
# Test of free space on /var
227
# Test free space on /var
228
		free_space=`df -BG --output=avail /var|tail -1|tr -d [:space:]G`
228
		free_space=`df -BG --output=avail /var|tail -1|tr -d [:space:]G`
229
		if [ $free_space -lt 10 ]
229
		if [ $free_space -lt 10 ]
230
			then
230
			then
231
			if [ $Lang == "fr" ]
231
			if [ $Lang == "fr" ]
232
				then echo "place disponible sur /var insufisante ($free_space Go au lieu de 10 Go au minimum)"
232
				then echo "place disponible sur /var insufisante ($free_space Go au lieu de 10 Go au minimum)"
233
				else echo "not enough free space on /var ($free_space GB instead of at least 10 GB)"
233
				else echo "not enough free space on /var ($free_space GB instead of at least 10 GB)"
234
			fi
234
			fi
235
		exit 0
235
		exit 0
236
		fi
236
		fi
237
	fi
237
	fi
238
###########################################################################################
-
 
239
# Comparaison des interfaces et des fichiers d'interface présents
238
	if [ $Lang == "fr" ]
240
# Suppression des fichiers d'interface si l'interface n'est plus présente
239
		then echo -n "Tests des paramètres réseau : "
241
# Exemple: Cas d'un dongle USB GSM qui crée une interface réseau
240
		else echo -n "Network parameters tests : "
242
 
241
	fi
-
 
242
# Remove conf file if NIC is not plugged (ie : GSM/WIFI/Bt dongles)
243
	cd /etc/sysconfig/network-scripts/
243
	cd /etc/sysconfig/network-scripts/
244
	IF_INTERFACES=`ls ifcfg-*|grep -v "^lo"|cut -d"-" -f2|cut -d"*" -f1`
244
	IF_INTERFACES=`ls ifcfg-*|cut -d"-" -f2|grep -v "^lo"|cut -d"*" -f1`
245
 
-
 
246
	for i in $IF_INTERFACES
245
	for i in $IF_INTERFACES
247
	do
246
	do
248
		IP_INTERFACE=`/usr/sbin/ip link|grep $i`	
247
		IP_INTERFACE=`/usr/sbin/ip link|grep $i`	
249
		if [ -z "$IP_INTERFACE" ]
248
		if [ -z "$IP_INTERFACE" ]
250
		then
249
		then
Line 255... Line 254...
255
				else echo "Deleting : ifcfg-$i"
254
				else echo "Deleting : ifcfg-$i"
256
			fi
255
			fi
257
		fi
256
		fi
258
	done
257
	done
259
	cd $DIR_INSTALL
258
	cd $DIR_INSTALL
260
###########################################################################################
-
 
261
	if [ $Lang == "fr" ]
259
	echo -n "."
262
		then echo -n "Tests des paramètres réseau : "
-
 
263
		else echo -n "Network parameters tests : "
-
 
264
	fi
-
 
265
# Test of Ethernet links state
260
# Test Ethernet NIC links state 
266
	DOWN_IF=`/usr/sbin/ip link|grep -v "^w"|grep "NO-CARRIER"|cut -d":" -f2|tr -d " "`
261
	DOWN_IF=`/usr/sbin/ip link|grep "NO-CARRIER"|cut -d":" -f2|tr -d " "|grep -v "^w"`
267
	for i in $DOWN_IF
262
	for i in $DOWN_IF
268
	do
263
	do
-
 
264
		echo $i
269
		if [ $Lang == "fr" ]
265
		if [ $Lang == "fr" ]
270
		then 
266
		then 
271
			echo "Échec"
267
			echo "Échec"
272
			echo "Le lien réseau de la carte $i n'est pas actif."
268
			echo "Le lien réseau de la carte $i n'est pas actif."
273
			echo "Assurez-vous que cette carte est bien connectée à un équipement (commutateur, A.P., etc.)"
269
			echo "Assurez-vous que cette carte est bien connectée à un équipement (commutateur, A.P., etc.)"
Line 277... Line 273...
277
			echo "Make sure that this network card is connected to a switch or an A.P."
273
			echo "Make sure that this network card is connected to a switch or an A.P."
278
		fi
274
		fi
279
		exit 0
275
		exit 0
280
	done
276
	done
281
	echo -n "."
277
	echo -n "."
282
 
-
 
283
# Test EXTIF config files
278
# Test EXTIF config files
284
	PUBLIC_IP_MASK=`ip addr show $EXTIF|grep "inet "|cut -d" " -f6`
279
	PUBLIC_IP_MASK=`ip addr show $EXTIF|grep "inet "|cut -d" " -f6`
285
	PUBLIC_IP=`echo $PUBLIC_IP_MASK | cut -d"/" -f1`
280
	PUBLIC_IP=`echo $PUBLIC_IP_MASK | cut -d"/" -f1`
286
	PUBLIC_GATEWAY=`ip route list|grep $EXTIF|grep ^default|cut -d" " -f3`
281
	PUBLIC_GATEWAY=`ip route list|grep $EXTIF|grep ^default|cut -d" " -f3`
287
	if [ `echo $PUBLIC_IP|wc -c` -lt 7 ] || [ `echo $PUBLIC_GATEWAY|wc -c` -lt 7 ]
282
	if [ `echo $PUBLIC_IP|wc -c` -lt 7 ] || [ `echo $PUBLIC_GATEWAY|wc -c` -lt 7 ]
Line 306... Line 301...
306
		echo "DNS2="
301
		echo "DNS2="
307
		echo "ONBOOT=yes"
302
		echo "ONBOOT=yes"
308
		exit 0
303
		exit 0
309
	fi
304
	fi
310
	echo -n "."
305
	echo -n "."
311
 
-
 
312
# Test if router is alive (Box FAI)
306
# Test if default GW is set on EXTIF (router or ISP provider equipment)
313
	if [ `ip route list|grep $EXTIF|grep -c ^default` -ne "1" ] ; then
307
	if [ `ip route list|grep $EXTIF|grep -c ^default` -ne "1" ] ; then
314
		if [ $Lang == "fr" ]
308
		if [ $Lang == "fr" ]
315
		then 
309
		then 
316
			echo "Échec"
310
			echo "Échec"
317
			echo "Vous n'avez pas configuré l'accès à Internet ou le câble réseau n'est pas sur la bonne carte."
311
			echo "Vous n'avez pas configuré l'accès à Internet ou le câble réseau n'est pas sur la bonne carte."
Line 322... Line 316...
322
			echo "Resolv this problem, then restart this script."
316
			echo "Resolv this problem, then restart this script."
323
		fi
317
		fi
324
		exit 0
318
		exit 0
325
	fi
319
	fi
326
	echo -n "."
320
	echo -n "."
327
# On teste le lien vers le routeur par defaut
321
# Test if default GW is alive
328
	arp_reply=`/usr/sbin/arping -b -I$EXTIF -c1 -w2 $PUBLIC_GATEWAY|grep response|cut -d" " -f2`
322
	arp_reply=`/usr/sbin/arping -b -I$EXTIF -c1 -w2 $PUBLIC_GATEWAY|grep response|cut -d" " -f2`
329
	if [ $(expr $arp_reply) -eq 0 ]
323
	if [ $(expr $arp_reply) -eq 0 ]
330
	       	then
324
	       	then
331
		if [ $Lang == "fr" ]
325
		if [ $Lang == "fr" ]
332
		then 
326
		then 
333
			echo "Échec"
327
			echo "Échec"
334
			echo "Le routeur de site ou la Box Internet ($PUBLIC_GATEWAY) ne répond pas."
328
			echo "Le routeur de sortie ou la Box Internet ($PUBLIC_GATEWAY) ne répond pas."
335
			echo "Réglez ce problème puis relancez ce script."
329
			echo "Réglez ce problème puis relancez ce script."
336
		else
330
		else
337
			echo "Failed"
331
			echo "Failed"
338
			echo "The Internet gateway doesn't answered"
332
			echo "The Internet gateway or the ISP equipment ($PUBLIC_GATEWAY) doesn't answered."
339
			echo "Resolv this problem, then restart this script."
333
			echo "Resolv this problem, then restart this script."
340
		fi
334
		fi
341
		exit 0
335
		exit 0
342
	fi
336
	fi
343
	echo -n "."
337
	echo -n "."
344
# On teste la connectivité Internet
338
# Test Internet connectivity
345
	rm -rf /tmp/con_ok.html
339
	rm -rf /tmp/con_ok.html
346
	/usr/bin/curl www.google.fr -s -o /tmp/con_ok.html
340
	/usr/bin/curl www.google.fr -s -o /tmp/con_ok.html
347
	if [ ! -e /tmp/con_ok.html ]
341
	if [ ! -e /tmp/con_ok.html ]
348
	then
342
	then
349
		if [ $Lang == "fr" ]
343
		if [ $Lang == "fr" ]
Line 362... Line 356...
362
	echo ". : ok"
356
	echo ". : ok"
363
} # end of testing ()
357
} # end of testing ()
364
 
358
 
365
##################################################################
359
##################################################################
366
##			Function "init"				##
360
##			Function "init"				##
367
## - Création du fichier "/root/ALCASAR_parametres.txt"		##
361
## - Création du fichier "/root/ALCASAR_parametres.tx		##
368
## - Installation et modification des scripts du portail	##
362
## - Installation et modification des scripts du portail	##
369
##################################################################
363
##################################################################
370
init ()
364
init ()
371
{
365
{
372
	if [ "$mode" != "update" ]
366
	if [ "$mode" != "update" ]