diff --git a/contrib/initramfs/scripts/zfs b/contrib/initramfs/scripts/zfs index 2633371afe34..b4927dc37347 100644 --- a/contrib/initramfs/scripts/zfs +++ b/contrib/initramfs/scripts/zfs @@ -27,19 +27,19 @@ pre_mountroot() if type run_scripts > /dev/null 2>&1 && \ [ -f "/scripts/local-top" -o -d "/scripts/local-top" ] then - check_boolean "$quiet" || \ + check_boolean "${quiet}" || \ zfs_log_begin_msg "Running /scripts/local-top" run_scripts /scripts/local-top - check_boolean "$quiet" || zfs_log_end_msg + check_boolean "${quiet}" || zfs_log_end_msg fi if type run_scripts > /dev/null 2>&1 && \ [ -f "/scripts/local-premount" -o -d "/scripts/local-premount" ] then - check_boolean "$quiet" || \ + check_boolean "${quiet}" || \ zfs_log_begin_msg "Running /scripts/local-premount" run_scripts /scripts/local-premount - check_boolean "$quiet" || zfs_log_end_msg + check_boolean "${quiet}" || zfs_log_end_msg fi } @@ -48,13 +48,13 @@ pre_mountroot() # with more logging etc. load_module_initrd() { - if [ "$ZFS_INITRD_PRE_MOUNTROOT_SLEEP" -gt 0 ] + if [ "${ZFS_INITRD_PRE_MOUNTROOT_SLEEP}" -gt 0 ] then - check_boolean "$quiet" || \ + check_boolean "${quiet}" || \ zfs_log_begin_msg "Sleeping for" \ - "$ZFS_INITRD_PRE_MOUNTROOT_SLEEP seconds..." - sleep "$ZFS_INITRD_PRE_MOUNTROOT_SLEEP" - check_boolean "$quiet" || zfs_log_end_msg + "${ZFS_INITRD_PRE_MOUNTROOT_SLEEP} seconds..." + sleep "${ZFS_INITRD_PRE_MOUNTROOT_SLEEP}" + check_boolean "${quiet}" || zfs_log_end_msg fi # Wait for all of the /dev/{hd,sd}[a-z] device nodes to appear. @@ -71,13 +71,13 @@ load_module_initrd() # Load the module load_module "zfs" || return 1 - if [ "$ZFS_INITRD_POST_MODPROBE_SLEEP" -gt 0 ] + if [ "${ZFS_INITRD_POST_MODPROBE_SLEEP}" -gt 0 ] then - check_boolean "$quiet" || \ + check_boolean "${quiet}" || \ zfs_log_begin_msg "Sleeping for" \ - "$ZFS_INITRD_POST_MODPROBE_SLEEP seconds..." - sleep "$ZFS_INITRD_POST_MODPROBE_SLEEP" - check_boolean "$quiet" || zfs_log_end_msg + "${ZFS_INITRD_POST_MODPROBE_SLEEP} seconds..." + sleep "${ZFS_INITRD_POST_MODPROBE_SLEEP}" + check_boolean "${quiet}" || zfs_log_end_msg fi return 0 @@ -123,17 +123,17 @@ mountroot() # ------------ # Look for the cache file (if any). - [ ! -f ${ZPOOL_CACHE} ] && unset ZPOOL_CACHE + [ ! -f "${ZPOOL_CACHE}" ] && unset ZPOOL_CACHE # ------------ # Compatibility: 'ROOT' is for Debian GNU/Linux (etc), # 'root' is for Redhat/Fedora (etc), # 'REAL_ROOT' is for Gentoo - if [ -z "$ROOT" ] + if [ -z "${ROOT}" ] then - [ -n "$root" ] && ROOT=${root} + [ -n "${root}" ] && ROOT="${root}" - [ -n "$REAL_ROOT" ] && ROOT=${REAL_ROOT} + [ -n "${REAL_ROOT}" ] && ROOT="${REAL_ROOT}" fi # ------------ @@ -141,18 +141,18 @@ mountroot() # Compatibility: 'rootmnt' is for Debian GNU/Linux (etc), # 'NEWROOT' is for RedHat/Fedora (etc), # 'NEW_ROOT' is for Gentoo - if [ -z "$rootmnt" ] + if [ -z "${rootmnt}" ] then - [ -n "$NEWROOT" ] && rootmnt=${NEWROOT} + [ -n "${NEWROOT}" ] && rootmnt="${NEWROOT}" - [ -n "$NEW_ROOT" ] && rootmnt=${NEW_ROOT} + [ -n "${NEW_ROOT}" ] && rootmnt="${NEW_ROOT}" fi # ------------ # No longer set in the defaults file, but it could have been set in # get_pools() in some circumstances. If it's something, but not 'yes', # it's no good to us. - if [ -n "$USE_DISK_BY_ID" ] && ! check_boolean "$USE_DISK_BY_ID"; then + if [ -n "${USE_DISK_BY_ID}" ] && ! check_boolean "${USE_DISK_BY_ID}"; then unset USE_DISK_BY_ID fi @@ -192,19 +192,19 @@ mountroot() # ------------ # Look for 'rpool' and 'bootfs' parameter - [ -n "$rpool" ] && ZFS_RPOOL="${rpool#rpool=}" - [ -n "$bootfs" ] && ZFS_BOOTFS="${bootfs#bootfs=}" + [ -n "${rpool}" ] && ZFS_RPOOL="${rpool#rpool=}" + [ -n "${bootfs}" ] && ZFS_BOOTFS="${bootfs#bootfs=}" # ------------ # If we have 'ROOT' (see above), but not 'ZFS_BOOTFS', then use # 'ROOT' - [ -n "$ROOT" -a -z "${ZFS_BOOTFS}" ] && ZFS_BOOTFS="$ROOT" + [ -n "${ROOT}" -a -z "${ZFS_BOOTFS}" ] && ZFS_BOOTFS="${ROOT}" # ------------ # Check for the `-B zfs-bootfs=%s/%u,...` kind of parameter. # NOTE: Only use the pool name and dataset. The rest is not # supported by ZoL (whatever it's for). - if [ -z "$ZFS_RPOOL" ] + if [ -z "${ZFS_RPOOL}" ] then # The ${zfs-bootfs} variable is set at the kernel commmand # line, usually by GRUB, but it cannot be referenced here @@ -214,12 +214,12 @@ mountroot() # Reassign the variable by dumping the environment and # stripping the zfs-bootfs= prefix. Let the shell handle # quoting through the eval command. - eval ZFS_RPOOL=$(set | sed -n -e 's,^zfs-bootfs=,,p') + eval ZFS_RPOOL="$(set | sed -n -e 's,^zfs-bootfs=,,p')" fi # ------------ # No root fs or pool specified - do auto detect. - if [ -z "$ZFS_RPOOL" -a -z "${ZFS_BOOTFS}" ] + if [ -z "${ZFS_RPOOL}" -a -z "${ZFS_BOOTFS}" ] then # Do auto detect. Do this by 'cheating' - set 'root=zfs:AUTO' # which will be caught later @@ -230,33 +230,33 @@ mountroot() # F I N D A N D I M P O R T C O R R E C T P O O L # ------------ - if [ "$ROOT" = "zfs:AUTO" ] + if [ "${ROOT}" = "zfs:AUTO" ] then # Try to detect both pool and root fs. - check_boolean "$quiet" || \ + check_boolean "${quiet}" || \ zfs_log_begin_msg "Attempting to import additional pools." # Get a list of pools available for import - if [ -n "$ZFS_RPOOL" ] + if [ -n "${ZFS_RPOOL}" ] then # We've specified a pool - check only that - POOLS=$ZFS_RPOOL + POOLS="${ZFS_RPOOL}" else - POOLS=$(get_pools) + POOLS="$(get_pools)" fi - OLD_IFS="$IFS" ; IFS=";" - for pool in $POOLS + OLD_IFS="${IFS}" ; IFS=";" + for pool in ${POOLS} do - [ -z "$pool" ] && continue + [ -z "${pool}" ] && continue - import_pool "$pool" - ZFS_BOOTFS="$(find_rootfs "$pool")" + import_pool "${pool}" + ZFS_BOOTFS="$(find_rootfs "${pool}")" done - IFS="$OLD_IFS" + IFS="${OLD_IFS}" - check_boolean "$quiet" || zfs_log_end_msg $ZFS_ERROR + check_boolean "${quiet}" || zfs_log_end_msg "${ZFS_ERROR}" else # No auto - use value from the command line option. @@ -268,7 +268,7 @@ mountroot() fi # Import the pool (if not already done so in the AUTO check above). - if [ -n "$ZFS_RPOOL" -a -z "${POOL_IMPORTED}" ] + if [ -n "${ZFS_RPOOL}" -a -z "${POOL_IMPORTED}" ] then import_pool "${ZFS_RPOOL}" ZFS_BOOTFS="$(find_rootfs "${pool}")" @@ -279,9 +279,9 @@ mountroot() # No pool imported, this is serious! disable_plymouth echo "" - echo "Command: $ZFS_CMD" - echo "Message: $ZFS_STDERR" - echo "Error: $ZFS_ERROR" + echo "Command: ${ZFS_CMD}" + echo "Message: ${ZFS_STDERR}" + echo "Error: ${ZFS_ERROR}" echo "" echo "No pool imported. Manually import the root pool" echo "at the command prompt and then exit." @@ -309,8 +309,8 @@ mountroot() echo "Error: Unknown root filesystem - no 'bootfs' pool property and" echo " not specified on the kernel command line." echo "" - echo "Manually mount the root filesystem on $rootmnt and then exit." - echo "Hint: Try: mount -o zfsutil -t zfs ${ZFS_RPOOL-rpool}/ROOT/system $rootmnt" + echo "Manually mount the root filesystem on ${rootmnt} and then exit." + echo "Hint: Try: mount -o zfsutil -t zfs ${ZFS_RPOOL-rpool}/ROOT/system ${rootmnt}" emergency_shell fi @@ -319,7 +319,7 @@ mountroot() # * Ideally, the root filesystem would be mounted like this: # - # zpool import -R "$rootmnt" -N "$ZFS_RPOOL" + # zpool import -R "${rootmnt}" -N "${ZFS_RPOOL}" # zfs mount -o mountpoint=/ "${ZFS_BOOTFS}" # # but the MOUNTPOINT prefix is preserved on descendent filesystem @@ -364,8 +364,8 @@ mountroot() echo -n " 'c' for shell, 'r' for reboot, 'ENTER' to continue. " read b - [ "$b" = "c" ] && emergency_shell - [ "$b" = "r" ] && reboot -f + [ "${b}" = "c" ] && emergency_shell + [ "${b}" = "r" ] && reboot -f set +x fi @@ -375,9 +375,9 @@ mountroot() if type run_scripts > /dev/null 2>&1 && \ [ -f "/scripts/local-bottom" -o -d "/scripts/local-bottom" ] then - check_boolean "$quiet" || \ + check_boolean "${quiet}" || \ zfs_log_begin_msg "Running /scripts/local-bottom" run_scripts /scripts/local-bottom - check_boolean "$quiet" || zfs_log_end_msg + check_boolean "${quiet}" || zfs_log_end_msg fi } diff --git a/contrib/shell-common/zfs-functions.in b/contrib/shell-common/zfs-functions.in index ee2b51c8e6d2..6d834abc6f1a 100644 --- a/contrib/shell-common/zfs-functions.in +++ b/contrib/shell-common/zfs-functions.in @@ -40,20 +40,20 @@ elif type success > /dev/null 2>&1 ; then # Fedora/RedHat functions zfs_log_begin_msg() { echo -n "$1 "; } zfs_log_end_msg() { - zfs_set_ifs "$OLD_IFS" + zfs_set_ifs "${OLD_IFS}" if [ "$1" -eq 0 ]; then success else failure fi echo - zfs_set_ifs "$TMP_IFS" + zfs_set_ifs "${TMP_IFS}" } zfs_log_failure_msg() { - zfs_set_ifs "$OLD_IFS" + zfs_set_ifs "${OLD_IFS}" failure echo - zfs_set_ifs "$TMP_IFS" + zfs_set_ifs "${TMP_IFS}" } zfs_log_progress_msg() { echo -n $"$1"; } elif type einfo > /dev/null 2>&1 ; then @@ -67,13 +67,13 @@ else # Unknown - simple substitues. zfs_log_begin_msg() { echo -n "$1"; } zfs_log_end_msg() { - ret=$1 - if [ "$ret" -ge 1 ]; then + ret="$1" + if [ "${ret}" -ge 1 ]; then echo " failed!" else echo " success" fi - return "$ret" + return "${ret}" } zfs_log_failure_msg() { echo "$1"; } zfs_log_progress_msg() { echo -n "$1"; } @@ -144,11 +144,12 @@ zfs_action() local CMD="$*" check_boolean "${quiet}" && \ - zfs_log_begin_msg "$MSG " + zfs_log_begin_msg "${MSG} " check_zfs_debug && \ zfs_log_begin_msg "CMD: '${cmd}'" - zfs_run_cmd $CMD + zfs_run_cmd "${CMD}" + if [ "${ZFS_ERROR}" -eq 0 ]; then (check_boolean "${quiet}" || check_zfs_debug) && \ zfs_log_end_msg "${ZFS_ERROR}" @@ -174,24 +175,24 @@ zfs_daemon_start() if type start-stop-daemon > /dev/null 2>&1 ; then # LSB functions - start-stop-daemon --start --quiet --pidfile "$PIDFILE" \ - --exec "$DAEMON_BIN" --test > /dev/null || return 1 + start-stop-daemon --start --quiet --pidfile "${PIDFILE}" \ + --exec "${DAEMON_BIN}" --test > /dev/null || return 1 - start-stop-daemon --start --quiet --exec "$DAEMON_BIN" -- \ - $DAEMON_ARGS || return 2 + start-stop-daemon --start --quiet --exec "${DAEMON_BIN}" -- \ + ${DAEMON_ARGS} || return 2 # On Debian GNU/Linux, there's a 'sendsigs' script that will # kill basically everything quite early and zed is stopped # much later than that. We don't want zed to be among them, # so add the zed pid to list of pids to ignore. - if [ -f "$PIDFILE" -a -d /run/sendsigs.omit.d ] + if [ -f "${PIDFILE}" -a -d /run/sendsigs.omit.d ] then - ln -sf "$PIDFILE" /run/sendsigs.omit.d/zed + ln -sf "${PIDFILE}" /run/sendsigs.omit.d/zed fi elif type daemon > /dev/null 2>&1 ; then # Fedora/RedHat functions - daemon --pidfile "$PIDFILE" "$DAEMON_BIN" $DAEMON_ARGS - return $? + daemon --pidfile "${PIDFILE}" "${DAEMON_BIN}" ${DAEMON_ARGS} + return "$?" else # Unsupported return 3 @@ -215,16 +216,16 @@ zfs_daemon_stop() if type start-stop-daemon > /dev/null 2>&1 ; then # LSB functions start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \ - --pidfile "$PIDFILE" --name "$DAEMON_NAME" - [ "$?" = 0 ] && rm -f "$PIDFILE" + --pidfile "${PIDFILE}" --name "${DAEMON_NAME}" + [ "$?" = 0 ] && rm -f "${PIDFILE}" - return $? + return "$?" elif type killproc > /dev/null 2>&1 ; then # Fedora/RedHat functions - killproc -p "$PIDFILE" "$DAEMON_NAME" - [ "$?" = 0 ] && rm -f "$PIDFILE" + killproc -p "${PIDFILE}" "${DAEMON_NAME}" + [ "$?" = 0 ] && rm -f "${PIDFILE}" - return $? + return "$?" else # Unsupported return 3 @@ -242,12 +243,12 @@ zfs_daemon_status() if type status_of_proc > /dev/null 2>&1 ; then # LSB functions - status_of_proc "$DAEMON_NAME" "$DAEMON_BIN" - return $? + status_of_proc "${DAEMON_NAME}" "${DAEMON_BIN}" + return "$?" elif type status > /dev/null 2>&1 ; then # Fedora/RedHat functions - status -p "$PIDFILE" "$DAEMON_NAME" - return $? + status -p "${PIDFILE}" "${DAEMON_NAME}" + return "$?" else # Unsupported return 3 @@ -265,12 +266,12 @@ zfs_daemon_reload() if type start-stop-daemon > /dev/null 2>&1 ; then # LSB functions start-stop-daemon --stop --signal 1 --quiet \ - --pidfile "$PIDFILE" --name "$DAEMON_NAME" - return $? + --pidfile "${PIDFILE}" --name "${DAEMON_NAME}" + return "$?" elif type killproc > /dev/null 2>&1 ; then # Fedora/RedHat functions - killproc -p "$PIDFILE" "$DAEMON_NAME" -HUP - return $? + killproc -p "${PIDFILE}" "${DAEMON_NAME}" -HUP + return "$?" else # Unsupported return 3 @@ -283,20 +284,20 @@ zfs_daemon_reload() # Will catch a problem with libraries as well. zfs_installed() { - if [ ! -x "$ZPOOL" ]; then + if [ ! -x "${ZPOOL}" ]; then return 1 else # Test if it works (will catch missing/broken libs etc) - "$ZPOOL" -? > /dev/null 2>&1 - return $? + "${ZPOOL}" -? > /dev/null 2>&1 + return "$?" fi - if [ ! -x "$ZFS" ]; then + if [ ! -x "${ZFS}" ]; then return 2 else # Test if it works (will catch missing/broken libs etc) - "$ZFS" -? > /dev/null 2>&1 - return $? + "${ZFS}" -? > /dev/null 2>&1 + return "$?" fi return 0 @@ -324,7 +325,7 @@ checksystem() # HOWEVER, only do this if we're called at the boot up # (from init), not if we're running interactivly (as in # from the shell - we know what we're doing). - [ -n "$init" ] && exit 3 + [ -n "${init}" ] && exit 3 fi # Check if ZFS is installed. @@ -357,7 +358,7 @@ check_boolean() { local var="$1" - echo "$var" | grep -Eiq "^yes$|^on$|^true$|^1$" && return 0 || return 1 + echo "${var}" | grep -Eiq "^yes$|^on$|^true$|^1$" && return 0 || return 1 } # Check to see if we're running in debug mode @@ -384,8 +385,8 @@ load_module() module="$1" # Load the zfs module stack - if ! check_module_loaded "$module"; then - if ! /sbin/modprobe "$module"; then + if ! check_module_loaded "${module}"; then + if ! /sbin/modprobe "${module}"; then return 5 fi fi @@ -432,7 +433,7 @@ read_mtab() unset $(env | grep ^MTAB_ | sed 's,=.*,,') while read -r fs mntpnt fstype opts rest; do - if echo "$fs $mntpnt $fstype $opts" | grep -qE "$match"; then + if echo "${fs} ${mntpnt} ${fstype} ${opts}" | grep -qE "${match}"; then # * Fix problems (!?) in the mounts file. It will record # 'rpool 1' as 'rpool\0401' instead of 'rpool\00401' # which seems to be the correct (at least as far as @@ -440,16 +441,16 @@ read_mtab() # * We need to use the external echo, because the # internal one would interpret the backslash code # (incorrectly), giving us a  instead. - mntpnt=$(/bin/echo "$mntpnt" | sed "s,\\\0,\\\00,g") - fs=$(/bin/echo "$fs" | sed "s,\\\0,\\\00,") + mntpnt="$(/bin/echo "${mntpnt}" | sed "s,\\\0,\\\00,g")" + fs="$(/bin/echo "${fs}" | sed "s,\\\0,\\\00,")" # Remove 'unwanted' characters. - mntpnt=$(printf '%b\n' "$mntpnt" | sed -e 's,/,,g' \ - -e 's,-,,g' -e 's,\.,,g' -e 's, ,,g') - fs=$(printf '%b\n' "$fs") + mntpnt="$(printf '%b\n' "${mntpnt}" | sed -e 's,/,,g' \ + -e 's,-,,g' -e 's,\.,,g' -e 's, ,,g')" + fs="$(printf '%b\n' "${fs}")" # Set the variable. - eval export MTAB_$mntpnt=\"$fs\" + eval export MTAB_${mntpnt}=\"${fs}\" fi done < /proc/mounts } @@ -460,8 +461,8 @@ in_mtab() local fs="$(echo "$1" | sed 's,/,_,g')" local var - var="$(eval echo MTAB_$fs)" - [ "$(eval echo "$""$var")" != "" ] + var="$(eval echo MTAB_${fs})" + [ "$(eval echo "$""${var}")" != "" ] return "$?" } @@ -479,14 +480,14 @@ read_fstab() i=0 while read -r fs mntpnt fstype opts; do - echo "$fs" | egrep -qE '^#|^$' && continue + echo "${fs}" | egrep -qE '^#|^$' && continue - if echo "$fs $mntpnt $fstype $opts" | grep -qE "$match"; then - eval export FSTAB_dev_$i="$fs" - fs=$(printf '%b\n' "$fs" | sed 's,/,_,g') - eval export FSTAB_$i="$mntpnt" + if echo "${fs} ${mntpnt} ${fstype} ${opts}" | grep -qE "${match}"; then + eval export FSTAB_dev_${i}="${fs}" + fs="$(printf '%b\n' "${fs}" | sed 's,/,_,g')" + eval export FSTAB_${i}="${mntpnt}" - i=$((i + 1)) + i="$((i + 1))" fi done < /etc/fstab } @@ -498,7 +499,7 @@ in_fstab() var="$(eval echo FSTAB_$1)" [ "${var}" != "" ] - return $? + return "$?" } # Check if specified mountpoint is mounted. @@ -509,7 +510,7 @@ is_mounted() mount | \ while read line; do - if echo "$line" | grep -q " on $mntpt "; then + if echo "${line}" | grep -q " on ${mntpt} "; then return 0 fi done @@ -521,9 +522,9 @@ is_mounted() get_fs_value() { local fs="$1" - local value=$2 + local value="$2" - "${ZFS}" get -H -ovalue $value "$fs" 2> /dev/null + "${ZFS}" get -H -ovalue "${value}" "${fs}" 2> /dev/null } # Get a ZFS pool property value. @@ -564,12 +565,12 @@ find_pools() local CMD="$*" local pools pool - pools=$($CMD 2> /dev/null | \ + pools="$(${CMD} 2> /dev/null | \ grep -E "pool:|^[a-zA-Z0-9]" | \ sed 's@.*: @@' | \ while read pool; do \ - echo -n "$pool;" - done) + echo -n "${pool};" + done)" echo "${pools%%;}" # Return without the last ';'. } @@ -580,75 +581,75 @@ get_pools() local available_pools npools if [ -n "${ZFS_POOL_IMPORT}" ]; then - echo "$ZFS_POOL_IMPORT" + echo "${ZFS_POOL_IMPORT}" return 0 fi # Get the base list of availible pools. - available_pools=$(find_pools "$ZPOOL" import) + available_pools="$(find_pools "${ZPOOL}" import)" # Just in case - seen it happen (that a pool isn't visable/found # with a simple "zpool import" but only when using the "-d" # option or setting ZPOOL_IMPORT_PATH). if [ -d "/dev/disk/by-id" ] then - npools=$(find_pools "$ZPOOL" import -d /dev/disk/by-id) - if [ -n "$npools" ] + npools="$(find_pools "${ZPOOL}" import -d /dev/disk/by-id)" + if [ -n "${npools}" ] then # Because we have found extra pool(s) here, which wasn't # found 'normaly', we need to force USE_DISK_BY_ID to # make sure we're able to actually import it/them later. USE_DISK_BY_ID='yes' - if [ -n "$available_pools" ] + if [ -n "${available_pools}" ] then # Filter out duplicates (pools found with the simple # "zpool import" but which is also found with the # "zpool import -d ..."). - npools=$(echo "$npools" | sed "s,$available_pools,,") + npools="$(echo "${npools}" | sed "s,${available_pools},,")" # Add the list to the existing list of # available pools - available_pools="$available_pools;$npools" + available_pools="${available_pools};${npools}" else - available_pools="$npools" + available_pools="${npools}" fi fi fi # Filter out any exceptions... - if [ -n "$ZFS_POOL_EXCEPTIONS" ] + if [ -n "${ZFS_POOL_EXCEPTIONS}" ] then local found="" local apools="" local pool exception - OLD_IFS="$IFS" ; IFS=";" + OLD_IFS="${IFS}" ; IFS=";" - for pool in $available_pools + for pool in ${available_pools} do - for exception in $ZFS_POOL_EXCEPTIONS + for exception in ${ZFS_POOL_EXCEPTIONS} do - [ "$pool" = "$exception" ] && continue 2 - found="$pool" + [ "${pool}" = "${exception}" ] && continue 2 + found="${pool}" done - if [ -n "$found" ] + if [ -n "${found}" ] then - if [ -n "$apools" ] + if [ -n "${apools}" ] then - apools="$apools;$pool" + apools="${apools};${pool}" else - apools="$pool" + apools="${pool}" fi fi done - IFS="$OLD_IFS" - available_pools="$apools" + IFS="${OLD_IFS}" + available_pools="${apools}" fi # Return list of availible pools. - echo "$available_pools" + echo "${available_pools}" } # Import given pool $1 @@ -659,21 +660,21 @@ import_pool() # Verify that the pool isn't already imported # Make as sure as we can to not require '-f' to import. - "${ZPOOL}" status "$pool" > /dev/null 2>&1 && return 0 + "${ZPOOL}" status "${pool}" > /dev/null 2>&1 && return 0 # For backwards compability, make sure that ZPOOL_IMPORT_PATH is set # to something we can use later with the real import(s). We want to # make sure we find all by* dirs, BUT by-vdev should be first (if it # exists). - if [ -n "$USE_DISK_BY_ID" -a -z "$ZPOOL_IMPORT_PATH" ] + if [ -n "${USE_DISK_BY_ID}" -a -z "${ZPOOL_IMPORT_PATH}" ] then dirs="$(for dir in $(echo /dev/disk/by-*) do # Ignore by-vdev here - we want it first! - echo "$dir" | grep -q /by-vdev && continue - [ ! -d "$dir" ] && continue + echo "${dir}" | grep -q /by-vdev && continue + [ ! -d "${dir}" ] && continue - echo -n "$dir:" + echo -n "${dir}:" done | sed 's,:$,,g')" if [ -d "/dev/disk/by-vdev" ] @@ -683,11 +684,11 @@ import_pool() fi # ... and /dev at the very end, just for good measure. - ZPOOL_IMPORT_PATH="$ZPOOL_IMPORT_PATH$dirs:/dev" + ZPOOL_IMPORT_PATH="${ZPOOL_IMPORT_PATH}${dirs}:/dev" fi # Needs to be exported for "zpool" to catch it. - [ -n "$ZPOOL_IMPORT_PATH" ] && export ZPOOL_IMPORT_PATH + [ -n "${ZPOOL_IMPORT_PATH}" ] && export ZPOOL_IMPORT_PATH zfs_action "Importing pool '${pool}' using defaults" \ @@ -706,11 +707,11 @@ import_pool() disable_plymouth if [ "$?" -ne "123" ]; then echo "" - echo "Command: $ZFS_CMD" - echo "Message: $ZFS_STDERR" - echo "Error: $ZFS_ERROR" + echo "Command: ${ZFS_CMD}" + echo "Message: ${ZFS_STDERR}" + echo "Error: ${ZFS_ERROR}" echo "" - echo "Failed to import pool '$pool'." + echo "Failed to import pool '${pool}'." echo "Manually import the pool and exit." emergency_shell else @@ -745,29 +746,29 @@ mount_fs() # can figure out what 'mount' command to use (legacy or native fs). # We overwrite the 'mountpoint' variable later if we are called # with a mountpoint. - mountpoint=$(get_fs_value "$fs" mountpoint) - if [ "$mountpoint" = "legacy" -o "$mountpoint" = "none" ]; then + mountpoint="$(get_fs_value "${fs}" mountpoint)" + if [ "${mountpoint}" = "legacy" -o "${mountpoint}" = "none" ]; then # Can't use the mountpoint property. Might be one of our # clones. Check the 'org.zol:mountpoint' property set in # clone_snap() if that's usable. - mountpoint=$(get_fs_value "$fs" org.zol:mountpoint) - if [ "$mountpoint" = "legacy" -o \ - "$mountpoint" = "none" -o \ - "$mountpoint" = "-" ] + mountpoint="$(get_fs_value "${fs}" org.zol:mountpoint)" + if [ "${mountpoint}" = "legacy" -o \ + "${mountpoint}" = "none" -o \ + "${mountpoint}" = "-" ] then - if [ "$fs" != "${ZFS_BOOTFS}" ]; then + if [ "${fs}" != "${ZFS_BOOTFS}" ]; then # We don't have a proper mountpoint, this # isn't the root fs. So extract the root fs # value from the filesystem, and we should # (hopefully!) have a mountpoint we can use. - mountpoint="${fs##$ZFS_BOOTFS}" + mountpoint="${fs##${ZFS_BOOTFS}}" else # Last hail-mary: Hope 'rootmnt' is set! mountpoint="" fi fi - if [ "$mountpoint" = "legacy" ]; then + if [ "${mountpoint}" = "legacy" ]; then cmd="mount -t zfs" else # If it's not a legacy filesystem, it can only be a @@ -782,7 +783,7 @@ mount_fs() [ -n "${mntpnt}" ] && mountpoint="${mntpnt}" # Possibly decrypt a filesystem using native encryption. - zfs_action "Decrypting ${fs}" decrypt_fs "$fs" + zfs_action "Decrypting ${fs}" decrypt_fs "${fs}" zfs_action "Mounting '${fs}' on '${rootmnt}/${mountpoint}'" \ "${cmd}" "${fs}" "${rootmnt}/${mountpoint}" @@ -792,8 +793,8 @@ mount_fs() if [ "$?" -ne "123" ]; then echo "" echo "Command: ${ZFS_CMD}" - echo "Message: $ZFS_STDERR" - echo "Error: $ZFS_ERROR" + echo "Message: ${ZFS_STDERR}" + echo "Error: ${ZFS_ERROR}" echo "" echo "Failed to mount ${fs} on ${rootmnt}/${mountpoint}." echo "Manually mount the filesystem and exit." @@ -817,10 +818,10 @@ decrypt_fs() "${ZFS}" 2>&1 | grep -q 'key -l ' || return 0 # Check if filesystem is encrypted. If not, exit right here. - [ "$(get_fs_value "$fs" encryption)" != "off" ] || return 0 + [ "$(get_fs_value "${fs}" encryption)" != "off" ] || return 0 - check_boolean "$quiet" || \ - zfs_log_begin_msg "Loading crypto wrapper key for $fs" + check_boolean "${quiet}" || \ + zfs_log_begin_msg "Loading crypto wrapper key for ${fs}" # Just make sure that ALL crypto modules module is loaded. # Simplest just to load all... @@ -832,14 +833,14 @@ decrypt_fs() disable_plymouth if [ "$?" -ne "123" ]; then echo "" - echo "Command: $ZFS_CMD" - echo "Message: $ZFS_STDERR" - echo "Error: $ZFS_ERROR" + echo "Command: ${ZFS_CMD}" + echo "Message: ${ZFS_STDERR}" + echo "Error: ${ZFS_ERROR}" echo "" - echo "Failed to load $mod module." + echo "Failed to load ${mod} module." echo "Please verify that it is availible on the initrd image" echo "(without it it won't be possible to unlock the filesystem)" - echo "and rerun: $ZFS_CMD" + echo "and rerun: ${ZFS_CMD}" emergency_shell else return 1 @@ -857,13 +858,13 @@ decrypt_fs() disable_plymouth if [ "$?" -ne "123" ]; then echo "" - echo "Command: $ZFS_CMD" - echo "Message: $ZFS_STDERR" - echo "Error: $ZFS_ERROR" + echo "Command: ${ZFS_CMD}" + echo "Message: ${ZFS_STDERR}" + echo "Error: ${ZFS_ERROR}" echo "" echo "Failed to load zfs encryption wrapper key (s)." echo "Please verify dataset property 'keysource' for datasets" - echo "and rerun: $ZFS_CMD" + echo "and rerun: ${ZFS_CMD}" emergency_shell else return 1 @@ -886,12 +887,12 @@ destroy_fs() disable_plymouth if [ "$?" -ne "123" ]; then echo "" - echo "Command: $ZFS_CMD" - echo "Message: $ZFS_STDERR" - echo "Error: $ZFS_ERROR" + echo "Command: ${ZFS_CMD}" + echo "Message: ${ZFS_STDERR}" + echo "Error: ${ZFS_ERROR}" echo "" - echo "Failed to destroy '$fs'. Please make sure that '$fs' is not availible." - echo "Hint: Try: zfs destroy -Rfn $fs" + echo "Failed to destroy '${fs}'. Please make sure that '${fs}' is not availible." + echo "Hint: Try: zfs destroy -Rfn ${fs}" echo "If this dryrun looks good, then remove the 'n' from '-Rfn' and try again." emergency_shell else @@ -928,13 +929,13 @@ clone_snap() disable_plymouth if [ "$?" -ne "123" ]; then echo "" - echo "Command: $ZFS_CMD" - echo "Message: $ZFS_STDERR" - echo "Error: $ZFS_ERROR" + echo "Command: ${ZFS_CMD}" + echo "Message: ${ZFS_STDERR}" + echo "Error: ${ZFS_ERROR}" echo "" echo "Failed to clone snapshot." echo "Make sure that the any problems are corrected and then make sure" - echo "that the dataset '$destfs' exists and is bootable." + echo "that the dataset '${destfs}' exists and is bootable." emergency_shell else return 1 @@ -957,9 +958,9 @@ rollback_snap() disable_plymouth if [ "$?" -ne "123" ]; then echo "" - echo "Command: $ZFS_CMD" - echo "Message: $ZFS_STDERR" - echo "Error: $ZFS_ERROR" + echo "Command: ${ZFS_CMD}" + echo "Message: ${ZFS_STDERR}" + echo "Error: ${ZFS_ERROR}" echo "" echo "Failed to rollback snapshot." emergency_shell @@ -993,9 +994,9 @@ ask_user_snap() # stdout to the caller, we use stderr for our questions. echo "What snapshot do you want to boot from?" > /dev/stderr while read snap; do - echo " $i: ${snap}" > /dev/stderr - eval `echo SNAP_$i=$snap` - i=$((i + 1)) + echo " ${i}: ${snap}" > /dev/stderr + eval `echo SNAP_${i}="${snap}"` + i="$((i + 1))" done < rpool/ROOT/debian_snap2/boot # rpool/ROOT/debian/usr@snap2 => rpool/ROOT/debian_snap2/usr # rpool/ROOT/debian/var@snap2 => rpool/ROOT/debian_snap2/var - subfs="${s##$rootfs}" - subfs="${subfs%%@$snapname}" + subfs="${s##${rootfs}}" + subfs="${subfs%%@${snapname}}" destfs="${rootfs}_${snapname}" # base fs. - [ -n "$subfs" ] && destfs="${destfs}$subfs" # + sub fs. + [ -n "${subfs}" ] && destfs="${destfs}${subfs}" # + sub fs. # Get the mountpoint of the filesystem, to be used # with clone_snap(). If legacy or none, then use # the sub fs value. - mountpoint=$(get_fs_value "${s%%@*}" mountpoint) - if [ "$mountpoint" = "legacy" -o \ - "$mountpoint" = "none" ] + mountpoint="$(get_fs_value "${s%%@*}" mountpoint)" + if [ "${mountpoint}" = "legacy" -o \ + "${mountpoint}" = "none" ] then if [ -n "${subfs}" ]; then mountpoint="${subfs}" @@ -1088,8 +1089,8 @@ setup_snapshot_booting() # Clone the snapshot into its own # filesystem - clone_snap "$s" "${destfs}" "${mountpoint}" || \ - retval=$((retval + 1)) + clone_snap "${s}" "${destfs}" "${mountpoint}" || \ + retval="$((retval + 1))" fi done @@ -1100,7 +1101,7 @@ setup_snapshot_booting() # Check if the/a root fs is mounted. chkroot() { while read line; do - set -- $line + set -- ${line} if [ "$2" = "/" ]; then return 0 fi @@ -1126,9 +1127,9 @@ disable_plymouth() # using a temporary global variable (TMP_IFS). zfs_set_ifs() { local tIFS="$1" - if [ -n "$tIFS" ] + if [ -n "${tIFS}" ] then - TMP_IFS="$IFS" - IFS="$tIFS" + TMP_IFS="${IFS}" + IFS="${tIFS}" fi } diff --git a/contrib/sysv-init/zfs-import.in b/contrib/sysv-init/zfs-import.in index aee46cba5ec3..1d43d18c222a 100755 --- a/contrib/sysv-init/zfs-import.in +++ b/contrib/sysv-init/zfs-import.in @@ -50,10 +50,10 @@ do_import() local exception dir ZPOOL_IMPORT_PATH RET=0 r=1 # In case not shutdown cleanly. - [ -n "$init" ] && rm -f /etc/dfs/sharetab + [ -n "${init}" ] && rm -f /etc/dfs/sharetab # Just simplify code later on. - if [ -n "$USE_DISK_BY_ID" ] && ! check_boolean "$USE_DISK_BY_ID" + if [ -n "${USE_DISK_BY_ID}" ] && ! check_boolean "${USE_DISK_BY_ID}" then # It's something, but not 'yes' so it's no good to us. unset USE_DISK_BY_ID @@ -74,21 +74,21 @@ do_import() # Example: Importing ZFS pool pool1 [OK] # Importing ZFS pool pool2 [OK] # [etc] - [ -n "$init" ] && zfs_log_begin_msg "Importing ZFS pool(s)" - OLD_IFS="$IFS" ; IFS=";" - for pool in $POOLS + [ -n "${init}" ] && zfs_log_begin_msg "Importing ZFS pool(s)" + OLD_IFS="${IFS}" ; IFS=";" + for pool in ${POOLS} do - [ -z "$pool" ] && continue + [ -z "${pool}" ] && continue # We have pools that haven't been imported - import them - if [ -n "$init" ] + if [ -n "${init}" ] then # Not interactive - a dot for each pool. # Except on Gentoo where this doesn't work. zfs_log_progress_msg "." else # Interactive - one 'Importing ...' line per pool - zfs_log_begin_msg "Importing ZFS pool $pool" + zfs_log_begin_msg "Importing ZFS pool ${pool}" fi # Import by using ZPOOL_IMPORT_PATH (either set above or in @@ -96,19 +96,19 @@ do_import() # paths. This is the prefered way. import_pool "${pool}" r="$?" ; RET=$((RET + r)) - if [ "$r" -eq 0 ] + if [ "${r}" -eq 0 ] then # Output success and process the next pool - [ -z "$init" ] && zfs_log_end_msg 0 + [ -z "${init}" ] && zfs_log_end_msg 0 continue fi - zfs_log_end_msg "$RET" + zfs_log_end_msg "${RET}" done - [ -n "$init" ] && zfs_log_end_msg "$RET" + [ -n "${init}" ] && zfs_log_end_msg "${RET}" - IFS="$OLD_IFS" + IFS="${OLD_IFS}" - return "$RET" + return "${RET}" } # Export all pools @@ -117,35 +117,35 @@ do_export() local already_imported pool root_pool RET r RET=0 - root_pool=$(get_root_pool) + root_pool="$(get_root_pool)" - [ -n "$init" ] && zfs_log_begin_msg "Exporting ZFS pool(s)" + [ -n "${init}" ] && zfs_log_begin_msg "Exporting ZFS pool(s)" # Find list of already imported pools. - already_imported=$(find_pools "$ZPOOL" list -H -oname) + already_imported="$(find_pools "${ZPOOL}" list -H -oname)" - OLD_IFS="$IFS" ; IFS=";" - for pool in $already_imported; do - [ "$pool" = "$root_pool" ] && continue + OLD_IFS="${IFS}" ; IFS=";" + for pool in ${already_imported}; do + [ "${pool}" = "${root_pool}" ] && continue - if [ -z "$init" ] + if [ -z "${init}" ] then # Interactive - one 'Importing ...' line per pool - zfs_log_begin_msg "Exporting ZFS pool $pool" + zfs_log_begin_msg "Exporting ZFS pool ${pool}" else # Not interactive - a dot for each pool. zfs_log_progress_msg "." fi - "$ZPOOL" export "$pool" - r="$?" ; RET=$((RET + r)) - [ -z "$init" ] && zfs_log_end_msg "$r" + "${ZPOOL}" export "${pool}" + r="$?" ; RET="$((RET + r))" + [ -z "${init}" ] && zfs_log_end_msg "${r}" done - IFS="$OLD_IFS" + IFS="${OLD_IFS}" - [ -n "$init" ] && zfs_log_end_msg "$RET" + [ -n "${init}" ] && zfs_log_end_msg "${RET}" - return "$RET" + return "${RET}" } # Output the status and list of pools @@ -153,29 +153,29 @@ do_status() { check_module_loaded "zfs" || exit 0 - "$ZPOOL" status && echo "" && "$ZPOOL" list + "${ZPOOL}" status && echo "" && "${ZPOOL}" list } do_start() { - if check_boolean "$VERBOSE_MOUNT" + if check_boolean "${VERBOSE_MOUNT}" then zfs_log_begin_msg "Checking if ZFS userspace tools present" fi if checksystem then - check_boolean "$VERBOSE_MOUNT" && zfs_log_end_msg 0 + check_boolean "${VERBOSE_MOUNT}" && zfs_log_end_msg 0 - check_boolean "$VERBOSE_MOUNT" && \ + check_boolean "${VERBOSE_MOUNT}" && \ zfs_log_begin_msg "Loading kernel ZFS infrastructure" if ! load_module "zfs" then - check_boolean "$VERBOSE_MOUNT" && zfs_log_end_msg 1 + check_boolean "${VERBOSE_MOUNT}" && zfs_log_end_msg 1 return 5 fi - check_boolean "$VERBOSE_MOUNT" && zfs_log_end_msg 0 + check_boolean "${VERBOSE_MOUNT}" && zfs_log_end_msg 0 do_import && udev_trigger # just to make sure we get zvols. diff --git a/contrib/sysv-init/zfs-mount.in b/contrib/sysv-init/zfs-mount.in index be064a070757..db25099453e4 100755 --- a/contrib/sysv-init/zfs-mount.in +++ b/contrib/sysv-init/zfs-mount.in @@ -56,55 +56,55 @@ do_mount() { local verbose overlay i mntpt val - check_boolean "$VERBOSE_MOUNT" && verbose=v - check_boolean "$DO_OVERLAY_MOUNTS" && overlay=O + check_boolean "${VERBOSE_MOUNT}" && verbose=v + check_boolean "${DO_OVERLAY_MOUNTS}" && overlay=O zfs_action "Mounting ZFS filesystem(s)" \ - "$ZFS" mount -a$verbose$overlay "$MOUNT_EXTRA_OPTIONS" + "${ZFS}" mount -a${verbose}${overlay} "${MOUNT_EXTRA_OPTIONS}" # Require each volume/filesytem to have 'noauto' and no fsck # option. This shouldn't really be necessary, as long as one # can get zfs-import to run sufficiently early on in the boot # process - before local mounts. This is just here in case/if # this isn't possible. - check_boolean "$VERBOSE_MOUNT" && \ + check_boolean "${VERBOSE_MOUNT}" && \ zfs_log_begin_msg "Mounting volumes and filesystems registered in fstab" read_mtab "^/dev/(zd|zvol)" read_fstab "^/dev/(zd|zvol)" - i=0; var=$(eval echo FSTAB_$i) - while [ -n "$(eval echo "$""$var")" ] + i=0; var=$(eval echo FSTAB_${i}) + while [ -n "$(eval echo "$""${var}")" ] do - mntpt=$(eval echo "$""$var") - dev=$(eval echo "$"FSTAB_dev_$i) - if ! in_mtab "$mntpt" && ! is_mounted "$mntpt" && [ -e "$dev" ] + mntpt=$(eval echo "$""${var}") + dev=$(eval echo "$"FSTAB_dev_${i}) + if ! in_mtab "${mntpt}" && ! is_mounted "${mntpt}" && [ -e "${dev}" ] then - check_boolean "$VERBOSE_MOUNT" && \ - zfs_log_progress_msg "$mntpt " - fsck "$dev" && mount "$mntpt" + check_boolean "${VERBOSE_MOUNT}" && \ + zfs_log_progress_msg "${mntpt} " + fsck "${dev}" && mount "${mntpt}" fi i=$((i + 1)) - var=$(eval echo FSTAB_$i) + var=$(eval echo FSTAB_${i}) done read_mtab "[[:space:]]zfs[[:space:]]" read_fstab "[[:space:]]zfs[[:space:]]" - i=0; var=$(eval echo FSTAB_$i) - while [ -n "$(eval echo "$""$var")" ] + i=0; var=$(eval echo FSTAB_${i}) + while [ -n "$(eval echo "$""${var}")" ] do - mntpt=$(eval echo "$""$var") - if ! in_mtab "$mntpt" && ! is_mounted "$mntpt" + mntpt=$(eval echo "$""${var}") + if ! in_mtab "${mntpt}" && ! is_mounted "${mntpt}" then - check_boolean "$VERBOSE_MOUNT" && \ - zfs_log_progress_msg "$mntpt " - mount "$mntpt" + check_boolean "${VERBOSE_MOUNT}" && \ + zfs_log_progress_msg "${mntpt} " + mount "${mntpt}" fi i=$((i + 1)) - var=$(eval echo FSTAB_$i) + var=$(eval echo FSTAB_${i}) done - check_boolean "$VERBOSE_MOUNT" && zfs_log_end_msg 0 + check_boolean "${VERBOSE_MOUNT}" && zfs_log_end_msg 0 return 0 } @@ -118,52 +118,52 @@ do_unmount() # zfs-import to run sufficiently late in the shutdown/reboot process # - after unmounting local filesystems. This is just here in case/if # this isn't possible. - zfs_action "Unmounting ZFS filesystems" "$ZFS" unmount -a + zfs_action "Unmounting ZFS filesystems" "${ZFS}" unmount -a - check_boolean "$VERBOSE_MOUNT" && \ + check_boolean "${VERBOSE_MOUNT}" && \ zfs_log_begin_msg "Unmounting volumes and filesystems registered in fstab" read_mtab "^/dev/(zd|zvol)" read_fstab "^/dev/(zd|zvol)" - i=0; var=$(eval echo FSTAB_$i) - while [ -n "$(eval echo "$""$var")" ] + i=0; var=$(eval echo FSTAB_${i}) + while [ -n "$(eval echo "$""${var}")" ] do - mntpt=$(eval echo "$""$var") - dev=$(eval echo "$"FSTAB_dev_$i) - if in_mtab "$mntpt" + mntpt=$(eval echo "$""${var}") + dev=$(eval echo "$"FSTAB_dev_${i}) + if in_mtab "${mntpt}" then - check_boolean "$VERBOSE_MOUNT" && \ - zfs_log_progress_msg "$mntpt " - umount "$mntpt" + check_boolean "${VERBOSE_MOUNT}" && \ + zfs_log_progress_msg "${mntpt} " + umount "${mntpt}" fi i=$((i + 1)) - var=$(eval echo FSTAB_$i) + var=$(eval echo FSTAB_${i}) done read_mtab "[[:space:]]zfs[[:space:]]" read_fstab "[[:space:]]zfs[[:space:]]" - i=0; var=$(eval echo FSTAB_$i) - while [ -n "$(eval echo "$""$var")" ] + i=0; var=$(eval echo FSTAB_${i}) + while [ -n "$(eval echo "$""${var}")" ] do - mntpt=$(eval echo "$""$var") - if in_mtab "$mntpt"; then - check_boolean "$VERBOSE_MOUNT" && \ - zfs_log_progress_msg "$mntpt " - umount "$mntpt" + mntpt=$(eval echo "$""${var}") + if in_mtab "${mntpt}"; then + check_boolean "${VERBOSE_MOUNT}" && \ + zfs_log_progress_msg "${mntpt} " + umount "${mntpt}" fi i=$((i + 1)) - var=$(eval echo FSTAB_$i) + var=$(eval echo FSTAB_${i}) done - check_boolean "$VERBOSE_MOUNT" && zfs_log_end_msg 0 + check_boolean "${VERBOSE_MOUNT}" && zfs_log_end_msg 0 return 0 } do_start() { - check_boolean "$ZFS_MOUNT" || exit 0 + check_boolean "${ZFS_MOUNT}" || exit 0 check_module_loaded "zfs" || exit 0 @@ -179,7 +179,7 @@ do_start() do_stop() { - check_boolean "$ZFS_UNMOUNT" || exit 0 + check_boolean "${ZFS_UNMOUNT}" || exit 0 check_module_loaded "zfs" || exit 0 @@ -207,7 +207,7 @@ then ;; esac - exit $? + exit "$?" else # Create wrapper functions since Gentoo don't use the case part. depend() { do_depend; } diff --git a/contrib/sysv-init/zfs-share.in b/contrib/sysv-init/zfs-share.in index 1b70da4d50c7..07e4c64a0c81 100755 --- a/contrib/sysv-init/zfs-share.in +++ b/contrib/sysv-init/zfs-share.in @@ -40,20 +40,20 @@ do_depend() do_start() { - check_boolean "$ZFS_SHARE" || exit 0 + check_boolean "${ZFS_SHARE}" || exit 0 check_module_loaded "zfs" || exit 0 - zfs_action "Sharing ZFS filesystems" "$ZFS" share -a + zfs_action "Sharing ZFS filesystems" "${ZFS}" share -a } do_stop() { - check_boolean "$ZFS_UNSHARE" || exit 0 + check_boolean "${ZFS_UNSHARE}" || exit 0 check_module_loaded "zfs" || exit 0 - zfs_action "Unsharing ZFS filesystems" "$ZFS" unshare -a + zfs_action "Unsharing ZFS filesystems" "${ZFS}" unshare -a } # ---------------------------------------------------- @@ -76,7 +76,7 @@ if [ ! -e /etc/gentoo-release ]; then ;; esac - exit $? + exit "$?" else # Create wrapper functions since Gentoo don't use the case part. depend() { do_depend; } diff --git a/contrib/sysv-init/zfs-zed.in b/contrib/sysv-init/zfs-zed.in index 86e31855ed8a..a7594c61d760 100755 --- a/contrib/sysv-init/zfs-zed.in +++ b/contrib/sysv-init/zfs-zed.in @@ -30,12 +30,12 @@ . @sysconfdir@/zfs/zfs-functions ZED_NAME="zed" -ZED_PIDFILE="@runstatedir@/$ZED_NAME.pid" +ZED_PIDFILE="@runstatedir@/${ZED_NAME}.pid" extra_started_commands="reload" # Exit if the package is not installed -[ -x "$ZED" ] || exit 0 +[ -x "${ZED}" ] || exit 0 # ---------------------------------------------------- @@ -48,10 +48,10 @@ do_start() { check_module_loaded "zfs" || exit 0 - ZED_ARGS="$ZED_ARGS -p $ZED_PIDFILE" + ZED_ARGS="${ZED_ARGS} -p ${ZED_PIDFILE}" zfs_action "Starting ZFS Event Daemon" zfs_daemon_start \ - "$ZED_PIDFILE" "$ZED" "$ZED_ARGS" + "${ZED_PIDFILE}" "${ZED}" "${ZED_ARGS}" return "$?" } @@ -61,12 +61,12 @@ do_stop() check_module_loaded "zfs" || exit 0 zfs_action "Stopping ZFS Event Daemon" zfs_daemon_stop \ - "$ZED_PIDFILE" "$ZED" "$ZED_NAME" + "${ZED_PIDFILE}" "${ZED}" "${ZED_NAME}" if [ "$?" -eq "0" ] then # Let's see if we have any pools imported - pools=$("$ZPOOL" list -H -oname) - if [ -z "$pools" ] + pools=$("${ZPOOL}" list -H -oname) + if [ -z "${pools}" ] then # No pools imported, it is/should be safe/possible to # unload modules. @@ -83,7 +83,7 @@ do_status() { check_module_loaded "zfs" || exit 0 - zfs_daemon_status "$ZED_PIDFILE" "$ZED" "$ZED_NAME" + zfs_daemon_status "${ZED_PIDFILE}" "${ZED}" "${ZED_NAME}" return "$?" } @@ -92,7 +92,7 @@ do_reload() check_module_loaded "zfs" || exit 0 zfs_action "Reloading ZFS Event Daemon" zfs_daemon_reload \ - "$ZED_PIDFILE" "$ZED_NAME" + "${ZED_PIDFILE}" "${ZED_NAME}" return "$?" } @@ -123,7 +123,7 @@ if [ ! -e /etc/gentoo-release ]; then ;; esac - exit $? + exit "$?" else # Create wrapper functions since Gentoo don't use the case part. depend() { do_depend; }