snort: Update init script
authorJeffery To <redacted>
Sun, 3 Feb 2019 11:20:44 +0000 (19:20 +0800)
committerJeffery To <redacted>
Sun, 3 Feb 2019 11:20:44 +0000 (19:20 +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 fixes a variable name typo ("CONFIGFILE" instead of
"config_file").

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

index 30c3d7f6a4be57cfc3fac500a5eb2d437b025a79..2f65527e15785d4c8ed4bab269455a3c74acc56c 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=snort
 PKG_VERSION:=2.9.11.1
-PKG_RELEASE:=7
+PKG_RELEASE:=8
 
 PKG_LICENSE:=GPL-2.0
 PKG_MAINTAINER:=W. Michael Petullo <mike@flyn.org>
index c3d962902bc8e79f4a9ce5f966628bb8362236da..7905c6ff30c2fecc26d042fc29fd5a23f7d85261 100644 (file)
@@ -8,26 +8,29 @@ USE_PROCD=1
 PROG=/usr/bin/snort
 
 validate_snort_section() {
-       uci_validate_section snort snort "${1}" \
+       uci_load_validate snort snort "$1" "$2" \
                'config_file:string' \
                'interface:string'
 }
 
-start_service() {
-       local config_file interface
-
-       validate_snort_section snort || {
+start_snort_instance() {
+       [ "$2" = 0 ] || {
                echo "validation failed"
                return 1
        }
 
        procd_open_instance
        procd_set_param command $PROG "-q" "--daq-dir" "/usr/lib/daq/" "-i" "$interface" "-c" "$config_file" "-s" "-N"
-       procd_set_param file $CONFIGFILE
+       procd_set_param file $config_file
        procd_set_param respawn
        procd_close_instance
 }
 
+start_service()
+{
+       validate_snort_section snort start_snort_instance
+}
+
 stop_service()
 {
        service_stop ${PROG}
git clone https://git.99rst.org/PROJECT