diff options
author | Slawomir Lis <slis@gentoo.org> | 2016-12-27 11:43:03 +0100 |
---|---|---|
committer | Slawomir Lis <slis@gentoo.org> | 2016-12-27 11:43:03 +0100 |
commit | 46b93f31143ddd9e2c0d2d45332a0feeefc3df84 (patch) | |
tree | da42e708f4988f68a832d92409d240f274fb6a22 /net-analyzer | |
parent | dev-perl/XML-SAX-Expat: Remove POD Author tests (diff) | |
download | gentoo-46b93f31143ddd9e2c0d2d45332a0feeefc3df84.tar.gz gentoo-46b93f31143ddd9e2c0d2d45332a0feeefc3df84.tar.bz2 gentoo-46b93f31143ddd9e2c0d2d45332a0feeefc3df84.zip |
net-analyzer/suricata: Updated init script
Now it's able to override config filename and point to log directory.
Related to #602590
Thanks to Vieri <rentorbuy@yahoo.com>
Package-Manager: Portage-2.3.3, Repoman-2.3.1
Diffstat (limited to 'net-analyzer')
-rw-r--r-- | net-analyzer/suricata/files/suricata-3.2-conf | 23 | ||||
-rw-r--r-- | net-analyzer/suricata/files/suricata-3.2-init | 30 |
2 files changed, 45 insertions, 8 deletions
diff --git a/net-analyzer/suricata/files/suricata-3.2-conf b/net-analyzer/suricata/files/suricata-3.2-conf index 61715ba3c55e..d900ade85258 100644 --- a/net-analyzer/suricata/files/suricata-3.2-conf +++ b/net-analyzer/suricata/files/suricata-3.2-conf @@ -19,9 +19,17 @@ # ln -s /etc/init.d/suricata /etc/init.d/suricata.q1 # cp /etc/suricata/suricata.yaml /etc/suricata/suricata-q0.yaml # cp /etc/suricata/suricata.yaml /etc/suricata/suricata-q1.yaml +# # Edit both suricata-q{0,1}.yaml files and set values accordingly. -# -# You can then define the following options here: +# You can override these yaml config file names with SURICATA_CONF* below (optional). +# This allows you to use the same yaml config file for multiple instances as long as you override +# sensible options such as the log file paths. +# SURICATA_CONF_q0="suricata-queues.yaml" +# SURICATA_CONF_q1="suricata-queues.yaml" +# SURICATA_CONF="suricata.yaml" + +# You can define the options here: +# NB: avoid using -l, -c and setting logging.outputs.1.file.filename as the init script will try to set them for you. # SURICATA_OPTS_q0="-q 0" # SURICATA_OPTS_q1="-q 1" @@ -30,3 +38,14 @@ # then you can set: SURICATA_OPTS="-i eth0" + +# Log paths listed here will be created by the init script and will override the log path +# set in the yaml file, if present. +# SURICATA_LOG_PATH_q0="/var/log/suricata/q0" +# SURICATA_LOG_PATH_q1="/var/log/suricata/q1" +# SURICATA_LOG_PATH="/var/log/suricata" +# SURICATA_LOG_FILE="suricata.log" + +# You can view all the available options you can set with --set +# and check the full config settings in an easily parsable format. +# SURICATA_DUMP=1 diff --git a/net-analyzer/suricata/files/suricata-3.2-init b/net-analyzer/suricata/files/suricata-3.2-init index d6128159e1b1..3ec6afd68f72 100644 --- a/net-analyzer/suricata/files/suricata-3.2-init +++ b/net-analyzer/suricata/files/suricata-3.2-init @@ -8,13 +8,17 @@ SURICATA_DIR=${SURICATA_DIR:-/etc/suricata} SURICATA=${SVCNAME#*.} SURICATAID=$(shell_var "${SURICATA}") if [ -n "${SURICATA}" ] && [ ${SVCNAME} != "suricata" ]; then - SURICATACONF="${SURICATA_DIR}/suricata-${SURICATA}.yaml" + eval SURICATACONF=\$SURICATA_CONF_${SURICATAID} + [ ${#SURICATACONF} -eq 0 ] && SURICATACONF="${SURICATA_DIR}/suricata-${SURICATA}.yaml" || SURICATACONF="${SURICATA_DIR}/${SURICATACONF}" SURICATAPID="/var/run/suricata/suricata.${SURICATA}.pid" eval SURICATAOPTS=\$SURICATA_OPTS_${SURICATAID} + eval SURICATALOGPATH=\$SURICATA_LOG_PATH_${SURICATAID} else - SURICATACONF="${SURICATA_DIR}/suricata.yaml" + SURICATACONF=${SURICATA_CONF} + [ ${#SURICATACONF} -eq 0 ] && SURICATACONF="${SURICATA_DIR}/suricata.yaml" || SURICATACONF="${SURICATA_DIR}/${SURICATACONF}" SURICATAPID="/var/run/suricata/suricata.pid" SURICATAOPTS=${SURICATA_OPTS} + SURICATALOGPATH=${SURICATA_LOG_PATH} fi [ -e ${SURICATACONF} ] && SURICATAOPTS="${SURICATAOPTS} -c ${SURICATACONF}" @@ -36,6 +40,14 @@ checkconfig() { if [ ! -d "/var/run/suricata" ] ; then checkpath -d /var/run/suricata fi + if [ ${#SURICATALOGPATH} -gt 0 ]; then + if [ ! -d "${SURICATALOGPATH}" ] ; then + checkpath -d "${SURICATALOGPATH}" + fi + SURICATALOGFILE=${SURICATA_LOG_FILE:-suricata.log} + SURICATAOPTS="${SURICATAOPTS} --set logging.outputs.1.file.filename=${SURICATALOGPATH}/${SURICATALOGFILE}" + SURICATALOGPATH="-l ${SURICATALOGPATH}" + fi } initpidinfo() { @@ -65,13 +77,19 @@ checkpidinfo() { start() { checkconfig || return 1 + if [ $((SURICATA_DUMP)) -eq 1 ]; then + einfo "Dumping ${SVCNAME} config values and quitting." + ${SURICATA_BIN} --dump-config --pidfile ${SURICATAPID} ${SURICATAOPTS} ${SURICATALOGPATH} + einfo "You need to disable SURICATA_DUMP to start ${SVCNAME}." + return 1 + fi ebegin "Starting ${SVCNAME}" start-stop-daemon --start --quiet --exec ${SURICATA_BIN} \ - -- --pidfile ${SURICATAPID} -D ${SURICATAOPTS} >/dev/null 2>&1 + -- --pidfile ${SURICATAPID} -D ${SURICATAOPTS} ${SURICATALOGPATH} >/dev/null 2>&1 local SUR_EXIT=$? if [ $((SUR_EXIT)) -ne 0 ]; then einfo "Could not start ${SURICATA_BIN} with:" - einfo "--pidfile ${SURICATAPID} -D ${SURICATAOPTS}" + einfo "--pidfile ${SURICATAPID} -D ${SURICATAOPTS} ${SURICATALOGPATH}" einfo "Exit code ${SUR_EXIT}" fi eend ${SUR_EXIT} @@ -87,7 +105,7 @@ stop() { while [ -e ${SURICATAPID} ] && [ $cnt -gt 0 ]; do cnt=$(expr $cnt - 1) sleep 1 - einfo -ne "$cnt seconds left before we give up checking the PID file...\r" + echo -ne "$cnt seconds left before we give up checking the PID file...\r" done # under certain conditions suricata can be pretty slow and the PID can persist long after the pidfile has been removed # max wait for process to terminate: 1 minute @@ -105,7 +123,7 @@ stop() { break fi sleep 1 - einfo -ne "$cnt seconds left before we give up checking PID ${SUR_PID}...\r" + echo -ne "$cnt seconds left before we give up checking PID ${SUR_PID}...\r" SUR_PID_CHECK="$(ps -eo pid | grep -c ${SUR_PID})" done fi |