From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id CD89F139085 for ; Tue, 27 Dec 2016 10:43:18 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 2680C21C038; Tue, 27 Dec 2016 10:43:18 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id E5E6921C038 for ; Tue, 27 Dec 2016 10:43:17 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 5021B34106E for ; Tue, 27 Dec 2016 10:43:16 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id BD06C24E1 for ; Tue, 27 Dec 2016 10:43:14 +0000 (UTC) From: "Slawek Lis" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Slawek Lis" Message-ID: <1482835383.46b93f31143ddd9e2c0d2d45332a0feeefc3df84.slis@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: net-analyzer/suricata/files/ X-VCS-Repository: repo/gentoo X-VCS-Files: net-analyzer/suricata/files/suricata-3.2-conf net-analyzer/suricata/files/suricata-3.2-init X-VCS-Directories: net-analyzer/suricata/files/ X-VCS-Committer: slis X-VCS-Committer-Name: Slawek Lis X-VCS-Revision: 46b93f31143ddd9e2c0d2d45332a0feeefc3df84 X-VCS-Branch: master Date: Tue, 27 Dec 2016 10:43:14 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: e5fb3f85-3b21-4246-8c17-9c08675b3e55 X-Archives-Hash: e14aee51183997337243ed695b6be22b commit: 46b93f31143ddd9e2c0d2d45332a0feeefc3df84 Author: Slawomir Lis gentoo org> AuthorDate: Tue Dec 27 10:43:03 2016 +0000 Commit: Slawek Lis gentoo org> CommitDate: Tue Dec 27 10:43:03 2016 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=46b93f31 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 yahoo.com> Package-Manager: Portage-2.3.3, Repoman-2.3.1 net-analyzer/suricata/files/suricata-3.2-conf | 23 ++++++++++++++++++-- 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 61715ba..d900ade 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 d612815..3ec6afd 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