Subversion Repositories ALCASAR

Rev

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

Rev Author Line No. Line
1 root 1
#/bin/sh
63 franck 2
# $Id: alcasar-nf.sh 612 2011-05-22 21:19:27Z richard $
3
 
520 richard 4
# active ou desactive le filtrage de protocoles réseau
5
# enable or disable the network protocols filter
1 root 6
# by rexy
520 richard 7
 
1 root 8
SED="/bin/sed -i"
9
FIC_SERVICES="/usr/local/etc/alcasar-services"
28 richard 10
FIC_EXCEPTIONS="/usr/local/etc/alcasar-filter-exceptions"
612 richard 11
FIC_CONF="/usr/local/etc/alcasar.conf"
1 root 12
 
393 franck 13
usage="Usage: alcasar-nf.sh {--on or -on} | {--off | -off} "
1 root 14
nb_args=$#
15
args=$1
16
if [ $nb_args -eq 0 ]
17
then
18
	nb_args=1
19
	args="-h"
20
fi
21
case $args in
22
	-\? | -h* | --h*)
23
		echo "$usage"
24
		exit 0
25
		;;
393 franck 26
	-on|-on)	
1 root 27
		# activation du filtrage réseau
612 richard 28
		$SED "s?^PROTOCOLS_FILTERING.*?PROTOCOLS_FILTERING=on?g" $FIC_CONF
1 root 29
		# tri du fichier de services
323 richard 30
		$SED "/^$/d" $FIC_SERVICES # suppression lignes vides
1 root 31
		sort -k2n $FIC_SERVICES > /tmp/alcasar-services-sort
32
		mv -f /tmp/alcasar-services-sort $FIC_SERVICES
33
		chown root:apache $FIC_SERVICES
34
		chmod 660 $FIC_SERVICES
25 richard 35
		# vérification de présence du fichier d'exception
36
		[ -e $FIC_EXCEPTIONS ] || touch $FIC_EXCEPTIONS
37
		chown root:apache $FIC_EXCEPTIONS
38
		chmod 664 $FIC_EXCEPTIONS
1 root 39
		/usr/local/bin/alcasar-iptables.sh
40
		;;
393 franck 41
	--off|-off)
1 root 42
		# désactivation du filtrage réseau
612 richard 43
		$SED "s?^PROTOCOLS_FILTERING.*?PROTOCOLS_FILTERING=off?g" $FIC_CONF
1 root 44
		/usr/local/bin/alcasar-iptables.sh
45
		;;
46
	*)
47
		echo "Argument inconnu :$1";
48
		echo "$usage"
49
		exit 1
50
		;;
51
esac
52