Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archiso/initcpio/hooks/archiso_pxe_nbd
diff options
context:
space:
mode:
authorDavid Runge <dvzrv@archlinux.org>2020-07-11 18:13:20 +0200
committerDavid Runge <dvzrv@archlinux.org>2020-07-11 20:58:01 +0200
commite2032db4e74c66d3f8bcba97497ccb5fff88df4b (patch)
tree6b1fa957e952916ed34ff101cd277c11c3a9437b /archiso/initcpio/hooks/archiso_pxe_nbd
parent550aca712432c6708fc48db5e9a8aaba9ef1e0c1 (diff)
Adding linting for initcpio scripts
archiso/initcpio/install/*: Setting bash shebang for all scripts and making them comform with shellcheck. archiso/initcpio/{hooks,script}/*: Setting ash shebang for all scripts and making them comform with shellcheck (for dash, as shellcheck has no ash specific ruleset). Essentially the ash based scripts should be POSIX compliant as much as possible to have an easier time writing, debugging and maintaining them. Ensuring that variables are not treated as options and introducing variable quoting. .gitlab-ci.yml: Integrating shellcheck for initcpio scripts. Closes #32
Diffstat (limited to 'archiso/initcpio/hooks/archiso_pxe_nbd')
-rw-r--r--archiso/initcpio/hooks/archiso_pxe_nbd27
1 files changed, 15 insertions, 12 deletions
diff --git a/archiso/initcpio/hooks/archiso_pxe_nbd b/archiso/initcpio/hooks/archiso_pxe_nbd
index 4fb7fa5..ce93080 100644
--- a/archiso/initcpio/hooks/archiso_pxe_nbd
+++ b/archiso/initcpio/hooks/archiso_pxe_nbd
@@ -1,19 +1,20 @@
-# vim: set ft=sh:
+#!/bin/ash
run_earlyhook() {
- if [[ -n "${ip}" && -n "${archiso_nbd_srv}" ]]; then
+ # shellcheck disable=SC2154 # defined via initcpio's parse_cmdline()
+ if [ -n "${ip}" ] && [ -n "${archiso_nbd_srv}" ]; then
# Module autoloading like with loop devices does not work, doing manually...
modprobe nbd 2> /dev/null
fi
}
run_hook() {
- if [[ -n "${ip}" && -n "${archiso_nbd_srv}" ]]; then
+ if [ -n "${ip}" ] && [ -n "${archiso_nbd_srv}" ]; then
- archiso_nbd_srv=$(eval echo ${archiso_nbd_srv})
- [[ -z "${archiso_nbd_name}" ]] && archiso_nbd_name="archiso"
+ archiso_nbd_srv=$(eval echo "${archiso_nbd_srv}")
+ [ -z "${archiso_nbd_name}" ] && archiso_nbd_name="archiso"
- mount_handler="archiso_pxe_nbd_mount_handler"
+ export mount_handler="archiso_pxe_nbd_mount_handler"
fi
}
@@ -29,19 +30,21 @@ archiso_pxe_nbd_mount_handler () {
done
msg ":: Setup NBD from ${archiso_nbd_srv} at /dev/nbd0"
- if [[ "${copytoram}" != "n" ]]; then
- nbd-client ${archiso_nbd_srv} -N ${archiso_nbd_name} /dev/nbd0
+ if [ "${copytoram}" != "n" ]; then
+ nbd-client "${archiso_nbd_srv}" -N "${archiso_nbd_name}" /dev/nbd0
copytoram="y"
else
- nbd-client ${archiso_nbd_srv} -N ${archiso_nbd_name} -systemd-mark -persist /dev/nbd0
+ nbd-client "${archiso_nbd_srv}" -N "${archiso_nbd_name}" -systemd-mark -persist /dev/nbd0
fi
- archisodevice=/dev/nbd0
+ export archisodevice=/dev/nbd0
- archiso_mount_handler ${newroot}
+ archiso_mount_handler "${newroot}"
- if [[ "${copytoram}" == "y" ]]; then
+ if [ "${copytoram}" = "y" ]; then
msg ":: Disconnect NBD from ${archiso_nbd_srv} at /dev/nbd0"
nbd-client -d /dev/nbd0
fi
}
+
+# vim: set ft=sh: