svn commit: r217755 - head/etc/periodic/daily
Jilles Tjoelker
jilles at stack.nl
Sun Jan 23 17:35:14 UTC 2011
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
More information about the svn-src-all
mailing list