From: Harald Hoyer Date: Fri, 26 Mar 2021 09:29:21 +0000 (+0100) Subject: fix(livenet): shellcheck for modules.d/90livenet X-Git-Tag: 054~237 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0315e16955a24182d1b83f1db165dc6b4eea3c8c;p=thirdparty%2Fdracut.git fix(livenet): shellcheck for modules.d/90livenet --- diff --git a/modules.d/90livenet/.shchkdir b/modules.d/90livenet/.shchkdir new file mode 100644 index 000000000..e69de29bb diff --git a/modules.d/90livenet/fetch-liveupdate.sh b/modules.d/90livenet/fetch-liveupdate.sh index 700e38735..32d8cfed0 100755 --- a/modules.d/90livenet/fetch-liveupdate.sh +++ b/modules.d/90livenet/fetch-liveupdate.sh @@ -10,22 +10,22 @@ command -v getarg > /dev/null || . /lib/dracut-lib.sh command -v fetch_url > /dev/null || . /lib/url-lib.sh command -v unpack_img > /dev/null || . /lib/img-lib.sh -read url < /tmp/liveupdates.info +read -r url < /tmp/liveupdates.info info "fetching live updates from $url" -fetch_url "$url" /tmp/updates.img -if [ $? != 0 ]; then +if ! fetch_url "$url" /tmp/updates.img; then warn "failed to fetch update image!" warn "url: $url" return 1 fi -unpack_img /tmp/updates.img /updates.tmp.$$ -if [ $? != 0 ]; then +if ! unpack_img /tmp/updates.img /updates.tmp.$$; then warn "failed to unpack update image!" warn "url: $url" return 1 fi + copytree /updates.tmp.$$ /updates + mv /tmp/liveupdates.info /tmp/liveupdates.done diff --git a/modules.d/90livenet/livenetroot.sh b/modules.d/90livenet/livenetroot.sh index 929c88128..92ad805be 100755 --- a/modules.d/90livenet/livenetroot.sh +++ b/modules.d/90livenet/livenetroot.sh @@ -19,34 +19,35 @@ info "fetching $liveurl" imgfile= #retry until the imgfile is populated with data or the max retries i=1 -while [ "$i" -le $RETRIES ]; do +while [ "$i" -le "$RETRIES" ]; do imgfile=$(fetch_url "$liveurl") + # shellcheck disable=SC2181 if [ $? != 0 ]; then warn "failed to download live image: error $?" imgfile= fi - if [ ! -z "$imgfile" -a -s "$imgfile" ]; then + if [ -n "$imgfile" -a -s "$imgfile" ]; then break else - if [ $i -ge $RETRIES ]; then + if [ $i -ge "$RETRIES" ]; then warn "failed to download live image after $i attempts." exit 1 fi - sleep $SLEEP + sleep "$SLEEP" fi i=$((i + 1)) done > /tmp/livenet.downloaded # TODO: couldn't dmsquash-live-root handle this? -if [ ${imgfile##*.} = "iso" ]; then +if [ "${imgfile##*.}" = "iso" ]; then root=$(losetup -f) - losetup $root $imgfile + losetup "$root" "$imgfile" else root=$imgfile fi -exec /sbin/dmsquash-live-root $root +exec /sbin/dmsquash-live-root "$root" diff --git a/modules.d/90livenet/module-setup.sh b/modules.d/90livenet/module-setup.sh index 11738b8f4..eae7f2a97 100755 --- a/modules.d/90livenet/module-setup.sh +++ b/modules.d/90livenet/module-setup.sh @@ -18,7 +18,7 @@ install() { inst_hook initqueue/online 95 "$moddir/fetch-liveupdate.sh" inst_script "$moddir/livenetroot.sh" "/sbin/livenetroot" if dracut_module_included "systemd-initrd"; then - inst_script "$moddir/livenet-generator.sh" $systemdutildir/system-generators/dracut-livenet-generator + inst_script "$moddir/livenet-generator.sh" "$systemdutildir"/system-generators/dracut-livenet-generator fi dracut_need_initqueue } diff --git a/modules.d/90livenet/parse-livenet.sh b/modules.d/90livenet/parse-livenet.sh index b3c0e1730..e59fa51a1 100755 --- a/modules.d/90livenet/parse-livenet.sh +++ b/modules.d/90livenet/parse-livenet.sh @@ -14,7 +14,7 @@ if [ -n "$updates" ]; then fi echo "$updates" > /tmp/liveupdates.info echo '[ -e /tmp/liveupdates.done ]' > \ - $hookdir/initqueue/finished/liveupdates.sh + "$hookdir"/initqueue/finished/liveupdates.sh fi str_starts "$root" "live:" && liveurl="$root" @@ -26,6 +26,7 @@ if get_url_handler "$liveurl" > /dev/null; then info "livenet: root image at $liveurl" netroot="livenet:$liveurl" root="livenet" # quiet complaints from init + # shellcheck disable=SC2034 rootok=1 wait_for_dev -n /dev/root else