blob: 9ea615e4b1a969ddc31c8e7bdbbdac59c25cf51a (
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#!/sbin/openrc-run
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$
SURICATA_DIR=${SURICATA_DIR:-/etc/suricata}
SURICATA=${SVCNAME#*.}
if [ -n "${SURICATA}" ] && [ ${SVCNAME} != "suricata" ]; then
SURICATACONF="${SURICATA_DIR}/suricata-${SURICATA}.yaml"
SURICATAPID="/var/run/suricata/suricata.${SURICATA}.pid"
else
SURICATACONF="${SURICATA_DIR}/suricata.yaml"
SURICATAPID="/var/run/suricata/suricata.pid"
fi
SURICATAOPTS=${SURICATA_OPTIONS}
extra_commands="checkconfig"
extra_started_commands="reload"
depend() {
need net
after firewall
}
checkconfig() {
if [ ! -e ${SURICATACONF} ] ; then
eerror "You need to create ${SURICATACONF} to run ${SVCNAME}."
return 1
fi
}
start() {
checkconfig || return 1
ebegin "Starting ${SVCNAME}"
start-stop-daemon --start --quiet --exec /usr/bin/suricata \
-- --pidfile ${SURICATAPID} -D ${SURICATAOPTS} \
-c ${SURICATACONF} >/dev/null 2>&1
eend $?
}
stop() {
ebegin "Stopping ${SVCNAME}"
start-stop-daemon --stop --quiet --pidfile ${SURICATAPID} >/dev/null 2>&1
einfon "Waiting for ${SVCNAME} to shut down. This can take a while..."
echo
# max wait: 5 minutes as it can take quite a while on some systems with heavy traffic
cnt=300
while [ -f ${SURICATAPID} ]; do
cnt=$(expr $cnt - 1)
if [ $cnt -lt 1 ] ; then
echo
eend 1 "Failed."
break
fi
sleep 1
echo -ne "$cnt seconds left before we give up\r"
done
eend $?
}
reload() {
checkconfig || return 1
ebegin "Reloading ${SVCNAME}"
start-stop-daemon --signal HUP --pidfile ${SURICATAPID}
}
|