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