From owner-svn-src-all@FreeBSD.ORG Sun Jan 23 17:35:14 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D4812106566C; Sun, 23 Jan 2011 17:35:14 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay04.stack.nl [IPv6:2001:610:1108:5010::107]) by mx1.freebsd.org (Postfix) with ESMTP id 718078FC17; Sun, 23 Jan 2011 17:35:14 +0000 (UTC) Received: from turtle.stack.nl (turtle.stack.nl [IPv6:2001:610:1108:5010::132]) by mx1.stack.nl (Postfix) with ESMTP id 582AA1DD625; Sun, 23 Jan 2011 18:35:13 +0100 (CET) Received: by turtle.stack.nl (Postfix, from userid 1677) id 4BC2F17104; Sun, 23 Jan 2011 18:35:13 +0100 (CET) Date: Sun, 23 Jan 2011 18:35:13 +0100 From: Jilles Tjoelker To: Josh Paetzel Message-ID: <20110123173513.GB9898@stack.nl> References: <201101231713.p0NHDTvg062076@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201101231713.p0NHDTvg062076@svn.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r217755 - head/etc/periodic/daily X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Jan 2011 17:35:14 -0000 On Sun, Jan 23, 2011 at 05:13:29PM +0000, Josh Paetzel wrote: > Author: jpaetzel > Date: Sun Jan 23 17:13:29 2011 > New Revision: 217755 > URL: http://svn.freebsd.org/changeset/base/217755 > > Log: > This script parses output of userland tools. In the case of a faulted > zpool the output causes the script to bail out with syntax errors. > Since a scrub of a faulted zpool is pointless, just skip over any pools > marked as such. > > PR: conf/150228 > Submitted by: jpaetzel > Approved by: kib (mentor) > MFC after: 3 days > MFC note: only for RELENG_8 > > Modified: > head/etc/periodic/daily/800.scrub-zfs > > Modified: head/etc/periodic/daily/800.scrub-zfs > ============================================================================== > --- head/etc/periodic/daily/800.scrub-zfs Sun Jan 23 16:28:44 2011 (r217754) > +++ head/etc/periodic/daily/800.scrub-zfs Sun Jan 23 17:13:29 2011 (r217755) > @@ -24,13 +24,17 @@ case "$daily_scrub_zfs_enable" in > > for pool in ${daily_scrub_zfs_pools}; do > # sanity check > - zpool list ${pool} >/dev/null 2>&1 > + _status=$(zpool list ${pool} | sed -n -e '$p') > if [ $? -ne 0 ]; then > echo " WARNING: pool '${pool}' specified in" > echo " '/etc/periodic.conf:daily_scrub_zfs_pools'" > echo " does not exist" > continue > fi The above 'if' block never executes anymore now, since $? is sed's exit status which is always 0. Consider _status=$(zpool list "${pool}") if [ $? -ne 0 ]; then ... fi _status=${_status##*$newline} With somewhere at the top of the script newline=' ' # one newline and no other whitespace Note that this changed code will give the last non-empty line, while your sed code gives the last line even if it is empty. I think it does not make a difference. > + if echo ${_status} | grep -q FAULTED; then > + echo "Skipping faulted pool: ${pool}" > + continue > + fi Faster and more resilient to special characters: case ${_status} in *FAULTED*) echo "Skipping faulted pool: ${pool}" continue ;; esac > # successful only if there is at least one pool to scrub > rc=0 -- Jilles Tjoelker