clamav: add package

Signed-off-by: Marko Ratkaj <marko.ratkaj@sartura.hr>
This commit is contained in:
Marko Ratkaj
2015-05-21 12:45:16 +02:00
committed by Luka Perkov
parent 8c13dbd2e1
commit f9507c02e0
7 changed files with 350 additions and 0 deletions
Binary file not shown.
+34
View File
@@ -0,0 +1,34 @@
config clamav 'clamav'
option clamd_config_file '/etc/clamav/clamd.conf'
option LogFile '/tmp/clamd.log'
option LogFileMaxSize '1M'
option LogTime 'no'
option LogVerbose 'no'
option ExtendedDetectionInfo 'no'
option OfficialDatabaseOnly 'no'
option StreamMinPort '1024'
option StreamMaxPort '2048'
option MaxThreads '10'
option ReadTimeout '30'
option CommandReadTimeout '5'
option MaxDirectoryRecursion '15'
option FollowDirectorySymlinks 'no'
option FollowFileSymlinks 'no'
option SelfCheck '600'
option DetectPUA 'yes'
option ScanPE 'yes'
option DisableCertCheck 'no'
option ScanELF 'yes'
option DetectBrokenExecutables 'no'
option ScanOLE2 'yes'
option ScanPDF 'yes'
option ScanSWF 'yes'
option ScanMail 'yes'
option ScanPartialMessages 'no'
option ScanArchive 'yes'
option ArchiveBlockEncrypted 'yes'
option MaxFileSize '10M'
option TemporaryDirectory '/tmp'
option LocalSocket '/var/run/clamav/clamd.sock'
option User 'nobody'
option ExitOnOOM 'yes'
+116
View File
@@ -0,0 +1,116 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2015 OpenWrt.org
START=90
STOP=10
USE_PROCD=1
PROG=/usr/sbin/clamd
CLAMD_CONFIGFILE="/tmp/clamav/clamd.conf"
validate_clamav_section() {
uci_validate_section clamav clamav "${1}" \
'clamd_config_file:string' \
'LogFile:string' \
'LogFileMaxSize:string' \
'LogVerbose:string' \
'ExtendedDetectionInfo:string' \
'LogTime:string' \
'OfficialDatabaseOnly:string' \
'StreamMinPort:uinteger' \
'StreamMaxPort:uinteger' \
'MaxThreads:uinteger' \
'ReadTimeout:uinteger' \
'CommandReadTimeout:uinteger' \
'MaxDirectoryRecursion:uinteger' \
'FollowDirectorySymlinks:string' \
'FollowFileSymlinks:string' \
'SelfCheck:uinteger' \
'DetectPUA:string' \
'ScanPE:string' \
'DisableCertCheck:string' \
'ScanELF:string' \
'DetectBrokenExecutables:string' \
'ScanOLE2:string' \
'ScanPDF:string' \
'ScanSWF:string' \
'ScanMail:string' \
'ScanPartialMessages:string' \
'ScanArchive:string' \
'TemporaryDirectory:string' \
'ArchiveBlockEncrypted:string' \
'MaxFileSize:string' \
'LocalSocket:string' \
'User:string' \
'ExitOnOOM:string'
}
start_service() {
local clamd_config_file LogFile LogTime StreamMinPort \
StreamMaxPort MaxThreads ReadTimeout CommandReadTimeout MaxDirectoryRecursion \
FollowFileSymlinks FollowDirectorySymlinks SelfCheck DetectPUA ScanPE DisableCertCheck \
ScanELF DetectBrokenExecutables ScanOLE2 ScanPDF ScanSWF ScanMail ScanPartialMessages \
ScanArchive TemporaryDirectory ArchiveBlockEncrypted MaxFileSize LocalSocket User
validate_clamav_section clamav || {
echo "validation failed"
return 1
}
mkdir -p /usr/share/clamav
mkdir -p /etc/clamav/
mkdir -p /var/run/clamav/
chmod a+rw /var/run/clamav
mkdir -p $(dirname $CLAMD_CONFIGFILE)
ln -sf $clamd_config_file $CLAMD_CONFIGFILE
echo "LogFile " $LogFile > $CLAMD_CONFIGFILE
echo "LogFileMaxSize " $LogFileMaxSize >> $CLAMD_CONFIGFILE
echo "LogVerbose " $LogVerbose >> $CLAMD_CONFIGFILE
echo "ExtendedDetectionInfo " $ExtendedDetectionInfo >> $CLAMD_CONFIGFILE
echo "LogTime " $LogTime >> $CLAMD_CONFIGFILE
echo "OfficialDatabaseOnly " $OfficialDatabaseOnly >> $CLAMD_CONFIGFILE
echo "StreamMinPort " $StreamMinPort >> $CLAMD_CONFIGFILE
echo "StreamMaxPort " $StreamMaxPort >> $CLAMD_CONFIGFILE
echo "MaxThreads " $MaxThreads >> $CLAMD_CONFIGFILE
echo "ReadTimeout " $ReadTimeout >> $CLAMD_CONFIGFILE
echo "CommandReadTimeout " $CommandReadTimeout >> $CLAMD_CONFIGFILE
echo "MaxDirectoryRecursion " $MaxDirectoryRecursion >> $CLAMD_CONFIGFILE
echo "FollowDirectorySymlinks " $FollowDirectorySymlinks >> $CLAMD_CONFIGFILE
echo "FollowFileSymlinks " $FollowFileSymlinks >> $CLAMD_CONFIGFILE
echo "SelfCheck " $SelfCheck >> $CLAMD_CONFIGFILE
echo "DetectPUA " $DetectPUA >> $CLAMD_CONFIGFILE
echo "ScanPE " $ScanPE >> $CLAMD_CONFIGFILE
echo "DisableCertCheck " $DisableCertCheck >> $CLAMD_CONFIGFILE
echo "ScanELF " $ScanELF >> $CLAMD_CONFIGFILE
echo "DetectBrokenExecutables " $DetectBrokenExecutables >> $CLAMD_CONFIGFILE
echo "ScanOLE2 " $ScanOLE2 >> $CLAMD_CONFIGFILE
echo "ScanPDF " $ScanPDF >> $CLAMD_CONFIGFILE
echo "ScanSWF " $ScanSWF >> $CLAMD_CONFIGFILE
echo "ScanMail " $ScanMail >> $CLAMD_CONFIGFILE
echo "ScanPartialMessages " $ScanPartialMessages >> $CLAMD_CONFIGFILE
echo "ScanArchive " $ScanArchive >> $CLAMD_CONFIGFILE
echo "TemporaryDirectory " $TemporaryDirectory >> $CLAMD_CONFIGFILE
echo "ArchiveBlockEncrypted " $ArchiveBlockEncrypted >> $CLAMD_CONFIGFILE
echo "MaxFileSize " $MaxFileSize >> $CLAMD_CONFIGFILE
echo "LocalSocket " $LocalSocket >> $CLAMD_CONFIGFILE
echo "User " $User >> $CLAMD_CONFIGFILE
echo "ExitOnOOM " $ExitOnOOM >> $CLAMD_CONFIGFILE
procd_open_instance
procd_set_param command $PROG -c $CLAMD_CONFIGFILE
procd_set_param file $CLAMD_CONFIGFILE
procd_close_instance
}
stop_service()
{
service_stop ${PROG}
}
service_triggers()
{
procd_add_reload_trigger "clamav"
procd_add_validation validate_clamav_section
}
+7
View File
@@ -0,0 +1,7 @@
config freshclam 'freshclam'
option freshclam_config_file '/etc/clamav/freshclam.conf'
option UpdateLogFile '/tmp/freshclam.log'
option DatabaseMirror 'database.clamav.net'
option NotifyClamd '/etc/clamav/clamd.conf'
option DatabaseOwner 'root'
option CompressLocalDatabase 'yes'
+63
View File
@@ -0,0 +1,63 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2015 OpenWrt.org
START=90
STOP=10
USE_PROCD=1
PROG=/usr/sbin/freshclam
FRESHCLAM_CONFIGFILE="/tmp/clamav/freshclam.conf"
validate_freshclam_section() {
uci_validate_section freshclam freshclam "${1}" \
'freshclam_config_file:string' \
'UpdateLogFile:string' \
'DatabaseMirror:string' \
'NotifyClamd:string' \
'DatabaseOwner:string' \
'CompressLocalDatabase:string:'
}
start_service() {
local freshclam_config_file UpdateLogFile DatabaseOwner NotifyClamd DatabaseMirror
validate_freshclam_section freshclam || {
echo "validation failed"
return 1
}
[ -f /tmp/freshclam.pid ] && echo "already running" && return 0
mkdir -p /usr/share/clamav
mkdir -p /etc/clamav
touch /tmp/freshclam.log
touch /tmp/freshclam.pid
mkdir -p $(dirname $FRESHCLAM_CONFIGFILE)
ln -sf $freshclam_config_file $FRESHCLAM_CONFIGFILE
echo "UpdateLogFile " $UpdateLogFile > $FRESHCLAM_CONFIGFILE
echo "DatabaseMirror " $DatabaseMirror >> $FRESHCLAM_CONFIGFILE
echo "NotifyClamd " $NotifyClamd >> $FRESHCLAM_CONFIGFILE
echo "DatabaseOwner " $DatabaseOwner >> $FRESHCLAM_CONFIGFILE
echo "CompressLocalDatabase " $CompressLocalDatabase >> $FRESHCLAM_CONFIGFILE
procd_open_instance
procd_set_param command $PROG -d --config-file=$FRESHCLAM_CONFIGFILE -p /tmp/freshclam.pid --no-warnings
procd_set_param file $FRESHCLAM_CONFIGFILE
procd_close_instance
}
stop_service()
{
[ ! -f /tmp/freshclam.pid ] && echo "not running" && return 0
PID=`cat /tmp/freshclam.pid`
kill $PID
rm -f /tmp/freshclam.pid
}
service_triggers()
{
procd_add_reload_trigger "freshclam"
procd_add_validation validate_freshclam_section
}