From 14a88e4ee227c59246f8fea29e2ea38ad6303877 Mon Sep 17 00:00:00 2001 From: Eric Hameleers Date: Tue, 19 Nov 2019 21:37:05 +0100 Subject: iso2usb.sh: fix logic for finding and writing gptmbr.bin to the device --- iso2usb.sh | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'iso2usb.sh') diff --git a/iso2usb.sh b/iso2usb.sh index e8c7014..21248cb 100644 --- a/iso2usb.sh +++ b/iso2usb.sh @@ -77,12 +77,15 @@ REQTOOLS="blkid cpio extlinux fdisk gdisk isoinfo lsblk mkdosfs sgdisk syslinux" # Path to syslinux files: if [ -d /usr/share/syslinux ]; then SYSLXLOC="/usr/share/syslinux" + GPTMBRBIN=$(find $SYSLXLOC -name gptmbr.bin) elif [ -d /usr/lib/syslinux ]; then SYSLXLOC="/usr/lib/syslinux" + GPTMBRBIN=$(find $SYSLXLOC -name gptmbr.bin) else # Should not happen... in this case we use what we have on the ISO # and hope for the best: - SYSLXLOC="" + SYSLXLOC="/" + GPTMBRBIN="gptmbr.bin" fi # Initialize more variables: @@ -845,23 +848,25 @@ if [ $EFIBOOT -eq 1 ]; then sync fi -# No longer needed: +# No longer needed; umount the USB partitions so we can write a new MBR: if mount |grep -qw ${USBMNT} ; then umount ${USBMNT} ; fi if mount |grep -qw ${US2MNT} ; then umount ${US2MNT} ; fi -# Unmount/remove stuff: -cleanup - # Install a GPT compatible MBR record: -if [ -f ${SYSLXLOC}/gptmbr.bin ]; then - cat ${SYSLXLOC}/gptmbr.bin > ${TARGET} -elif [ -f ${USBMNT}/boot/extlinux/gptmbr.bin ]; then - cat ${USBMNT}/boot/extlinux/gptmbr.bin > ${TARGET} +if [ -n "${GPTMBRBIN}" ]; then + if [ -f ${GPTMBRBIN} ]; then + cat ${GPTMBRBIN} > ${TARGET} + fi +elif [ -f ${ISOMNT}/boot/syslinux/gptmbr.bin ]; then + cat ${ISOMNT}/boot/syslinux/gptmbr.bin > ${TARGET} else echo "*** Failed to make USB device bootable - 'gptmbr.bin' not found!" cleanup exit 1 fi +# Unmount/remove stuff: +cleanup + # THE END -- cgit v1.2.3