Subversion Repositories ALCASAR

Rev

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

Rev 672 Rev 835
1
#/bin/bash
1
#/bin/bash
2
# $Id: alcasar-havp.sh 672 2011-07-08 15:34:22Z richard $
2
# $Id: alcasar-havp.sh 835 2012-03-11 22:21:27Z richard $
3
 
3
 
4
# alcasar-havp.sh
4
# alcasar-havp.sh
5
# by Richard REY
5
# by Rexy
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
# Activation / désactivation antivirus de flux WEB (Havp + LibClamav)
8
# Activation / désactivation antivirus de flux WEB (Havp + LibClamav)
9
# Enable / disable of WEB flow antivirus (HAVP + LibClamav)
9
# Enable / disable of WEB flow antivirus (HAVP + LibClamav)
10
 
10
 
11
CONF_FILE="/usr/local/etc/alcasar.conf"
11
CONF_FILE="/usr/local/etc/alcasar.conf"
12
SED="/bin/sed -i"
12
SED="/bin/sed -i"
13
function av_disable (){
13
function av_disable (){
-
 
14
	$SED "s/^cache_peer.*/#cache_peer 127\.0\.0\.1 parent 8090 0 no-query default/g" /etc/squid/squid.conf
14
	$SED "s/^proxyport =.*/proxyport = 3128/g" /etc/dansguardian/dansguardian.conf
15
	$SED "s/^never_direct.*/#never_direct allow all/g" /etc/squid/squid.conf
15
	$SED "s/^WEB_ANTIVIRUS=.*/WEB_ANTIVIRUS=off/g" /usr/local/etc/alcasar.conf
16
	$SED "s/^WEB_ANTIVIRUS=.*/WEB_ANTIVIRUS=off/g" /usr/local/etc/alcasar.conf
16
	service dansguardian reload
17
	service squid reload
17
	service havp stop
18
	service havp stop
18
}
19
}
19
function av_enable (){
20
function av_enable (){
-
 
21
	$SED "s/^#cache_peer.*/cache_peer 127\.0\.0\.1 parent 8090 0 no-query default/g" /etc/squid/squid.conf
20
	$SED "s/^proxyport =.*/proxyport = 8090/g" /etc/dansguardian/dansguardian.conf
22
	$SED "s/^#never_direct.*/never_direct allow all/g" /etc/squid/squid.conf
21
	$SED "s/^WEB_ANTIVIRUS=.*/WEB_ANTIVIRUS=on/g" /usr/local/etc/alcasar.conf
23
	$SED "s/^WEB_ANTIVIRUS=.*/WEB_ANTIVIRUS=on/g" /usr/local/etc/alcasar.conf
22
	service dansguardian reload
24
	service squid reload
23
	service havp start
25
	service havp start
24
}
26
}
25
usage="Usage: alcasar-havp.sh {--on or -on} | {--off or -off} | {--update or -update}"
27
usage="Usage: alcasar-havp.sh {--on or -on} | {--off or -off} | {--update or -update}"
26
nb_args=$#
28
nb_args=$#
27
args=$1
29
args=$1
28
if [ $nb_args -eq 0 ]
30
if [ $nb_args -eq 0 ]
29
then
31
then
30
	AV_FILTERING=`grep WEB_ANTIVIRUS $CONF_FILE|cut -d"=" -f2`		# DNS and URLs filter (on/off)
32
	AV_FILTERING=`grep WEB_ANTIVIRUS $CONF_FILE|cut -d"=" -f2`		# WEB-antivir  (on/off)
31
	AV_FILTERING=${AV_FILTERING:=on}
33
	AV_FILTERING=${AV_FILTERING:=on}
32
	echo "Set antivirus Filtering to $AV_FILTERING"
34
	echo "Set antivirus Filtering to $AV_FILTERING"
33
	if [ $AV_FILTERING = on ]; then
35
	if [ $AV_FILTERING = on ]; then
34
		av_enable
36
		av_enable
35
	else
37
	else
36
		av_disable
38
		av_disable
37
	fi
39
	fi
38
	exit 0
40
	exit 0
39
fi
41
fi
40
case $args in
42
case $args in
41
	-\? | -h* | --h*)
43
	-\? | -h* | --h*)
42
		echo "$usage"
44
		echo "$usage"
43
		exit 0
45
		exit 0
44
		;;
46
		;;
45
	--on|-on)	
47
	--on|-on)	
46
		av_enable
48
		av_enable
47
		;;
49
		;;
48
	--off|-off)
50
	--off|-off)
49
		av_disable
51
		av_disable
50
		;;
52
		;;
51
	--update|-update)
53
	--update|-update)
52
		#mise à jour de la base de signature
54
		#mise à jour de la base de signature
53
		freshclam
55
		freshclam
54
		;;		
56
		;;		
55
	*)
57
	*)
56
		echo "Argument inconnu :$1";
58
		echo "Argument inconnu :$1";
57
		echo "$usage"
59
		echo "$usage"
58
		exit 1
60
		exit 1
59
		;;
61
		;;
60
esac
62
esac
61
 
63
 
62
 
64