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