Files @ 32434a92d02a
Branch filter:

Location: ohnobinki_overlay/app-antivirus/clamav/files/clamd.rc

binki
Fixed clamav-0.95.2.ebuild from Portage. Made initscripts modular.

Also added userflag clamdtop to metadata.xml, made misc. improvements IMO ;-)
#!/sbin/runscript
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/app-antivirus/clamav/files/clamd.rc,v 1.16 2008/02/29 23:46:46 ticho Exp $

opts="logfix"

depend() {
	use net
	provide antivirus
}

start() {
	local clamd_socket=`awk '$1 == "LocalSocket" { print $2 }' /etc/clamd.conf`

	logfix

	if [ -S "${clamd_socket:-/tmp/clamd}" ]; then
	    rm -f ${clamd_socket:-/tmp/clamd}
	fi
	ebegin "Starting clamd"
	start-stop-daemon --start --quiet \
	    --nicelevel ${CLAMD_NICELEVEL:-0} \
	    --exec /usr/sbin/clamd

	local retcode=$?
	if [ ${retcode} != 0 ]; then
	    eend ${retcode} "Failed to start clamd"
	    return ${retcode};
	fi
	
	local clamd_socket_wait_count=0
	local clamd_socket_wait_max=10
	local clamd_socket_wait_result=-1
	ebegin "Waiting for clamd to create ${clamd_socket}"
	while (( clamd_socket_wait < clamd_socket_wait_max )); do
	    if [ -S "${clamd_socket:-/tmp/clamd}" ]; then
		clamd_socket_wait_result=0
		break
	    else
		echo -n " ."
		let clamd_socket_wait++
		sleep 1
	    fi
	done
	echo
	eend $clamd_socket_wait_result "Timeout waiting for ${clamd_socket}"
}

stop() {
    ebegin "Stopping clamd"
    start-stop-daemon --stop --quiet --exec /usr/sbin/clamd
    eend $? "Failed to stop clamd"
}

logfix() {
    # fix clamd log permissions
    # (might be clobbered by logrotate or something)
    local logfile=`awk '$1 == "LogFile" { print $2 }' /etc/clamd.conf`
    local clamav_user=`awk '$1 == "User" { print $2 }' /etc/clamd.conf`
    if [ -n "${logfile}" ] && [ -n "${clamav_user}" ]; then
	if [ ! -f "${logfile}" ]; then
	    touch ${logfile}
	fi
	chown ${clamav_user} ${logfile}
	chmod 640 ${logfile}
    fi
}