diff --git a/app-antivirus/clamav/files/freshclam.rc b/app-antivirus/clamav/files/freshclam.rc new file mode 100755 --- /dev/null +++ b/app-antivirus/clamav/files/freshclam.rc @@ -0,0 +1,44 @@ +#!/sbin/runscript +# Copyright 1999-2005 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +depend() { + use net +} + +start() { + logfix + + ebegin "Starting freshclam" + start-stop-daemon --start --quiet \ + --nicelevel ${FRESHCLAM_NICELEVEL:-0} \ + --exec /usr/bin/freshclam -- -d + retcode=$? + if [ ${retcode} = 1 ]; then + eend 0 + einfo "Virus database already up to date." + else + eend ${retcode} + fi +} + +stop() { + ebegin "Stopping freshclam" + start-stop-daemon --stop --quiet --exec /usr/bin/freshclam + eend $? +} + +logfix() { + # fix freshclam log permissions + # (might be clobbered by logrotate or something) + logfile=`awk '$1 == "UpdateLogFile" { print $2 }' /etc/freshclam.conf` + local freshclam_user=`awk '$1 == "DatabaseOwner" { print $2 }' /etc/freshclam.conf` + if [ -n "${logfile}" -a -n "${clamav_user}" ]; then + if [ ! -f "${logfile}" ]; then + touch ${logfile} + fi + chown ${freshclam_user} ${logfile} + chmod 640 ${logfile} + fi +}