]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix(livenet): shellcheck for modules.d/90livenet
authorHarald Hoyer <harald@redhat.com>
Fri, 26 Mar 2021 09:29:21 +0000 (10:29 +0100)
committerHarald Hoyer <harald@hoyer.xyz>
Mon, 29 Mar 2021 08:50:51 +0000 (10:50 +0200)
modules.d/90livenet/.shchkdir [new file with mode: 0644]
modules.d/90livenet/fetch-liveupdate.sh
modules.d/90livenet/livenetroot.sh
modules.d/90livenet/module-setup.sh
modules.d/90livenet/parse-livenet.sh

diff --git a/modules.d/90livenet/.shchkdir b/modules.d/90livenet/.shchkdir
new file mode 100644 (file)
index 0000000..e69de29
index 700e38735a8f86e0b57d3fe4fcb9bc9e62b9e718..32d8cfed049b9df080a1cff2f0a1a318fac46cd5 100755 (executable)
@@ -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
index 929c881285b6661de2c03fabe98604afb9f9e247..92ad805bed28297a10efba5c4ca1393acec97ecc 100755 (executable)
@@ -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"
index 11738b8f44a6747fd650414cd5d628c75074852e..eae7f2a976a262e5aa54156c89158e0896200618 100755 (executable)
@@ -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
 }
index b3c0e1730ef30543839e33a3546f13a144df0081..e59fa51a1ab0560d1faa81e2c1b77668c2d52f82 100755 (executable)
@@ -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