X-Git-Url: https://git.grml.org/?p=grml2usb.git;a=blobdiff_plain;f=grml2usb;h=44de706dc71a310c8454b3a15a02e159f030339f;hp=1a69cb4fa8b06f0bfaa226367f817dea47ae549f;hb=bdbc9e12407fbd6e617494ea290697b46296d93f;hpb=cfd0cbc35a2f042d8de283e3c78c4baa7bc49454 diff --git a/grml2usb b/grml2usb index 1a69cb4..44de706 100755 --- a/grml2usb +++ b/grml2usb @@ -4,7 +4,7 @@ # Authors: grml-team (grml.org), (c) Michael Prokop # Bug-Reports: see http://grml.org/bugs/ # License: This file is licensed under the GPL v2. -# Latest change: Mit Okt 04 22:52:03 CEST 2006 [mika] +# Latest change: Fre Mär 16 16:04:18 CET 2007 [mika] ################################################################################ # colors {{{ @@ -24,13 +24,13 @@ echo 1>&2 "${RED}Error: syslinux is not available. Please install it before running this script.${NORMAL}" ; exit 2 fi - if [ "$UID" != 0 ]; then + if [ "$(id -u)" != 0 ]; then echo 1>&2 "${RED}Error: please run this script with uid 0 (root).${NORMAL}" ; exit 1 fi # }}} # set variables {{{ - if [[ $DEBUG -gt 0 ]]; then + if [ -n "$DEBUG" ]; then # set -x debugit(){ echo $* @@ -41,7 +41,7 @@ } fi - if [ "$1" == "uninstall" ] ; then + if [ "$1" = "uninstall" ] ; then UNINSTALL=1 fi @@ -49,7 +49,7 @@ LANGUAGE='C' LC_ALL='C' PROGRAMNAME=${0##*/} - VERSION='0.6' + VERSION='0.7.4' ISO="$1" DEVICE="$2" [ -n "$TMPMNT" ] || TMPMNT='/mnt/test' @@ -62,7 +62,7 @@ bailout(){ echo "Exiting - umounting /mnt/test and $DEVICE" umount /mnt/test 2>/dev/null umount $DEVICE 2>/dev/null - exit 1 + exit 2 } usage() @@ -82,6 +82,9 @@ Usage: Usage example - install grml-small to usb-device on /mnt/external1: $PROGRAMNAME grml_small_0.2.iso /mnt/external1 +Usage example - using grml2usb on a live grml system: + $PROGRAMNAME /cdrom /mnt/external1 + Usage example - delete grml-installation from /mnt/external1: $PROGRAMNAME uninstall /mnt/external1 @@ -134,13 +137,19 @@ mount_device(){ mount_iso(){ echo -n "Mounting ${ISO} to ${TMPMNT}: " - debugit "debug: mount -o loop ${ISO} ${TMPMNT}" - if mount -o loop ${ISO} ${TMPMNT} ; then + local mount_opts_="-o loop" + if [ -d $ISO ]; then + mount_opts_="--bind" + elif [ -b $ISO ]; then + mount_opts_="" + fi + debugit "debug: mount $mount_opts_ ${ISO} ${TMPMNT}" + if mount $mount_opts_ "${ISO}" ${TMPMNT} ; then echo "${WHITE}done${NORMAL}" else echo 1>&2 "${RED}Problem? You got an error saying 'mount: could not find any free loop device'? Possible solution: losetup -d /dev/loop/0${NORMAL}" - exit 1 + exit 3 fi } @@ -183,8 +192,8 @@ Try to call it manually via 'syslinux /dev/sda1' if you installed grml to /dev/s # main program {{{ trap bailout 1 2 3 15 -if [[ $# != 2 ]]; then - usage ; exit 1 +if [ "$#" != 2 ]; then + usage ; exit 4 fi if [ -n "$UNINSTALL" ] ; then