fix(script): Differentiate between device path with and without /dev prefix

This commit is contained in:
hygienic-books 2023-10-26 03:23:47 +02:00
parent 31c415e93f
commit ad85e5b2d2

View File

@ -15,12 +15,15 @@ if [[ "$(<<<"${boot_fs}" wc -l)" -gt '1' ]]; then
exit 1
fi
boot_disk="$(lsblk --output 'NAME' --json --tree | jq --raw-output '.[][] | select(.children | length > 0) | select(.children[].name=="'"${boot_fs}"'") | .name')"
boot_fs_name="$(basename "${boot_fs}")"
boot_disk="$(lsblk --output 'NAME' --json --tree | jq --raw-output '.[][] | select(.children | length > 0) | select(.children[].name=="'"${boot_fs_name}"'") | .name')"
if [[ ! "${boot_disk}" ]]; then
# There's no parent drive over "${boot_fs}" meaning "${boot_fs}" itself
# already is the parent. This is a file system on a drive and not on a
# partition.
boot_disk="${boot_fs}"
else
boot_disk='/dev/'"${boot_disk}"
fi
find "${boot_dir}" -type f -iname '*.c32' -delete