aboutsummaryrefslogtreecommitdiffstats
path: root/community/clamav/freshclam.initd
diff options
context:
space:
mode:
Diffstat (limited to 'community/clamav/freshclam.initd')
-rw-r--r--community/clamav/freshclam.initd54
1 files changed, 54 insertions, 0 deletions
diff --git a/community/clamav/freshclam.initd b/community/clamav/freshclam.initd
new file mode 100644
index 0000000000..6589da0bca
--- /dev/null
+++ b/community/clamav/freshclam.initd
@@ -0,0 +1,54 @@
+#!/sbin/openrc-run
+
+CONF=/etc/clamav/freshclam.conf
+
+pidfile=/run/clamav/freshclam.pid
+command=/usr/bin/freshclam
+extra_started_commands="reload"
+extra_commands="logfix"
+required_files=$CONF
+
+depend() {
+ need net
+ after firewall
+}
+
+start_pre() {
+ local pid=`awk '$1 == "PidFile" { print $2 }' $CONF`
+ local owner=`awk '$1 == "DatabaseOwner" { print $2 }' $CONF`
+ [ "x$pid" != "x" ] && pidfile=$pid
+ checkpath --directory --owner ${owner:-clamav} \
+ --mode 750 ${pidfile%/*}
+}
+
+start() {
+ ebegin "Starting freshclam"
+ start-stop-daemon --start --quiet \
+ --nicelevel ${FRESHCLAM_NICELEVEL:-0} \
+ --exec $command \
+ -- \
+ --daemon \
+ --pid=$pidfile
+ eend $?
+}
+
+reload() {
+ ebegin "Reloading ${SVCNAME}"
+ start-stop-daemon --signal HUP --pidfile $pidfile --name $SVCNAME
+ eend $?
+}
+
+logfix() {
+ # fix freshclam log permissions
+ # (might be clobbered by logrotate or something)
+ logfile=$(awk '$1 == "UpdateLogFile" { print $2 }' $CONF)
+ local freshclam_user=$(awk '$1 == "DatabaseOwner" { print $2 }' $CONF)
+ if [ -n "${logfile}" -a -n "${clamav_user}" ]; then
+ if [ ! -f "${logfile}" ]; then
+ checkpath -fm 0640 ${logfile}
+ else
+ chmod 640 ${logfile}
+ fi
+ chown ${freshclam_user} ${logfile}
+ fi
+}