aboutsummaryrefslogtreecommitdiffstats
path: root/testing/suricata/suricata.initd
diff options
context:
space:
mode:
authorSteve McMaster <code@mcmaster.io>2016-12-18 02:01:52 -0500
committerTimo Teräs <timo.teras@iki.fi>2016-12-26 09:33:57 +0000
commit90cc7e47f3f2679acc74399af0531db1d2e1eca7 (patch)
treed8c2f6960824335c85cd1d5e19f06a6ee128ca99 /testing/suricata/suricata.initd
parentdaf10c638df0935988e1eb4d1773452b91d14e63 (diff)
downloadaports-90cc7e47f3f2679acc74399af0531db1d2e1eca7.tar.bz2
aports-90cc7e47f3f2679acc74399af0531db1d2e1eca7.tar.xz
testing/suricata: new aport
https://suricata-ids.org/ High performance Network IDS, IPS and Network Security Monitoring engine
Diffstat (limited to 'testing/suricata/suricata.initd')
-rw-r--r--testing/suricata/suricata.initd65
1 files changed, 65 insertions, 0 deletions
diff --git a/testing/suricata/suricata.initd b/testing/suricata/suricata.initd
new file mode 100644
index 0000000000..e39312f377
--- /dev/null
+++ b/testing/suricata/suricata.initd
@@ -0,0 +1,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}
+}