aboutsummaryrefslogtreecommitdiffstats
path: root/etc/init.d
diff options
context:
space:
mode:
authorнаб <[email protected]>2021-05-21 23:43:38 +0200
committerBrian Behlendorf <[email protected]>2021-06-09 13:05:34 -0700
commit132240507d0ab2999e764537b181e89ecc3c2b0e (patch)
tree3450e3a8132bbdc611944445146f259e541a0261 /etc/init.d
parentd6f8f41c21b42a1b5a36850c0f7b18be9a05ecd9 (diff)
Turn shellcheck into a normal make target. Fix new files it caught
This checks every file it checked (and a few more), but explicitly instead of "if it works it works" best-effort (which wasn't that good anyway) Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #10512 Closes #12101
Diffstat (limited to 'etc/init.d')
-rw-r--r--etc/init.d/Makefile.am3
-rwxr-xr-xetc/init.d/zfs-import.in5
-rwxr-xr-xetc/init.d/zfs-mount.in36
-rwxr-xr-xetc/init.d/zfs-zed.in1
4 files changed, 26 insertions, 19 deletions
diff --git a/etc/init.d/Makefile.am b/etc/init.d/Makefile.am
index 9285a995a..f93af1fd7 100644
--- a/etc/init.d/Makefile.am
+++ b/etc/init.d/Makefile.am
@@ -1,7 +1,10 @@
include $(top_srcdir)/config/Substfiles.am
+include $(top_srcdir)/config/Shellcheck.am
EXTRA_DIST += README.md
init_SCRIPTS = zfs-import zfs-mount zfs-share zfs-zed
SUBSTFILES += $(init_SCRIPTS)
+
+SHELLCHECK_SHELL = dash # local variables
diff --git a/etc/init.d/zfs-import.in b/etc/init.d/zfs-import.in
index 6b1b2f243..e4bc7b833 100755
--- a/etc/init.d/zfs-import.in
+++ b/etc/init.d/zfs-import.in
@@ -72,6 +72,7 @@ do_import_all_visible()
local exception dir ZPOOL_IMPORT_PATH RET=0 r=1
# In case not shutdown cleanly.
+ # shellcheck disable=SC2154
[ -n "$init" ] && rm -f /etc/dfs/sharetab
# Just simplify code later on.
@@ -157,7 +158,7 @@ do_import_all_visible()
echo "$dir" | grep -q /by-vdev && continue
[ ! -d "$dir" ] && continue
- echo -n "$dir:"
+ printf "%s" "$dir:"
done | sed 's,:$,,g')"
if [ -d "/dev/disk/by-vdev" ]
@@ -214,6 +215,7 @@ do_import_all_visible()
# Import by using ZPOOL_IMPORT_PATH (either set above or in
# the config file) _or_ with the 'built in' default search
# paths. This is the preferred way.
+ # shellcheck disable=SC2086
"$ZPOOL" import -N ${ZPOOL_IMPORT_OPTS} "$pool" 2> /dev/null
r="$?" ; RET=$((RET + r))
if [ "$r" -eq 0 ]
@@ -235,6 +237,7 @@ do_import_all_visible()
zfs_log_progress_msg " using cache file"
fi
+ # shellcheck disable=SC2086
"$ZPOOL" import -c "$ZPOOL_CACHE" -N ${ZPOOL_IMPORT_OPTS} \
"$pool" 2> /dev/null
r="$?" ; RET=$((RET + r))
diff --git a/etc/init.d/zfs-mount.in b/etc/init.d/zfs-mount.in
index cb571faf9..000619b67 100755
--- a/etc/init.d/zfs-mount.in
+++ b/etc/init.d/zfs-mount.in
@@ -80,11 +80,11 @@ do_mount()
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="FSTAB_0"
+ while [ -n "$(eval echo "\$$var")" ]
do
- mntpt=$(eval echo "$""$var")
- dev=$(eval echo "$"FSTAB_dev_$i)
+ mntpt=$(eval echo "\$$var")
+ dev=$(eval echo "\$FSTAB_dev_$i")
if ! in_mtab "$mntpt" && ! is_mounted "$mntpt" && [ -e "$dev" ]
then
check_boolean "$VERBOSE_MOUNT" && \
@@ -93,15 +93,15 @@ do_mount()
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")
+ mntpt=$(eval echo "\$$var")
if ! in_mtab "$mntpt" && ! is_mounted "$mntpt"
then
check_boolean "$VERBOSE_MOUNT" && \
@@ -110,7 +110,7 @@ do_mount()
fi
i=$((i + 1))
- var=$(eval echo FSTAB_$i)
+ var=$(eval echo "FSTAB_$i")
done
check_boolean "$VERBOSE_MOUNT" && zfs_log_end_msg 0
@@ -133,11 +133,11 @@ do_unmount()
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="FSTAB_0"
+ while [ -n "$(eval echo "\$$var")" ]
do
- mntpt=$(eval echo "$""$var")
- dev=$(eval echo "$"FSTAB_dev_$i)
+ mntpt=$(eval echo "\$$var")
+ dev=$(eval echo "\$FSTAB_dev_$i")
if in_mtab "$mntpt"
then
check_boolean "$VERBOSE_MOUNT" && \
@@ -146,15 +146,15 @@ do_unmount()
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="FSTAB_0"
+ while [ -n "$(eval echo "\$$var")" ]
do
- mntpt=$(eval echo "$""$var")
+ mntpt=$(eval echo "\$$var")
if in_mtab "$mntpt"; then
check_boolean "$VERBOSE_MOUNT" && \
zfs_log_progress_msg "$mntpt "
@@ -162,7 +162,7 @@ do_unmount()
fi
i=$((i + 1))
- var=$(eval echo FSTAB_$i)
+ var=$(eval echo "FSTAB_$i")
done
check_boolean "$VERBOSE_MOUNT" && zfs_log_end_msg 0
diff --git a/etc/init.d/zfs-zed.in b/etc/init.d/zfs-zed.in
index e5550e500..e5256cbc6 100755
--- a/etc/init.d/zfs-zed.in
+++ b/etc/init.d/zfs-zed.in
@@ -30,6 +30,7 @@
ZED_NAME="zed"
ZED_PIDFILE="@runstatedir@/$ZED_NAME.pid"
+# shellcheck disable=SC2034
extra_started_commands="reload"
# Exit if the package is not installed