3dd4ae5
#! /bin/bash
3dd4ae5
# Copyright (C) 2005 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
3dd4ae5
#  
3dd4ae5
# This program is free software; you can redistribute it and/or modify
3dd4ae5
# it under the terms of the GNU General Public License as published by
3dd4ae5
# the Free Software Foundation; version 2 of the License.
3dd4ae5
#  
3dd4ae5
# This program is distributed in the hope that it will be useful,
3dd4ae5
# but WITHOUT ANY WARRANTY; without even the implied warranty of
3dd4ae5
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
3dd4ae5
# GNU General Public License for more details.
3dd4ae5
#  
3dd4ae5
# You should have received a copy of the GNU General Public License
3dd4ae5
# along with this program; if not, write to the Free Software
3dd4ae5
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
3dd4ae5
3dd4ae5
3dd4ae5
FRESHCLAM_MOD=$[ 3*60 ]		# 3 hours
3dd4ae5
3dd4ae5
f=/etc/sysconfig/freshclam
3dd4ae5
test ! -e "$f" || . "$f"
3dd4ae5
3dd4ae5
3dd4ae5
case x"$1" in
3dd4ae5
    (xnow)		FRESHCLAM_DELAY=0;;
3dd4ae5
    (x|xrandom)		: ${FRESHCLAM_DELAY:=$[ 0x`hostid` ]};;
3dd4ae5
    (*)			FRESHCLAM_DELAY=$1;;
3dd4ae5
esac
3dd4ae5
3dd4ae5
set -e
3dd4ae5
3dd4ae5
case $FRESHCLAM_DELAY in
3dd4ae5
    (disabled-warn)
3dd4ae5
	echo $"\
3dd4ae5
WARNING: update of clamav database is disabled; please see
3dd4ae5
  '$f'  
3dd4ae5
  for information how to enable the periodic update resp. how to turn
3dd4ae5
  off this message." >&2
3dd4ae5
	exit 1
3dd4ae5
	;;
3dd4ae5
3dd4ae5
    (disabled)
3dd4ae5
	exit 0
3dd4ae5
	;;
3dd4ae5
3dd4ae5
    (*)
5b64065
	let FRESHCLAM_MOD*=60
5b64065
	sleep $[ (FRESHCLAM_DELAY % FRESHCLAM_MOD + FRESHCLAM_MOD) % FRESHCLAM_MOD ]
3dd4ae5
	;;
3dd4ae5
esac
3dd4ae5
3dd4ae5
3dd4ae5
/usr/bin/freshclam --quiet && {
3dd4ae5
    test -x /usr/sbin/clamav-notify-servers &&  \
3dd4ae5
	exec /usr/sbin/clamav-notify-servers || \
3dd4ae5
	:
3dd4ae5
}