From owner-svn-src-head@FreeBSD.ORG Sun Apr 5 17:10:00 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id EB54A7EC; Sun, 5 Apr 2015 17:09:59 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D679B1B2; Sun, 5 Apr 2015 17:09:59 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t35H9xDx036828; Sun, 5 Apr 2015 17:09:59 GMT (envelope-from jpaetzel@FreeBSD.org) Received: (from jpaetzel@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t35H9xG3036827; Sun, 5 Apr 2015 17:09:59 GMT (envelope-from jpaetzel@FreeBSD.org) Message-Id: <201504051709.t35H9xG3036827@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: jpaetzel set sender to jpaetzel@FreeBSD.org using -f From: Josh Paetzel Date: Sun, 5 Apr 2015 17:09:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r281112 - head/etc/rc.d X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Apr 2015 17:10:00 -0000 Author: jpaetzel Date: Sun Apr 5 17:09:58 2015 New Revision: 281112 URL: https://svnweb.freebsd.org/changeset/base/281112 Log: Bug fixes and feature adds - Remove extranious echo that breaks puppet - Handle restarts of multiple pflog devices correctly - Add the ability to perform actions on specific pflog devices. PR: 199150 Submitted by: jason.unovitch@gmail.com MFC after: 3 days Modified: head/etc/rc.d/pflog Modified: head/etc/rc.d/pflog ============================================================================== --- head/etc/rc.d/pflog Sun Apr 5 16:35:13 2015 (r281111) +++ head/etc/rc.d/pflog Sun Apr 5 17:09:58 2015 (r281112) @@ -24,30 +24,30 @@ pflog_prestart() { load_kld pflog || return 1 + # create pflog_dev interface if needed + if ! ifconfig $pflog_dev > /dev/null 2>&1; then + if ! ifconfig $pflog_dev create; then + warn "could not create $pflog_dev." + return 1 + fi + fi + # set pflog_dev interface to up state if ! ifconfig $pflog_dev up; then warn "could not bring up $pflog_dev." return 1 fi + # -p flag requires striping pidfile's leading /var/run and trailing .pid + pidfile=$(echo $pidfile | sed -e 's|/var/run/||' -e 's|.pid$||') + # prepare the command line for pflogd - rc_flags="-f $pflog_logfile -i $pflog_dev $rc_flags" + rc_flags="-p $pidfile -f $pflog_logfile -i $pflog_dev $rc_flags" # report we're ready to run pflogd return 0 } -pflog_poststart() { - # Allow child pflogd to settle - sleep 0.10 - # More elegant(?) method for getting a unique pid - if [ -f /var/run/pflogd.pid ]; then - mv /var/run/pflogd.pid $pidfile - else - warn "/var/run/pflogd.pid does not exist. Too fast." - fi -} - pflog_poststop() { if ! ifconfig $pflog_dev down; then @@ -70,29 +70,33 @@ pflog_resync() load_rc_config $name -# Check if spawning multiple pflogd -echo "Starting pflogd: $pflog_instances" -if [ "$pflog_instances" ] && [ -n "$pflog_instances" ]; then - start_postcmd="pflog_poststart" +# Check if spawning multiple pflogd and told what to spawn +if [ -n "$2" ]; then + # Set required variables + eval pflog_dev=\$pflog_${2}_dev + eval pflog_logfile=\$pflog_${2}_logfile + eval pflog_flags=\$pflog_${2}_flags + # Check that required vars have non-zero length, warn if not. + if [ -z $pflog_dev ]; then + warn "pflog_dev not set" + continue + fi + if [ -z $pflog_logfile ]; then + warn "pflog_logfile not set" + continue + fi + + # Provide a unique pidfile name for pflogd -p flag + pidfile="/var/run/pflogd.$2.pid" + + # Override service name and execute command + name=$pflog_dev + run_rc_command "$1" +# Check if spawning multiple pflogd and not told what to spawn +elif [ "$pflog_instances" ] && [ -n "$pflog_instances" ]; then # Interate through requested instances. for i in $pflog_instances; do - # Set required variables - eval pflog_dev=\$pflog_${i}_dev - eval pflog_logfile=\$pflog_${i}_logfile - eval pflog_flags=\$pflog_${i}_flags - # Check that required vars have non-zero length, warn if not. - if [ -z $pflog_dev ]; then - warn "pflog_dev not set" - continue - fi - if [ -z $pflog_logfile ]; then - warn "pflog_logfile not set" - continue - fi - # pflogd sets a pidfile, but the name is hardcoded. Concoct a - # unique pidfile name. - pidfile="/var/run/pflogd.$i.pid" - run_rc_command "$1" + /etc/rc.d/pflog $1 $i done else # Typical case, spawn single instance only.