snort: Update init script

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 <jeffery.to@gmail.com>
This commit is contained in:
Jeffery To
2019-02-03 19:20:44 +08:00
parent fdc5c5be60
commit 0fb4847b4b
2 changed files with 10 additions and 7 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=snort PKG_NAME:=snort
PKG_VERSION:=2.9.11.1 PKG_VERSION:=2.9.11.1
PKG_RELEASE:=7 PKG_RELEASE:=8
PKG_LICENSE:=GPL-2.0 PKG_LICENSE:=GPL-2.0
PKG_MAINTAINER:=W. Michael Petullo <mike@flyn.org> PKG_MAINTAINER:=W. Michael Petullo <mike@flyn.org>
+9 -6
View File
@@ -8,26 +8,29 @@ USE_PROCD=1
PROG=/usr/bin/snort PROG=/usr/bin/snort
validate_snort_section() { validate_snort_section() {
uci_validate_section snort snort "${1}" \ uci_load_validate snort snort "$1" "$2" \
'config_file:string' \ 'config_file:string' \
'interface:string' 'interface:string'
} }
start_service() { start_snort_instance() {
local config_file interface [ "$2" = 0 ] || {
validate_snort_section snort || {
echo "validation failed" echo "validation failed"
return 1 return 1
} }
procd_open_instance procd_open_instance
procd_set_param command $PROG "-q" "--daq-dir" "/usr/lib/daq/" "-i" "$interface" "-c" "$config_file" "-s" "-N" 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_set_param respawn
procd_close_instance procd_close_instance
} }
start_service()
{
validate_snort_section snort start_snort_instance
}
stop_service() stop_service()
{ {
service_stop ${PROG} service_stop ${PROG}