1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2015 OpenWrt.org
8 PROG
=/usr
/sbin
/freshclam
9 FRESHCLAM_CONFIGFILE
="/tmp/clamav/freshclam.conf"
11 validate_freshclam_section
() {
12 uci_validate_section freshclam freshclam
"${1}" \
13 'freshclam_config_file:string' \
14 'UpdateLogFile:string' \
15 'DatabaseMirror:string' \
16 'NotifyClamd:string' \
17 'DatabaseOwner:string' \
18 'CompressLocalDatabase:string:'
22 local freshclam_config_file UpdateLogFile DatabaseOwner NotifyClamd DatabaseMirror
24 validate_freshclam_section freshclam ||
{
25 echo "validation failed"
29 [ -f /tmp
/freshclam.pid
] && echo "already running" && return 0
31 mkdir
-p /usr
/share
/clamav
33 touch /tmp
/freshclam.log
34 touch /tmp
/freshclam.pid
36 mkdir
-p $
(dirname $FRESHCLAM_CONFIGFILE)
37 ln -sf $freshclam_config_file $FRESHCLAM_CONFIGFILE
39 echo "UpdateLogFile " $UpdateLogFile > $FRESHCLAM_CONFIGFILE
40 echo "DatabaseMirror " $DatabaseMirror >> $FRESHCLAM_CONFIGFILE
41 echo "NotifyClamd " $NotifyClamd >> $FRESHCLAM_CONFIGFILE
42 echo "DatabaseOwner " $DatabaseOwner >> $FRESHCLAM_CONFIGFILE
43 echo "CompressLocalDatabase " $CompressLocalDatabase >> $FRESHCLAM_CONFIGFILE
46 procd_set_param
command $PROG -d --config-file=$FRESHCLAM_CONFIGFILE -p /tmp
/freshclam.pid
--no-warnings
47 procd_set_param
file $FRESHCLAM_CONFIGFILE
53 [ ! -f /tmp
/freshclam.pid
] && echo "not running" && return 0
54 PID
=`cat /tmp/freshclam.pid`
56 rm -f /tmp
/freshclam.pid
61 procd_add_reload_trigger
"freshclam"
62 procd_add_validation validate_freshclam_section