From 90cc7e47f3f2679acc74399af0531db1d2e1eca7 Mon Sep 17 00:00:00 2001 From: Steve McMaster Date: Sun, 18 Dec 2016 02:01:52 -0500 Subject: testing/suricata: new aport https://suricata-ids.org/ High performance Network IDS, IPS and Network Security Monitoring engine --- testing/suricata/suricata.initd | 65 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 testing/suricata/suricata.initd (limited to 'testing/suricata/suricata.initd') 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} +} -- cgit v1.2.3