From e890e493a849f8966e8ab34b4a478bce3282ec74 Mon Sep 17 00:00:00 2001 From: Eric Hameleers Date: Sun, 29 Nov 2015 16:10:02 +0100 Subject: Make the 'iso2usb.sh' script sudo-friendly. --- iso2usb.sh | 54 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'iso2usb.sh') diff --git a/iso2usb.sh b/iso2usb.sh index 439d9f5..fe06678 100644 --- a/iso2usb.sh +++ b/iso2usb.sh @@ -1,5 +1,5 @@ #!/bin/bash -# $Id: iso2usb.sh,v 1.5 2015/11/22 22:53:01 root Exp root $ +# $Id: iso2usb.sh,v 1.6 2015/11/29 15:07:35 root Exp root $ # # Copyright 2015 Eric Hameleers, Eindhoven, NL # All rights reserved. @@ -46,9 +46,9 @@ cleanup() { # During cleanup, do not abort due to non-zero exit code: set +e sync - [ -n "${EFIMNT}" ] && ( umount -f ${EFIMNT} ; rmdir $EFIMNT ) - [ -n "${ISOMNT}" ] && ( umount -f ${ISOMNT} ; rmdir $ISOMNT ) - [ -n "${USBMNT}" ] && ( umount -f ${USBMNT} ; rmdir $USBMNT ) + [ -n "${EFIMNT}" ] && ( /sbin/umount -f ${EFIMNT} 2>/dev/null; rmdir $EFIMNT ) + [ -n "${ISOMNT}" ] && ( /sbin/umount -f ${ISOMNT} 2>/dev/null; rmdir $ISOMNT ) + [ -n "${USBMNT}" ] && ( /sbin/umount -f ${USBMNT} 2>/dev/null; rmdir $USBMNT ) [ -n "${IMGDIR}" ] && ( rm -rf $IMGDIR ) set -e } @@ -147,13 +147,13 @@ fi # Are all the required not-so-common add-on tools present? PROG_MISSING="" -for PROGN in cpio extlinux fdisk mkdosfs sgdisk ; do - if ! which $PROGN 1>/dev/null 2>/dev/null ; then +for PROGN in blkid cpio extlinux fdisk gdisk mkdosfs sgdisk ; do + if ! PATH="/sbin:$PATH" which $PROGN 1>/dev/null 2>/dev/null ; then PROG_MISSING="${PROG_MISSING}-- $PROGN\n" fi done if [ ! -z "$PROG_MISSING" ] ; then - echo "-- Required program(s) not found in PATH!" + echo "-- Required program(s) not found in root's PATH!" echo -e ${PROG_MISSING} echo "-- Exiting." exit 1 @@ -169,7 +169,7 @@ cat </dev/null | while read LINE ; do echo "# $LINE" ; done if [ $UNATTENDED -eq 0 ]; then cat </dev/null |grep EFI |tr -s ' ' | cut -d' ' -f 2) if [ -n "$EFIOFFSET" ]; then # Mount the EFI partition so we can retrieve the EFI bootloader: - mount -o loop,offset=$((512*$EFIOFFSET)) ${SLISO} ${EFIMNT} + /sbin/mount -o loop,offset=$((512*$EFIOFFSET)) ${SLISO} ${EFIMNT} if [ ! -f ${EFIMNT}/EFI/BOOT/bootx64.efi ]; then echo "-- Note: UEFI boot file 'bootx64.efi' not found on ISO." echo "-- UEFI boot will not be supported" @@ -251,17 +251,17 @@ else fi # Mount the EFI partition and copy the EFI boot image to it: -mount -t vfat -o shortname=mixed ${TARGET}2 ${USBMNT} +/sbin/mount -t vfat -o shortname=mixed ${TARGET}2 ${USBMNT} mkdir -p ${USBMNT}/EFI/BOOT cp ${EFIMNT}/EFI/BOOT/bootx64.efi ${USBMNT}/EFI/BOOT -umount ${USBMNT} -umount ${EFIMNT} +/sbin/umount ${USBMNT} +/sbin/umount ${EFIMNT} # Mount the Linux partition: -mount -t auto ${TARGET}3 ${USBMNT} +/sbin/mount -t auto ${TARGET}3 ${USBMNT} # Loop-mount the ISO (or 1st partition if this is a hybrid ISO): -mount -o loop ${SLISO} ${ISOMNT} +/sbin/mount -o loop ${SLISO} ${ISOMNT} # Copy the ISO content into the USB Linux partition: echo "--- Copying files from ISO to USB... takes some time." @@ -295,7 +295,7 @@ echo "--- Making the USB drive '$TARGET' bootable using extlinux..." mv ${USBMNT}/boot/syslinux ${USBMNT}/boot/extlinux mv ${USBMNT}/boot/extlinux/isolinux.cfg ${USBMNT}/boot/extlinux/extlinux.conf rm ${USBMNT}/boot/extlinux/isolinux.* -extlinux --install ${USBMNT}/boot/extlinux +/sbin/extlinux --install ${USBMNT}/boot/extlinux # Unmount/remove stuff: cleanup -- cgit v1.2.3