3 ### Enable the ClamAV services including starter config files and freshclam
4 ### Use once to enable and installed but inactive ClamAV virus toolkit in this
6 ### (C) 2016 by Jim Klimov
7 ### $Id: clamav-enable.sh,v 1.1 2016/02/05 00:00:00 jim Exp $
9 CLAMD_CONFFILE
=/etc
/clamav
/clamd.conf
10 CLAMMILT_CONFFILE
=/etc
/clamav
/clamav-milter.conf
11 FRESHCLAM_CONFFILE
=/etc
/clamav
/freshclam.conf
12 FRESHCLAM_RUNFILE
="/usr/bin/freshclam.sh"
14 ### After all, copying of configs and enablement of services should be separate:
15 ### freshclam depends on both its config and clamd.conf, but clamd service needs
16 ### the databases to start up...
17 for F
in "$CLAMD_CONFFILE" "$FRESHCLAM_CONFFILE" "$CLAMMILT_CONFFILE" ; do
18 S
="/usr/share/clamav/`basename "$F"`.sol"
19 if [ ! -s "$F" ] && [ -s "$S" ] ; then
20 echo "INFO: Copying default config '$S' into active config '$F'" >&2
25 echo "INFO: Nothing to change about active config '$F'" >&2
29 for F
in "$FRESHCLAM_CONFFILE" "$CLAMD_CONFFILE" "$CLAMMILT_CONFFILE" ; do
31 "$FRESHCLAM_CONFFILE")
33 echo "INFO: Enabling service: FRESHCLAM" >&2
34 [ -x "$FRESHCLAM_RUNFILE" ] && "$FRESHCLAM_RUNFILE"
35 theSMF_FMRI
="svc:/antivirus/freshclam:default"
36 svcadm refresh
"$theSMF_FMRI"
38 svcadm
enable -s "$theSMF_FMRI" # Let initial download pass
40 svcadm restart
"$theSMF_FMRI"
42 svcadm
clear "$theSMF_FMRI" 2>/dev
/null
&& sleep 5
44 svcs
-p "$theSMF_FMRI"
47 if [ -s "$F" -a -x "/usr/sbin/clamd" ]; then
48 echo "INFO: Enabling service: CLAMD" >&2
49 theSMF_FMRI
="svc:/antivirus/clamav:default"
50 svcadm refresh
"$theSMF_FMRI"
51 svcadm
enable "$theSMF_FMRI"
52 svcadm restart
"$theSMF_FMRI"
53 svcadm
clear "$theSMF_FMRI" 2>/dev
/null
&& sleep 5
55 svcs
-p "$theSMF_FMRI"
58 if [ -s "$F" -a -x "/usr/sbin/clamav-milter" ]; then
59 echo "INFO: Enabling service: CLAMAV-MILTER" >&2
60 theSMF_FMRI
="svc:/antivirus/clamav-milter:default"
61 svcadm refresh
"$theSMF_FMRI"
62 svcadm
enable "$theSMF_FMRI"
63 svcadm restart
"$theSMF_FMRI"
64 svcadm
clear "$theSMF_FMRI" 2>/dev
/null
&& sleep 5
66 svcs
-p "$theSMF_FMRI"