From babc015294b28d7d65babca6c8b6af700d598892 Mon Sep 17 00:00:00 2001 From: Kris Lamoureux Date: Mon, 28 Nov 2022 00:53:09 -0500 Subject: [PATCH] Add disk_by_id function --- debianzfs.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/debianzfs.sh b/debianzfs.sh index d29ced3..5089c76 100755 --- a/debianzfs.sh +++ b/debianzfs.sh @@ -103,6 +103,16 @@ function mirror_grub () { mount /boot/efi } +function disk_by_id () { + disk_check "$1" + OUTPUT=$(find /dev/disk/by-id -lname "../../$(basename "$1")" | tail -n1) + if [ -z "$OUTPUT" ]; then + echo "ERROR: No disk by-id label found for: $1" + exit 1 + fi + echo "$OUTPUT" +} + ################ ### Settings ### ################ @@ -334,15 +344,13 @@ echo -e "DISK=${DISK}\nROOTPW=${ROOTPW}" > "$ZFSROOT/var/tmp/zfsenv" if [ -n "$MIRROR" ]; then cp "$0" "$ZFSROOT/usr/local/bin/debianzfs" chmod u+x "$ZFSROOT/usr/local/bin/debianzfs" - DDIF=$(find /dev/disk/by-id -lname ../../"$(basename "$DISK")" | tail -n1) - DDOF=$(find /dev/disk/by-id -lname ../../"$(basename "$MIRROR")" | tail -n1) HELPER_SCRIPT="/root/MIRROR_GRUB_POSTINSTALL.sh" cat <<-GRUBMIRROR > "${ZFSROOT}${HELPER_SCRIPT}" #!/bin/bash # Post-install GRUB mirror helper script /usr/local/bin/debianzfs \ - -gm $DDOF \ - $DDIF + -gm $(disk_by_id "$MIRROR") \ + $(disk_by_id "$DISK") GRUBMIRROR fi