Subversion Repositories ALCASAR

Rev

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

Rev 1056 Rev 1377
1
#/bin/bash
1
#/bin/bash
2
# $Id: alcasar-havp.sh 1056 2013-03-26 21:46:36Z stephane $
2
# $Id: alcasar-havp.sh 1377 2014-06-10 22:16:50Z richard $
3
 
3
 
4
# alcasar-havp.sh
4
# alcasar-havp.sh
5
# by Rexy
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/^cache_peer.*/#cache_peer 127\.0\.0\.1 parent 8090 0 no-query default/g" /etc/squid/squid.conf
15
	$SED "s/^never_direct.*/#never_direct allow all/g" /etc/squid/squid.conf
15
	$SED "s/^never_direct.*/#never_direct allow all/g" /etc/squid/squid.conf
16
	$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
17
	service squid reload
-
 
18
	service havp stop
17
	service havp stop
19
}
18
}
20
function av_enable (){
19
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/^#cache_peer.*/cache_peer 127\.0\.0\.1 parent 8090 0 no-query default/g" /etc/squid/squid.conf
22
	$SED "s/^#never_direct.*/never_direct allow all/g" /etc/squid/squid.conf
21
	$SED "s/^#never_direct.*/never_direct allow all/g" /etc/squid/squid.conf
23
	$SED "s/^WEB_ANTIVIRUS=.*/WEB_ANTIVIRUS=on/g" /usr/local/etc/alcasar.conf
22
	$SED "s/^WEB_ANTIVIRUS=.*/WEB_ANTIVIRUS=on/g" /usr/local/etc/alcasar.conf
24
	service squid reload
-
 
25
	service havp start
23
	service havp start
26
}
24
}
27
usage="Usage: alcasar-havp.sh {--on or -on} | {--off or -off} | {--update or -update}"
25
usage="Usage: alcasar-havp.sh {--on or -on} | {--off or -off} | {--update or -update}"
28
nb_args=$#
26
nb_args=$#
29
args=$1
27
args=$1
30
if [ $nb_args -eq 0 ]
28
if [ $nb_args -eq 0 ]
31
then
29
then
32
	AV_FILTERING=`grep WEB_ANTIVIRUS $CONF_FILE|cut -d"=" -f2`		# WEB-antivir  (on/off)
30
	AV_FILTERING=`grep WEB_ANTIVIRUS $CONF_FILE|cut -d"=" -f2`		# WEB-antivir  (on/off)
33
	AV_FILTERING=${AV_FILTERING:=on}
31
	AV_FILTERING=${AV_FILTERING:=on}
34
	echo "Set antivirus Filtering to $AV_FILTERING"
32
	echo "Set antivirus Filtering to $AV_FILTERING"
35
	if [ $AV_FILTERING = on ]; then
33
	if [ $AV_FILTERING = on ]; then
36
		av_enable
34
		av_enable
37
	else
35
	else
38
		av_disable
36
		av_disable
39
	fi
37
	fi
40
	exit 0
38
	exit 0
41
fi
39
fi
42
case $args in
40
case $args in
43
	-\? | -h* | --h*)
41
	-\? | -h* | --h*)
44
		echo "$usage"
42
		echo "$usage"
45
		exit 0
43
		exit 0
46
		;;
44
		;;
47
	--on|-on)	
45
	--on|-on)	
48
		av_enable
46
		av_enable
49
		;;
47
		;;
50
	--off|-off)
48
	--off|-off)
51
		av_disable
49
		av_disable
52
		;;
50
		;;
53
	--update|-update)
51
	--update|-update)
54
		#mise à jour de la base de signature
52
		#mise à jour de la base de signature
55
		freshclam
53
		freshclam
56
		;;		
54
		;;		
57
	*)
55
	*)
58
		echo "Argument inconnu :$1";
56
		echo "Argument inconnu :$1";
59
		echo "$usage"
57
		echo "$usage"
60
		exit 1
58
		exit 1
61
		;;
59
		;;
62
esac
60
esac
63
 
61
 
64
 
62