Subversion Repositories ALCASAR

Rev

Rev 672 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 672 Rev 791
1
#/bin/bash
1
#/bin/bash
2
# $Id: alcasar-nf.sh 672 2011-07-08 15:34:22Z richard $
2
# $Id: alcasar-nf.sh 791 2012-01-13 21:31:36Z richard $
3
 
3
 
4
# alcasar-nf.sh
4
# alcasar-nf.sh
5
# by Richard REY
5
# by Richard REY
6
# This script is distributed under the Gnu General Public License (GPL)
6
# This script is distributed under the Gnu General Public License (GPL)
7
 
7
 
8
# active ou desactive le filtrage de protocoles réseau
8
# active ou desactive le filtrage de protocoles réseau
9
# enable or disable the network protocols filter
9
# enable or disable the network protocols filter
10
 
10
 
11
SED="/bin/sed -i"
11
SED="/bin/sed -i"
12
FIC_SERVICES="/usr/local/etc/alcasar-services"
12
FIC_SERVICES="/usr/local/etc/alcasar-services"
13
FIC_EXCEPTIONS="/usr/local/etc/alcasar-filter-exceptions"
13
FIC_EXCEPTIONS="/usr/local/etc/alcasar-filter-exceptions"
14
FIC_CONF="/usr/local/etc/alcasar.conf"
14
FIC_CONF="/usr/local/etc/alcasar.conf"
15
 
15
 
16
usage="Usage: alcasar-nf.sh {--on | -on} | {--off | -off}"
16
usage="Usage: alcasar-nf.sh {--on | -on} | {--off | -off} | {--lan_ext_filter_on | -lan_ext_filter_on} | {--lan_ext_filter_off | -lan_ext_filter_off}"
17
nb_args=$#
17
nb_args=$#
18
args=$1
18
args=$1
19
if [ $nb_args -eq 0 ]
19
if [ $nb_args -eq 0 ]
20
then
20
then
21
	/usr/local/bin/alcasar-iptables.sh
21
	/usr/local/bin/alcasar-iptables.sh
22
	exit 1
22
	exit 1
23
fi
23
fi
24
case $args in
24
case $args in
25
	-\? | -h* | --h*)
25
	-\? | -h* | --h*)
26
		echo "$usage"
26
		echo "$usage"
27
		exit 0
27
		exit 0
28
		;;
28
		;;
29
	-on|-on) # enable protocols filter
29
	-on|-on) # enable protocols filter
30
		# sort service file
30
		# sort service file
31
		$SED "/^$/d" $FIC_SERVICES # delete empty lines
31
		$SED "/^$/d" $FIC_SERVICES # delete empty lines
32
		sort -k2n $FIC_SERVICES > /tmp/alcasar-services-sort
32
		sort -k2n $FIC_SERVICES > /tmp/alcasar-services-sort
33
		mv -f /tmp/alcasar-services-sort $FIC_SERVICES
33
		mv -f /tmp/alcasar-services-sort $FIC_SERVICES
34
		chown root:apache $FIC_SERVICES
34
		chown root:apache $FIC_SERVICES
35
		chmod 660 $FIC_SERVICES
35
		chmod 660 $FIC_SERVICES
36
		# vérify exception file 
36
		# vérify exception file 
37
		[ -e $FIC_EXCEPTIONS ] || touch $FIC_EXCEPTIONS
37
		[ -e $FIC_EXCEPTIONS ] || touch $FIC_EXCEPTIONS
38
		chown root:apache $FIC_EXCEPTIONS
38
		chown root:apache $FIC_EXCEPTIONS
39
		chmod 664 $FIC_EXCEPTIONS
39
		chmod 664 $FIC_EXCEPTIONS
40
		$SED "s?^PROTOCOLS_FILTERING.*?PROTOCOLS_FILTERING=on?g" $FIC_CONF
40
		$SED "s?^PROTOCOLS_FILTERING.*?PROTOCOLS_FILTERING=on?g" $FIC_CONF
41
		/usr/local/bin/alcasar-iptables.sh
41
		/usr/local/bin/alcasar-iptables.sh
42
		;;
42
		;;
43
	--off|-off) # disable protocols filter
43
	--off|-off) # disable protocols filter
44
		$SED "s?^PROTOCOLS_FILTERING.*?PROTOCOLS_FILTERING=off?g" $FIC_CONF
44
		$SED "s?^PROTOCOLS_FILTERING.*?PROTOCOLS_FILTERING=off?g" $FIC_CONF
45
		/usr/local/bin/alcasar-iptables.sh
45
		/usr/local/bin/alcasar-iptables.sh
-
 
46
		;;
-
 
47
	--lan_ext_filter_on|-lan_ext_filter_on) # allow external LAN access (LAN located between ALCASAR and the Internet gateway)
-
 
48
		$SED "s?^EXT_LAN_FILTERING.*?EXT_LAN_FILTERING=on?g" $FIC_CONF
-
 
49
		/usr/local/bin/alcasar-iptables.sh
-
 
50
		;;
-
 
51
	--lan_ext_filter_off|-lan_ext_filter_off) # allow external LAN access (LAN located between ALCASAR and the Internet gateway)
-
 
52
		$SED "s?^EXT_LAN_FILTERING.*?EXT_LAN_FILTERING=off?g" $FIC_CONF
-
 
53
		/usr/local/bin/alcasar-iptables.sh
46
		;;
54
		;;
47
	*)
55
	*)
48
		echo "Argument inconnu :$1";
56
		echo "Argument inconnu :$1";
49
		echo "$usage"
57
		echo "$usage"
50
		exit 1
58
		exit 1
51
		;;
59
		;;
52
esac
60
esac
53
 
61
 
54
 
62