clamav: Update init scripts
authorJeffery To <redacted>
Fri, 1 Feb 2019 08:39:34 +0000 (16:39 +0800)
committerJeffery To <redacted>
Fri, 1 Feb 2019 08:39:34 +0000 (16:39 +0800)
This replaces the use of uci_validate_section() with
uci_load_validate(), which removes the need to declare local variables
for every config option.

This also removes some unnecessary curly brackets.

Signed-off-by: Jeffery To <redacted>
net/clamav/Makefile
net/clamav/files/clamav.init
net/clamav/files/freshclam.init

index 95db33a37365d920b871448cf920ebf5e1f86386..ba45fff84a25930b4971e6f894f879e818fd086a 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=clamav
 PKG_VERSION:=0.101.1
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_LICENSE:=GPL-2.0
 PKG_MAINTAINER:=Marko Ratkaj <marko.ratkaj@sartura.hr> \
index a02468e0737aebd12281155f588944c65edf0ba9..38b1c3238f09d43983a4002cc381be4f0a2d61e1 100644 (file)
@@ -9,7 +9,7 @@ PROG=/usr/sbin/clamd
 CLAMD_CONFIGFILE="/tmp/clamav/clamd.conf"
 
 validate_clamav_section() {
-       uci_validate_section clamav clamav "${1}" \
+       uci_load_validate clamav clamav "$1" "$2" \
                'clamd_config_file:string' \
                'LogFile:string' \
                'LogFileMaxSize:string' \
@@ -46,15 +46,8 @@ validate_clamav_section() {
                'DatabaseDirectory: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 \
-               DatabaseDirectory
-
-       validate_clamav_section clamav || {
+start_clamav_instance() {
+       [ "$2" = 0 ] || {
                echo "validation failed"
                return 1
        }
@@ -107,9 +100,14 @@ start_service() {
        procd_close_instance
 }
 
+start_service()
+{
+       validate_clamav_section clamav start_clamav_instance
+}
+
 stop_service()
 {
-       service_stop ${PROG}
+       service_stop $PROG
 }
 
 service_triggers()
index 9504b7ffaae7654f1d1a7b4b87bf19cffbf99998..120dc803f60d0e1f8f07e7aba597360d139caa22 100644 (file)
@@ -9,7 +9,7 @@ PROG=/usr/sbin/freshclam
 FRESHCLAM_CONFIGFILE="/tmp/clamav/freshclam.conf"
 
 validate_freshclam_section() {
-       uci_validate_section freshclam freshclam "${1}" \
+       uci_load_validate freshclam freshclam "$1" "$2" \
                'freshclam_config_file:string' \
                'UpdateLogFile:string' \
                'DatabaseMirror:string' \
@@ -19,11 +19,8 @@ validate_freshclam_section() {
                'DatabaseDirectory:string:'
 }
 
-start_service() {
-       local freshclam_config_file UpdateLogFile DatabaseOwner NotifyClamd DatabaseMirror \
-       DatabaseDirectory
-
-       validate_freshclam_section freshclam || {
+start_freshclam_instance() {
+       [ "$2" = 0 ] || {
                echo "validation failed"
                return 1
        }
@@ -51,6 +48,11 @@ start_service() {
        procd_close_instance
 }
 
+start_service()
+{
+       validate_freshclam_section freshclam start_freshclam_instance
+}
+
 stop_service()
 {
        [ ! -f /tmp/freshclam.pid ] && echo "not running" && return 0
git clone https://git.99rst.org/PROJECT