Subversion Repositories ALCASAR

Rev

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

Rev 2281 Rev 2282
Line 1... Line 1...
1
#!/bin/bash
1
#!/bin/bash
2
#  $Id: alcasar.sh 2281 2017-06-19 18:30:33Z tom.houdayer $ 
2
#  $Id: alcasar.sh 2282 2017-06-20 07:25:16Z 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 233... Line 233...
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
-
 
240
# Suppression des fichiers d'interface si l'interface n'est plus présente
-
 
241
# Exemple: Cas d'un dongle USB GSM qui crée une interface réseau
-
 
242
 
-
 
243
	cd /etc/sysconfig/network-scripts/
-
 
244
	IF_INTERFACES=`ls ifcfg-*|grep -v "^lo"|cut -d"-" -f2|cut -d"*" -f1`
-
 
245
 
-
 
246
	for i in $IF_INTERFACES
-
 
247
	do
-
 
248
		IP_INTERFACE=`/usr/sbin/ip link|grep $i`	
-
 
249
		if [ -z "$IP_INTERFACE" ]
-
 
250
		then
-
 
251
			rm -f ifcfg-$i
-
 
252
			
-
 
253
			if [ $Lang == "fr" ]
-
 
254
				then echo "Suppression : ifcfg-$i"
-
 
255
				else echo "Deleting : ifcfg-$i"
-
 
256
			fi
-
 
257
		fi
-
 
258
	done
-
 
259
	cd $DIR_INSTALL
-
 
260
###########################################################################################
238
	if [ $Lang == "fr" ]
261
	if [ $Lang == "fr" ]
239
		then echo -n "Tests des paramètres réseau : "
262
		then echo -n "Tests des paramètres réseau : "
240
		else echo -n "Network parameters tests : "
263
		else echo -n "Network parameters tests : "
241
	fi
264
	fi
242
# Test of Ethernet links state
265
# Test of Ethernet links state
243
	DOWN_IF=`/usr/sbin/ip link|grep "NO-CARRIER"|cut -d":" -f2|tr -d " "`
266
	DOWN_IF=`/usr/sbin/ip link|grep -v "^w"|grep "NO-CARRIER"|cut -d":" -f2|tr -d " "`
244
	for i in $DOWN_IF
267
	for i in $DOWN_IF
245
	do
268
	do
246
		if [ $Lang == "fr" ]
269
		if [ $Lang == "fr" ]
247
		then 
270
		then 
248
			echo "Échec"
271
			echo "Échec"
Line 492... Line 515...
492
	PUBLIC_PREFIX=`/bin/ipcalc -p $PUBLIC_IP $PUBLIC_NETMASK|cut -d"=" -f2`
515
	PUBLIC_PREFIX=`/bin/ipcalc -p $PUBLIC_IP $PUBLIC_NETMASK|cut -d"=" -f2`
493
	PUBLIC_NETWORK=`/bin/ipcalc -n $PUBLIC_IP/$PUBLIC_PREFIX|cut -d"=" -f2`
516
	PUBLIC_NETWORK=`/bin/ipcalc -n $PUBLIC_IP/$PUBLIC_PREFIX|cut -d"=" -f2`
494
# Wrtie the conf file
517
# Wrtie the conf file
495
	echo "EXTIF=$EXTIF" >> $CONF_FILE
518
	echo "EXTIF=$EXTIF" >> $CONF_FILE
496
	echo "INTIF=$INTIF" >> $CONF_FILE
519
	echo "INTIF=$INTIF" >> $CONF_FILE
-
 
520
	######## Récupération des interfaces du ou des réseaux de consultation supplémentaires #################
-
 
521
	INTERFACES=`/usr/sbin/ip link|grep '^[[:digit:]]:'|grep -v "^lo\|$EXTIF\|tun0"|cut -d " " -f2|tr -d ":"`
-
 
522
 
-
 
523
	for i in $INTERFACES
-
 
524
	do
-
 
525
		SUB=`echo ${i:0:2}`
-
 
526
		if [ $SUB = "wl" ]
-
 
527
			then WIFIF=$i
-
 
528
		elif [ "$i" != "$INTIF" ] && [ $SUB != "ww" ] 
-
 
529
			then LANIF=$i
-
 
530
		fi
-
 
531
	done
-
 
532
 
-
 
533
	if [ -n "$WIFIF" ]
-
 
534
		then echo "WIFIF=$WIFIF" >> $CONF_FILE
-
 
535
	elif [ -n "$LANIF" ]
-
 
536
		then echo "LANIF=$LANIF" >> $CONF_FILE
-
 
537
	fi
-
 
538
	#########################################################################################################	
-
 
539
	
497
	IP_SETTING=`grep BOOTPROTO /etc/sysconfig/network-scripts/ifcfg-$EXTIF|cut -d"=" -f2`		# IP setting (static or dynamic)
540
	IP_SETTING=`grep BOOTPROTO /etc/sysconfig/network-scripts/ifcfg-$EXTIF|cut -d"=" -f2`		# IP setting (static or dynamic)
498
	if [ $IP_SETTING == "dhcp" ]
541
	if [ $IP_SETTING == "dhcp" ]
499
		then
542
		then
500
		echo "PUBLIC_IP=dhcp" >> $CONF_FILE
543
		echo "PUBLIC_IP=dhcp" >> $CONF_FILE
501
		echo "GW=dhcp" >> $CONF_FILE
544
		echo "GW=dhcp" >> $CONF_FILE
Line 592... Line 635...
592
IPV6INIT=no
635
IPV6INIT=no
593
IPV6TO4INIT=no
636
IPV6TO4INIT=no
594
ACCOUNTING=no
637
ACCOUNTING=no
595
USERCTL=no
638
USERCTL=no
596
EOF
639
EOF
-
 
640
######### Config WIFIF (consultation WIFI) ou LANIF (consultation LAN) in normal mode #################
-
 
641
	if [ -n "$WIFIF" ] && [ "$WIFIF" != "$INTIF" ]
-
 
642
	then
-
 
643
		cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-$WIFIF
-
 
644
DEVICE=$WIFIF
-
 
645
BOOTPROTO=static
-
 
646
ONBOOT=yes
-
 
647
NOZEROCONF=yes
-
 
648
MII_NOT_SUPPORTED=yes
-
 
649
IPV6INIT=no
-
 
650
IPV6TO4INIT=no
-
 
651
ACCOUNTING=no
-
 
652
USERCTL=no
-
 
653
EOF
-
 
654
	elif [ -n "$LANIF" ]
-
 
655
	then
-
 
656
		cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-$LANIF
-
 
657
DEVICE=$LANIF
-
 
658
BOOTPROTO=static
-
 
659
ONBOOT=yes
-
 
660
NOZEROCONF=yes
-
 
661
MII_NOT_SUPPORTED=yes
-
 
662
IPV6INIT=no
-
 
663
IPV6TO4INIT=no
-
 
664
ACCOUNTING=no
-
 
665
USERCTL=no
-
 
666
EOF
-
 
667
	fi
-
 
668
	#########################################################################################################	
597
# Renseignement des fichiers hosts.allow et hosts.deny
669
# Renseignement des fichiers hosts.allow et hosts.deny
598
	[ -e /etc/hosts.allow.default ]  || cp /etc/hosts.allow /etc/hosts.allow.default
670
	[ -e /etc/hosts.allow.default ]  || cp /etc/hosts.allow /etc/hosts.allow.default
599
	cat <<EOF > /etc/hosts.allow
671
	cat <<EOF > /etc/hosts.allow
600
ALL: LOCAL, 127.0.0.1, localhost, $PRIVATE_IP
672
ALL: LOCAL, 127.0.0.1, localhost, $PRIVATE_IP
601
sshd: ALL
673
sshd: ALL