From b62130a877ffa8538a4c51f4705a6fe3002f93c6 Mon Sep 17 00:00:00 2001 From: Tim Foster Date: Thu, 28 Aug 2008 12:51:46 +0100 Subject: [PATCH] Filesystems weren't exluded - spaces are not tabs. auto_include shouldn't parse column headers. Postinstall script should work on SXCE too. --- src/lib/svc/method/zfs-auto-snapshot | 8 +++---- src/postinstall | 32 ++++++++++++---------------- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/lib/svc/method/zfs-auto-snapshot b/src/lib/svc/method/zfs-auto-snapshot index 1679330..bf2023c 100755 --- a/src/lib/svc/method/zfs-auto-snapshot +++ b/src/lib/svc/method/zfs-auto-snapshot @@ -779,7 +779,7 @@ function narrow_recursive_filesystems { function can_recursive_snapshot { typeset ds=$1 - if egrep "$ds/"\|"$ds " $EXCLUDE > /dev/null; then + if egrep "$ds/"\|"$ds " $EXCLUDE > /dev/null; then # we can't recursively snapshot $ds because # it's excluded or is in the path to an excluded dataset return 1 @@ -790,7 +790,7 @@ function can_recursive_snapshot { function is_excluded { typeset ds=$1 - if egrep "$ds " $EXCLUDE > /dev/null ; then + if egrep "$ds " $EXCLUDE > /dev/null ; then return 0 else return 1 @@ -879,8 +879,8 @@ function auto_include { POOLS=$(zpool list -H -o name) for pool in $POOLS ; do if ! zpool status -x $pool | grep "state: UNAVAIL" > /dev/null ; then - SNAPALL=$(zfs get com.sun:auto-snapshot $pool) - SNAPLABEL=$(zfs get com.sun:auto-snapshot:$LABEL $pool) + SNAPALL=$(zfs get -H -o value com.sun:auto-snapshot $pool) + SNAPLABEL=$(zfs get -H -o value com.sun:auto-snapshot:$LABEL $pool) SNAP=$SNAPALL$SNAPLABEL case $SNAP in *true | true*) diff --git a/src/postinstall b/src/postinstall index a1a4d07..f4e32e7 100755 --- a/src/postinstall +++ b/src/postinstall @@ -1,4 +1,4 @@ -#!/bin/ksh +#!/bin/sh # # CDDL HEADER START @@ -32,7 +32,7 @@ # Check if the first argument is 0, settting our return # variable to an error otherwise # -function check_error { +check_error() { RETURN_CODE=$1 ERROR="$2" if [ "$RETURN_CODE" -ne 0 ] ; then @@ -40,32 +40,28 @@ function check_error { fi } -function user_exists { - typeset USER=$1 - if /usr/bin/grep ^$USER: $BASEDIR/etc/passwd > /dev/null ; then - return 0 - else - return 1 - fi +user_exists() { + USER=$1 + /usr/bin/grep "^$USER:" $BASEDIR/etc/passwd > /dev/null + return $? } -function auth_exists { - typeset AUTH=$1 - if /usr/bin/grep ^$AUTH: $BASEDIR/etc/security/auth_attr > /dev/null ; then - return 0 - else - return 1 - fi +auth_exists() { + AUTH=$1 + /usr/bin/grep "^$AUTH:" $BASEDIR/etc/security/auth_attr > /dev/null + return $? } # add our authorization -if ! auth_exists solaris.smf.manage.zfs-auto-snapshot; then +auth_exists solaris.smf.manage.zfs-auto-snapshot +if [ $? -ne 0 ] ; then echo "solaris.smf.manage.zfs-auto-snapshot:::Manage the ZFS Automatic Snapshot Service::" \ >> /etc/security/auth_attr fi # add the zfssnap role - probably only works on a local system :-( -if ! user_exists zfssnap; then +user_exists zfssnap +if [ $? -ne 0 ] ; then /usr/sbin/roleadd -d /export/home/zfssnap -c "ZFS Automatic Snapshots role" \ -P "ZFS File System Management" \ -A solaris.smf.manage.zfs-auto-snapshot -m zfssnap