summarylogtreecommitdiffstats
path: root/zfs-utils.initcpio.hook
diff options
context:
space:
mode:
Diffstat (limited to 'zfs-utils.initcpio.hook')
-rw-r--r--zfs-utils.initcpio.hook38
1 files changed, 21 insertions, 17 deletions
diff --git a/zfs-utils.initcpio.hook b/zfs-utils.initcpio.hook
index 8f1d587b01ab..09d081f04b69 100644
--- a/zfs-utils.initcpio.hook
+++ b/zfs-utils.initcpio.hook
@@ -1,3 +1,9 @@
+#
+# WARNING: This script is parsed by ash in busybox at boot time, not bash!
+# http://linux.die.net/man/1/ash
+# https://wiki.ubuntu.com/DashAsBinSh
+# http://www.jpsdomain.org/public/2008-JP_bash_vs_dash.pdf
+#
ZPOOL_FORCE=""
ZPOOL_IMPORT_FLAGS=""
@@ -31,24 +37,24 @@ zfs_mount_handler () {
fi
local pool="${ZFS_DATASET%%/*}"
- local rwopt_exp=${rwopt:-ro}
+ local rwopt_exp="${rwopt:-ro}"
- if ! zpool list -H ${pool} 2>1 > /dev/null ; then
- if [ "${rwopt_exp}" != "rw" ]; then
+ if ! zpool list -H "${pool}" 2>1 > /dev/null ; then
+ if [ ! "${rwopt_exp}" = "rw" ]; then
msg "ZFS: Importing pool ${pool} readonly."
ZPOOL_IMPORT_FLAGS="${ZPOOL_IMPORT_FLAGS} -o readonly=on"
else
msg "ZFS: Importing pool ${pool}."
fi
- if ! zpool import ${ZPOOL_IMPORT_FLAGS} -N ${pool} ${ZPOOL_FORCE} ; then
+ if ! zpool import ${ZPOOL_IMPORT_FLAGS} -N "${pool}" ${ZPOOL_FORCE} ; then
die "ZFS: Unable to import pool ${pool}."
fi
fi
- local node=$1
- local tab_file="$node/etc/fstab"
- local zfs_datasets=$(zfs list -H -o name -t filesystem -r "${ZFS_DATASET}")
+ local node="$1"
+ local tab_file="${node}/etc/fstab"
+ local zfs_datasets="$(zfs list -H -o name -t filesystem -r ${ZFS_DATASET})"
# Mount the root, and any child datasets
for dataset in ${zfs_datasets}; do
@@ -75,35 +81,33 @@ zfs_mount_handler () {
run_hook() {
# Force import the pools, useful if the pool has not properly been exported using 'zpool export <pool>'
- [[ ${zfs_force} == 1 ]] && ZPOOL_FORCE='-f'
+ [ ! "${zfs_force}" = "" ] && ZPOOL_FORCE="-f"
# Add import directory to import command flags
- [[ "${zfs_import_dir}" != "" ]] && ZPOOL_IMPORT_FLAGS="${ZPOOL_IMPORT_FLAGS} -d ${zfs_import_dir}"
+ [ ! "${zfs_import_dir}" = "" ] && ZPOOL_IMPORT_FLAGS="${ZPOOL_IMPORT_FLAGS} -d ${zfs_import_dir}"
# Wait 15 seconds for ZFS devices to show up
- [[ "${zfs_wait}" == "" ]] && ZFS_WAIT="15" || ZFS_WAIT="${zfs_wait}"
+ [ "${zfs_wait}" = "" ] && ZFS_WAIT="15" || ZFS_WAIT="${zfs_wait}"
- if [[ "${root}" == 'zfs' ]]; then
- mount_handler='zfs_mount_handler'
- fi
+ [ "${root}" = "zfs" ] && mount_handler="zfs_mount_handler"
case ${zfs} in
"")
# skip this line/dataset
;;
auto|bootfs)
- ZFS_DATASET='bootfs'
+ ZFS_DATASET="bootfs"
mount_handler="zfs_mount_handler"
;;
*)
- ZFS_DATASET=${zfs}
+ ZFS_DATASET="${zfs}"
mount_handler="zfs_mount_handler"
;;
esac
# Allow up to n seconds for zfs device to show up
- for i in {1..${ZFS_WAIT}}; do
- [[ -c "/dev/zfs" ]] && break
+ for i in $(seq 1 ${ZFS_WAIT}); do
+ [ -c "/dev/zfs" ] && break
sleep 1
done
}