summaryrefslogtreecommitdiffstats
path: root/net/snort/files/snort.init
blob: fcdb0901a73fd7da575fa3cc2ae423aca2e183a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/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_validate_section snort snort "${1}" \
		'config_file:string' \
		'interface:string'
}

start_service() {
	local config_file interface

	validate_snort_section snort || {
		echo "validation failed"
		return 1
	}

	procd_open_instance
	procd_set_param command $PROG "-q" "--daq-dir" "/usr/lib/daq/" "-i" "$interface" "-s" "-N"
	procd_set_param file $CONFIGFILE
	procd_set_param respawn
	procd_close_instance
}

stop_service()
{
	service_stop ${PROG}
}

service_triggers()
{
	procd_add_reload_trigger "snort"
	procd_add_validation validate_snort_section
}