diff options
Diffstat (limited to 'main/clamav/clamd.initd')
-rw-r--r-- | main/clamav/clamd.initd | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/main/clamav/clamd.initd b/main/clamav/clamd.initd new file mode 100644 index 000000000..d3b915557 --- /dev/null +++ b/main/clamav/clamd.initd @@ -0,0 +1,56 @@ +#!/sbin/runscript + +opts="logfix reload" +NAME=clamd +CONF=/etc/clamav/clamd.conf + +depend() { + need net + provide antivirus +} + +start() { + local clamd_socket=$(awk '$1 == "LocalSocket" { print $2 }' $CONF) + + logfix + + if [ -S "${clamd_socket:=/tmp/clamd}" ]; then + rm -f ${clamd_socket} + fi + ebegin "Starting ${NAME}" + start-stop-daemon --start --quiet \ + --nicelevel ${CLAMD_NICELEVEL:-0} \ + --exec /usr/sbin/clamd + eend $? "Failed to start ${NAME}" +} + +stop() { + ebegin "Stopping ${NAME}" + start-stop-daemon --stop --quiet --exec /usr/sbin/clamd + eend $? +} + +reload() { + ebegin "Reloading ${NAME}" + if ! service_started "${NAME}" ; then + eend 1 "${NAME} is not started" + return 1 + fi + start-stop-daemon --stop --oknodo --signal HUP \ + --exec /usr/sbin/clamd + eend $? +} + +logfix() { + # fix clamd log permissions + # (might be clobbered by logrotate or something) + local logfile=`awk '$1 == "LogFile" { print $2 }' $CONF` + local clamav_user=`awk '$1 == "User" { print $2 }' $CONF` + if [ -n "${logfile}" ] && [ -n "${clamav_user}" ]; then + if [ ! -f "${logfile}" ]; then + touch ${logfile} + fi + chown ${clamav_user} ${logfile} + chmod 640 ${logfile} + fi +} |