nrpe: update to 4.1.3
[oi-userland.git] / components / sysutils / clamav / files / clamav-enable.sh
blob31f886e70c0b6848e8cb7d01fa28e6913617ae15
1 #!/bin/sh
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
5 ### local zone or host
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
21 cp -pf "$S" "$F"
22 chown root:root "$F"
23 chmod 644 "$F"
24 else
25 echo "INFO: Nothing to change about active config '$F'" >&2
27 done
29 for F in "$FRESHCLAM_CONFFILE" "$CLAMD_CONFFILE" "$CLAMMILT_CONFFILE" ; do
30 case "$F" in
31 "$FRESHCLAM_CONFFILE")
32 if [ -s "$F" ]; then
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"
37 sleep 5
38 svcadm enable -s "$theSMF_FMRI" # Let initial download pass
39 sleep 5
40 svcadm restart "$theSMF_FMRI"
41 sleep 5
42 svcadm clear "$theSMF_FMRI" 2>/dev/null && sleep 5
43 sleep 1
44 svcs -p "$theSMF_FMRI"
45 fi ;;
46 "$CLAMD_CONFFILE")
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
54 sleep 1
55 svcs -p "$theSMF_FMRI"
56 fi ;;
57 "$CLAMMILT_CONFFILE")
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
65 sleep 1
66 svcs -p "$theSMF_FMRI"
67 fi ;;
68 esac
69 done