|
|
- #!/bin/sh /etc/rc.common
- # Copyright (C) 2015 OpenWrt.org
-
- START=90
- STOP=10
-
- USE_PROCD=1
- PROG=/usr/sbin/clamav-milter
- CLAMAV_MILTER_CONFIGFILE="/tmp/clamav/clamav-milter.conf"
-
- validate_clamav_milter_section() {
- uci_load_validate clamav-milter clamav_milter "$1" "$2" \
- 'clamav_milter_config_file:string' \
- 'Foreground:string' \
- 'PidFile:string' \
- 'User:string' \
- 'MilterSocketGroup:string' \
- 'AllowSupplementaryGroups:string' \
- 'ReadTimeout:uinteger' \
- 'OnClean:string' \
- 'OnInfected:string' \
- 'OnFail:string' \
- 'AddHeader:string' \
- 'LogVerbose:string' \
- 'LogTime:string' \
- 'LogSyslog:string' \
- 'LogFacility:string' \
- 'LogInfected:string' \
- 'LogClean:string' \
- 'MaxFileSize:string' \
- 'SupportMultipleRecipients:string' \
- 'RejectMsg:string' \
- 'TemporaryDirectory:string' \
- 'MilterSocket:string' \
- 'MilterSocketMode:uinteger' \
- 'ClamdSocket:string' \
- 'FixStaleSocket:string'
- }
-
- start_clamav_milter_instance() {
- [ "$2" = 0 ] || {
- echo "validation failed"
- return 1
- }
-
- mkdir -p /etc/clamav/
- mkdir -p /var/run/clamav/
- chmod a+rw /var/run/clamav
-
- mkdir -p "$(dirname $CLAMAV_MILTER_CONFIGFILE)"
- ln -sf "$clamav_milter_config_file" "$CLAMAV_MILTER_CONFIGFILE"
-
- {
- echo "Foreground " "$Foreground"
- echo "PidFile " "$PidFile"
- echo "User " "$User"
- echo "MilterSocketGroup " "$MilterSocketGroup"
- echo "AllowSupplementaryGroups " "$AllowSupplementaryGroups"
- echo "ReadTimeout " "$ReadTimeout"
- echo "OnClean " "$OnClean"
- echo "OnInfected " "$OnInfected"
- echo "OnFail " "$OnFail"
- echo "AddHeader " "$AddHeader"
- echo "LogVerbose " "$LogVerbose"
- echo "LogTime " "$LogTime"
- echo "LogSyslog " "$LogSyslog"
- echo "LogFacility " "$LogFacility"
- echo "LogInfected " "$LogInfected"
- echo "LogClean " "$LogClean"
- echo "MaxFileSize " "$MaxFileSize"
- echo "SupportMultipleRecipients " "$SupportMultipleRecipients"
- echo "RejectMsg " "$RejectMsg"
- echo "TemporaryDirectory " "$TemporaryDirectory"
- echo "MilterSocket " "$MilterSocket"
- echo "MilterSocketMode " "$MilterSocketMode"
- echo "ClamdSocket " "$ClamdSocket"
- echo "FixStaleSocket " "$FixStaleSocket"
- } > "$CLAMAV_MILTER_CONFIGFILE"
-
- procd_open_instance
- procd_set_param command $PROG -c $CLAMAV_MILTER_CONFIGFILE
- procd_set_param file $CLAMAV_MILTER_CONFIGFILE
- procd_close_instance
- }
-
- start_service()
- {
- validate_clamav_milter_section clamav_milter start_clamav_milter_instance
- }
-
- stop_service()
- {
- service_stop $PROG
- }
-
- service_triggers()
- {
- procd_add_reload_trigger "clamav-milter"
- procd_add_validation validate_clamav_milter_section
- }
|