#!/bin/sh /etc/rc.common
|
|
# Copyright (C) 2015 OpenWrt.org
|
|
|
|
START=90
|
|
STOP=10
|
|
|
|
USE_PROCD=1
|
|
PROG=/usr/bin/snort
|
|
|
|
validate_snort_section() {
|
|
uci_load_validate snort snort "$1" "$2" \
|
|
'config_file:string' \
|
|
'interface:string'
|
|
}
|
|
|
|
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 $config_file
|
|
procd_set_param respawn
|
|
procd_close_instance
|
|
}
|
|
|
|
start_service()
|
|
{
|
|
validate_snort_section snort start_snort_instance
|
|
}
|
|
|
|
stop_service()
|
|
{
|
|
service_stop ${PROG}
|
|
}
|
|
|
|
service_triggers()
|
|
{
|
|
procd_add_reload_trigger "snort"
|
|
procd_add_validation validate_snort_section
|
|
}
|