clamav: update to 0.99.2
[feed/packages.git] / net / clamav / files / clamav.init
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2015 OpenWrt.org
3
4 START=90
5 STOP=10
6
7 USE_PROCD=1
8 PROG=/usr/sbin/clamd
9 CLAMD_CONFIGFILE="/tmp/clamav/clamd.conf"
10
11 validate_clamav_section() {
12 uci_validate_section clamav clamav "${1}" \
13 'clamd_config_file:string' \
14 'LogFile:string' \
15 'LogFileMaxSize:string' \
16 'LogVerbose:string' \
17 'ExtendedDetectionInfo:string' \
18 'LogTime:string' \
19 'OfficialDatabaseOnly:string' \
20 'StreamMinPort:uinteger' \
21 'StreamMaxPort:uinteger' \
22 'MaxThreads:uinteger' \
23 'ReadTimeout:uinteger' \
24 'CommandReadTimeout:uinteger' \
25 'MaxDirectoryRecursion:uinteger' \
26 'FollowDirectorySymlinks:string' \
27 'FollowFileSymlinks:string' \
28 'SelfCheck:uinteger' \
29 'DetectPUA:string' \
30 'ScanPE:string' \
31 'DisableCertCheck:string' \
32 'ScanELF:string' \
33 'DetectBrokenExecutables:string' \
34 'ScanOLE2:string' \
35 'ScanPDF:string' \
36 'ScanSWF:string' \
37 'ScanMail:string' \
38 'ScanPartialMessages:string' \
39 'ScanArchive:string' \
40 'TemporaryDirectory:string' \
41 'ArchiveBlockEncrypted:string' \
42 'MaxFileSize:string' \
43 'LocalSocket:string' \
44 'User:string' \
45 'ExitOnOOM:string' \
46 'DatabaseDirectory:string'
47 }
48
49 start_service() {
50 local clamd_config_file LogFile LogTime StreamMinPort \
51 StreamMaxPort MaxThreads ReadTimeout CommandReadTimeout MaxDirectoryRecursion \
52 FollowFileSymlinks FollowDirectorySymlinks SelfCheck DetectPUA ScanPE DisableCertCheck \
53 ScanELF DetectBrokenExecutables ScanOLE2 ScanPDF ScanSWF ScanMail ScanPartialMessages \
54 ScanArchive TemporaryDirectory ArchiveBlockEncrypted MaxFileSize LocalSocket User \
55 DatabaseDirectory
56
57 validate_clamav_section clamav || {
58 echo "validation failed"
59 return 1
60 }
61
62 mkdir -p $DatabaseDirectory
63 mkdir -p /etc/clamav/
64 mkdir -p /var/run/clamav/
65 chmod a+rw /var/run/clamav
66
67 mkdir -p $(dirname $CLAMD_CONFIGFILE)
68 ln -sf $clamd_config_file $CLAMD_CONFIGFILE
69
70 echo "LogFile " $LogFile > $CLAMD_CONFIGFILE
71 echo "LogFileMaxSize " $LogFileMaxSize >> $CLAMD_CONFIGFILE
72 echo "LogVerbose " $LogVerbose >> $CLAMD_CONFIGFILE
73 echo "ExtendedDetectionInfo " $ExtendedDetectionInfo >> $CLAMD_CONFIGFILE
74 echo "LogTime " $LogTime >> $CLAMD_CONFIGFILE
75 echo "OfficialDatabaseOnly " $OfficialDatabaseOnly >> $CLAMD_CONFIGFILE
76 echo "StreamMinPort " $StreamMinPort >> $CLAMD_CONFIGFILE
77 echo "StreamMaxPort " $StreamMaxPort >> $CLAMD_CONFIGFILE
78 echo "MaxThreads " $MaxThreads >> $CLAMD_CONFIGFILE
79 echo "ReadTimeout " $ReadTimeout >> $CLAMD_CONFIGFILE
80 echo "CommandReadTimeout " $CommandReadTimeout >> $CLAMD_CONFIGFILE
81 echo "MaxDirectoryRecursion " $MaxDirectoryRecursion >> $CLAMD_CONFIGFILE
82 echo "FollowDirectorySymlinks " $FollowDirectorySymlinks >> $CLAMD_CONFIGFILE
83 echo "FollowFileSymlinks " $FollowFileSymlinks >> $CLAMD_CONFIGFILE
84 echo "SelfCheck " $SelfCheck >> $CLAMD_CONFIGFILE
85 echo "DetectPUA " $DetectPUA >> $CLAMD_CONFIGFILE
86 echo "ScanPE " $ScanPE >> $CLAMD_CONFIGFILE
87 echo "DisableCertCheck " $DisableCertCheck >> $CLAMD_CONFIGFILE
88 echo "ScanELF " $ScanELF >> $CLAMD_CONFIGFILE
89 echo "DetectBrokenExecutables " $DetectBrokenExecutables >> $CLAMD_CONFIGFILE
90 echo "ScanOLE2 " $ScanOLE2 >> $CLAMD_CONFIGFILE
91 echo "ScanPDF " $ScanPDF >> $CLAMD_CONFIGFILE
92 echo "ScanSWF " $ScanSWF >> $CLAMD_CONFIGFILE
93 echo "ScanMail " $ScanMail >> $CLAMD_CONFIGFILE
94 echo "ScanPartialMessages " $ScanPartialMessages >> $CLAMD_CONFIGFILE
95 echo "ScanArchive " $ScanArchive >> $CLAMD_CONFIGFILE
96 echo "TemporaryDirectory " $TemporaryDirectory >> $CLAMD_CONFIGFILE
97 echo "ArchiveBlockEncrypted " $ArchiveBlockEncrypted >> $CLAMD_CONFIGFILE
98 echo "MaxFileSize " $MaxFileSize >> $CLAMD_CONFIGFILE
99 echo "LocalSocket " $LocalSocket >> $CLAMD_CONFIGFILE
100 echo "User " $User >> $CLAMD_CONFIGFILE
101 echo "ExitOnOOM " $ExitOnOOM >> $CLAMD_CONFIGFILE
102 echo "DatabaseDirectory " $DatabaseDirectory >> $CLAMD_CONFIGFILE
103
104 procd_open_instance
105 procd_set_param command $PROG -c $CLAMD_CONFIGFILE
106 procd_set_param file $CLAMD_CONFIGFILE
107 procd_close_instance
108 }
109
110 stop_service()
111 {
112 service_stop ${PROG}
113 }
114
115 service_triggers()
116 {
117 procd_add_reload_trigger "clamav"
118 procd_add_validation validate_clamav_section
119 }