aboutsummaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/dracut/02zfsexpandknowledge/module-setup.sh.in47
-rwxr-xr-xcontrib/dracut/90zfs/module-setup.sh.in1
-rwxr-xr-xcontrib/dracut/90zfs/mount-zfs.sh.in2
-rwxr-xr-xcontrib/dracut/90zfs/parse-zfs.sh.in3
-rwxr-xr-xcontrib/dracut/90zfs/zfs-generator.sh.in1
-rwxr-xr-xcontrib/dracut/90zfs/zfs-lib.sh.in4
-rwxr-xr-xcontrib/dracut/90zfs/zfs-load-key.sh.in1
-rwxr-xr-xcontrib/initramfs/hooks/zfs.in2
-rwxr-xr-xcontrib/initramfs/scripts/local-top/zfs21
9 files changed, 36 insertions, 46 deletions
diff --git a/contrib/dracut/02zfsexpandknowledge/module-setup.sh.in b/contrib/dracut/02zfsexpandknowledge/module-setup.sh.in
index 12f5d91e9..d21ab74cc 100755
--- a/contrib/dracut/02zfsexpandknowledge/module-setup.sh.in
+++ b/contrib/dracut/02zfsexpandknowledge/module-setup.sh.in
@@ -14,21 +14,16 @@ get_pool_devices() {
local poolconfigtemp
local poolconfigoutput
local pooldev
- local prefix
local resolved
- poolconfigtemp=`mktemp`
+ poolconfigtemp="$(mktemp)"
if ! @sbindir@/zpool list -v -H -P "$1" > "$poolconfigtemp" 2>&1 ; then
- poolconfigoutput=$(cat "$poolconfigtemp")
+ poolconfigoutput="$(cat "$poolconfigtemp")"
dinfo "zfsexpandknowledge: pool $1 cannot be listed: $poolconfigoutput"
else
- cat "$poolconfigtemp" | awk -F '\t' '/\t\/dev/ { print $2 }' | \
- while read pooldev ; do
- if [ -n "$pooldev" -a -e "$pooldev" ] ; then
- if [ -h "$pooldev" ] ; then
- resolved=`readlink -f "$pooldev"`
- else
- resolved="$pooldev"
- fi
+ awk -F '\t' '/\t\/dev/ { print $2 }' "$poolconfigtemp" | \
+ while read -r pooldev ; do
+ if [ -e "$pooldev" ] ; then
+ resolved="$(readlink -f "$pooldev")"
dinfo "zfsexpandknowledge: pool $1 has device $pooldev (which resolves to $resolved)"
echo "$resolved"
fi
@@ -39,22 +34,20 @@ get_pool_devices() {
find_zfs_block_devices() {
local dev
- local blockdev
local mp
local fstype
local pool
- local key
- local n
- local poolconfigoutput
- numfields=`head -1 /proc/self/mountinfo | awk '{print NF}'`
- if [ "$numfields" == "10" ] ; then
- fields="n n n n mp n n fstype dev n"
+ local _
+ numfields="$(awk '{print NF; exit}' /proc/self/mountinfo)"
+ if [ "$numfields" = "10" ] ; then
+ fields="_ _ _ _ mp _ _ fstype dev _"
else
- fields="n n n n mp n n n fstype dev n"
+ fields="_ _ _ _ mp _ _ _ fstype dev _"
fi
- while read $fields ; do
- if [ "$fstype" != "zfs" ]; then continue ; fi
- if [ "$mp" == "$1" ]; then
+ # shellcheck disable=SC2086
+ while read -r ${fields?} ; do
+ [ "$fstype" = "zfs" ] || continue
+ if [ "$mp" = "$1" ]; then
pool=$(echo "$dev" | cut -d / -f 1)
get_pool_devices "$pool"
fi
@@ -76,10 +69,9 @@ check() {
local _depdev
local _depdevname
local _depdevtype
- local _depmajmin
- local _dev
-if [[ $hostonly ]]; then
+# shellcheck disable=SC2154
+if [ -n "$hostonly" ]; then
for mp in \
"/" \
@@ -106,13 +98,12 @@ if [[ $hostonly ]]; then
fstype=$(get_devtype "$dev")
host_fs_types["$dev"]="$fstype"
majmin=$(get_maj_min "$dev")
- if [[ -d /sys/dev/block/$majmin/slaves ]] ; then
- for _depdev in /sys/dev/block/$majmin/slaves/*; do
+ if [ -d "/sys/dev/block/$majmin/slaves" ] ; then
+ for _depdev in "/sys/dev/block/$majmin/slaves"/*; do
[[ -f $_depdev/dev ]] || continue
_depdev=/dev/$(basename "$_depdev")
_depdevname=$(udevadm info --query=property --name="$_depdev" | grep "^DEVNAME=" | sed 's|^DEVNAME=||')
_depdevtype=$(get_devtype "$_depdevname")
- _depmajmin=$(get_maj_min "$_depdevname")
dinfo "zfsexpandknowledge: underlying block device backing ZFS dataset $mp: ${_depdevname//$'\n'/ }"
array_contains "$_depdevname" "${host_devs[@]}" || host_devs+=("$_depdevname")
host_fs_types["$_depdevname"]="$_depdevtype"
diff --git a/contrib/dracut/90zfs/module-setup.sh.in b/contrib/dracut/90zfs/module-setup.sh.in
index c545c8838..90d4cfc63 100755
--- a/contrib/dracut/90zfs/module-setup.sh.in
+++ b/contrib/dracut/90zfs/module-setup.sh.in
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
+# shellcheck disable=SC2154
check() {
# We depend on udev-rules being loaded
diff --git a/contrib/dracut/90zfs/mount-zfs.sh.in b/contrib/dracut/90zfs/mount-zfs.sh.in
index 5ad6a0f26..4f2a51ca6 100755
--- a/contrib/dracut/90zfs/mount-zfs.sh.in
+++ b/contrib/dracut/90zfs/mount-zfs.sh.in
@@ -1,4 +1,5 @@
#!/bin/sh
+# shellcheck disable=SC2034,SC2154
. /lib/dracut-zfs-lib.sh
@@ -39,6 +40,7 @@ udevadm settle
if [ "${root}" = "zfs:AUTO" ] ; then
if ! ZFS_DATASET="$(find_bootfs)" ; then
+ # shellcheck disable=SC2086
zpool import -N -a ${ZPOOL_IMPORT_OPTS}
if ! ZFS_DATASET="$(find_bootfs)" ; then
warn "ZFS: No bootfs attribute found in importable pools."
diff --git a/contrib/dracut/90zfs/parse-zfs.sh.in b/contrib/dracut/90zfs/parse-zfs.sh.in
index 768de9dd2..fe786a880 100755
--- a/contrib/dracut/90zfs/parse-zfs.sh.in
+++ b/contrib/dracut/90zfs/parse-zfs.sh.in
@@ -1,4 +1,5 @@
#!/bin/sh
+# shellcheck disable=SC2034,SC2154
. /lib/dracut-lib.sh
@@ -28,7 +29,7 @@ case "${root}" in
info "ZFS: Enabling autodetection of bootfs after udev settles."
;;
- ZFS\=*|zfs:*|zfs:FILESYSTEM\=*|FILESYSTEM\=*)
+ ZFS=*|zfs:*|FILESYSTEM=*)
# root is explicit ZFS root. Parse it now. We can handle
# a root=... param in any of the following formats:
# root=ZFS=rpool/ROOT
diff --git a/contrib/dracut/90zfs/zfs-generator.sh.in b/contrib/dracut/90zfs/zfs-generator.sh.in
index e3fbf334f..b57c64c68 100755
--- a/contrib/dracut/90zfs/zfs-generator.sh.in
+++ b/contrib/dracut/90zfs/zfs-generator.sh.in
@@ -1,4 +1,5 @@
#!/bin/sh
+# shellcheck disable=SC2016,SC1004
grep -wq debug /proc/cmdline && debug=1
[ -n "$debug" ] && echo "zfs-generator: starting" >> /dev/kmsg
diff --git a/contrib/dracut/90zfs/zfs-lib.sh.in b/contrib/dracut/90zfs/zfs-lib.sh.in
index 98e4452a7..10b0b701a 100755
--- a/contrib/dracut/90zfs/zfs-lib.sh.in
+++ b/contrib/dracut/90zfs/zfs-lib.sh.in
@@ -59,6 +59,7 @@ import_pool() {
if ! zpool list -H "${pool}" > /dev/null 2>&1; then
info "ZFS: Importing pool ${pool}..."
+ # shellcheck disable=SC2086
if ! zpool import -N ${ZPOOL_IMPORT_OPTS} "${pool}" ; then
warn "ZFS: Unable to import pool ${pool}"
return 1
@@ -123,13 +124,12 @@ for_relevant_root_children() {
# export_all OPTS
# exports all imported zfs pools.
export_all() {
- opts="${@}"
ret=0
IFS="${NEWLINE}"
for pool in $(zpool list -H -o name) ; do
if zpool list -H "${pool}" > /dev/null 2>&1; then
- zpool export "${pool}" ${opts} || ret=$?
+ zpool export "${pool}" "$@" || ret=$?
fi
done
IFS="${OLDIFS}"
diff --git a/contrib/dracut/90zfs/zfs-load-key.sh.in b/contrib/dracut/90zfs/zfs-load-key.sh.in
index 9b7716ae9..f8d664b71 100755
--- a/contrib/dracut/90zfs/zfs-load-key.sh.in
+++ b/contrib/dracut/90zfs/zfs-load-key.sh.in
@@ -1,4 +1,5 @@
#!/bin/sh
+# shellcheck disable=SC2154
# only run this on systemd systems, we handle the decrypt in mount-zfs.sh in the mount hook otherwise
[ -e /bin/systemctl ] || [ -e /usr/bin/systemctl ] || return 0
diff --git a/contrib/initramfs/hooks/zfs.in b/contrib/initramfs/hooks/zfs.in
index 613593c36..32331b264 100755
--- a/contrib/initramfs/hooks/zfs.in
+++ b/contrib/initramfs/hooks/zfs.in
@@ -26,7 +26,7 @@ fi
# We use pthreads, but i-t from buster doesn't automatically
# copy this indirect dependency: this can be removed when buster finally dies.
-for libgcc in $(find /lib/ -type f -name libgcc_s.so.[1-9]); do
+find /lib/ -type f -name "libgcc_s.so.[1-9]" | while read -r libgcc; do
copy_exec "$libgcc"
done
diff --git a/contrib/initramfs/scripts/local-top/zfs b/contrib/initramfs/scripts/local-top/zfs
index e8e5cd264..6b80e9f43 100755
--- a/contrib/initramfs/scripts/local-top/zfs
+++ b/contrib/initramfs/scripts/local-top/zfs
@@ -1,18 +1,11 @@
#!/bin/sh
-PREREQ="mdadm mdrun multipath"
+# shellcheck disable=SC2154
-prereqs()
-{
- echo "$PREREQ"
-}
-case $1 in
-# get pre-requisites
-prereqs)
- prereqs
+if [ "$1" = "prereqs" ]; then
+ echo mdadm mdrun multipath
exit 0
- ;;
-esac
+fi
#
@@ -20,10 +13,10 @@ esac
#
message()
{
- if [ -x /bin/plymouth ] && plymouth --ping; then
- plymouth message --text="$@"
+ if plymouth --ping 2>/dev/null; then
+ plymouth message --text="$*"
else
- echo "$@" >&2
+ echo "$*" >&2
fi
return 0
}