1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2015 OpenWrt.org
9 CLAMD_CONFIGFILE
="/tmp/clamav/clamd.conf"
11 validate_clamav_section
() {
12 uci_validate_section clamav clamav
"${1}" \
13 'clamd_config_file:string' \
15 'LogFileMaxSize:string' \
17 'ExtendedDetectionInfo: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' \
31 'DisableCertCheck:string' \
33 'DetectBrokenExecutables:string' \
38 'ScanPartialMessages:string' \
39 'ScanArchive:string' \
40 'TemporaryDirectory:string' \
41 'ArchiveBlockEncrypted:string' \
42 'MaxFileSize:string' \
43 'LocalSocket:string' \
49 local clamd_config_file LogFile LogTime StreamMinPort \
50 StreamMaxPort MaxThreads ReadTimeout CommandReadTimeout MaxDirectoryRecursion \
51 FollowFileSymlinks FollowDirectorySymlinks SelfCheck DetectPUA ScanPE DisableCertCheck \
52 ScanELF DetectBrokenExecutables ScanOLE2 ScanPDF ScanSWF ScanMail ScanPartialMessages \
53 ScanArchive TemporaryDirectory ArchiveBlockEncrypted MaxFileSize LocalSocket User
55 validate_clamav_section clamav ||
{
56 echo "validation failed"
60 mkdir
-p /usr
/share
/clamav
62 mkdir
-p /var
/run
/clamav
/
63 chmod a
+rw
/var
/run
/clamav
65 mkdir
-p $
(dirname $CLAMD_CONFIGFILE)
66 ln -sf $clamd_config_file $CLAMD_CONFIGFILE
68 echo "LogFile " $LogFile > $CLAMD_CONFIGFILE
69 echo "LogFileMaxSize " $LogFileMaxSize >> $CLAMD_CONFIGFILE
70 echo "LogVerbose " $LogVerbose >> $CLAMD_CONFIGFILE
71 echo "ExtendedDetectionInfo " $ExtendedDetectionInfo >> $CLAMD_CONFIGFILE
72 echo "LogTime " $LogTime >> $CLAMD_CONFIGFILE
73 echo "OfficialDatabaseOnly " $OfficialDatabaseOnly >> $CLAMD_CONFIGFILE
74 echo "StreamMinPort " $StreamMinPort >> $CLAMD_CONFIGFILE
75 echo "StreamMaxPort " $StreamMaxPort >> $CLAMD_CONFIGFILE
76 echo "MaxThreads " $MaxThreads >> $CLAMD_CONFIGFILE
77 echo "ReadTimeout " $ReadTimeout >> $CLAMD_CONFIGFILE
78 echo "CommandReadTimeout " $CommandReadTimeout >> $CLAMD_CONFIGFILE
79 echo "MaxDirectoryRecursion " $MaxDirectoryRecursion >> $CLAMD_CONFIGFILE
80 echo "FollowDirectorySymlinks " $FollowDirectorySymlinks >> $CLAMD_CONFIGFILE
81 echo "FollowFileSymlinks " $FollowFileSymlinks >> $CLAMD_CONFIGFILE
82 echo "SelfCheck " $SelfCheck >> $CLAMD_CONFIGFILE
83 echo "DetectPUA " $DetectPUA >> $CLAMD_CONFIGFILE
84 echo "ScanPE " $ScanPE >> $CLAMD_CONFIGFILE
85 echo "DisableCertCheck " $DisableCertCheck >> $CLAMD_CONFIGFILE
86 echo "ScanELF " $ScanELF >> $CLAMD_CONFIGFILE
87 echo "DetectBrokenExecutables " $DetectBrokenExecutables >> $CLAMD_CONFIGFILE
88 echo "ScanOLE2 " $ScanOLE2 >> $CLAMD_CONFIGFILE
89 echo "ScanPDF " $ScanPDF >> $CLAMD_CONFIGFILE
90 echo "ScanSWF " $ScanSWF >> $CLAMD_CONFIGFILE
91 echo "ScanMail " $ScanMail >> $CLAMD_CONFIGFILE
92 echo "ScanPartialMessages " $ScanPartialMessages >> $CLAMD_CONFIGFILE
93 echo "ScanArchive " $ScanArchive >> $CLAMD_CONFIGFILE
94 echo "TemporaryDirectory " $TemporaryDirectory >> $CLAMD_CONFIGFILE
95 echo "ArchiveBlockEncrypted " $ArchiveBlockEncrypted >> $CLAMD_CONFIGFILE
96 echo "MaxFileSize " $MaxFileSize >> $CLAMD_CONFIGFILE
97 echo "LocalSocket " $LocalSocket >> $CLAMD_CONFIGFILE
98 echo "User " $User >> $CLAMD_CONFIGFILE
99 echo "ExitOnOOM " $ExitOnOOM >> $CLAMD_CONFIGFILE
102 procd_set_param
command $PROG -c $CLAMD_CONFIGFILE
103 procd_set_param
file $CLAMD_CONFIGFILE
114 procd_add_reload_trigger
"clamav"
115 procd_add_validation validate_clamav_section