From 9ea37872a5abdd7781c630bad6e6c73a85621f22 Mon Sep 17 00:00:00 2001 From: Maximilian Friedersdorff Date: Thu, 11 Jul 2019 16:17:47 +0100 Subject: [PATCH] Expect 2 arguments, os image and usb drive --- disk_creator.sh | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/disk_creator.sh b/disk_creator.sh index 4dd8217..4ee7b5f 100755 --- a/disk_creator.sh +++ b/disk_creator.sh @@ -1,10 +1,39 @@ #!/bin/bash +usage() { + echo "Usage:" + echo "disk_creator.sh OS_IMAGE USB_DRIVE" + echo + echo "Example:" + echo "disk_creator.sh ~/Downloads/xubuntu-18.04.2-desktop-amd64.iso /dev/sdd" + echo + echo "Create a live usb drive on the device '/dev/sdd' with the os found in" + echo "~/Downloads/xubuntu-18.04.2-desktop-amd64.iso" +} + +if [ $# -ne 2 ]; then + echo "ERROR: expected exactly 2 arguments" + usage + exit 1 +fi + +if [ ! -b $2 ]; then + echo "ERROR: $2 is not a block device" + usage + exit 1 +fi + +if [ ! -f $1 ]; then + echo "ERROR: $1 is not a regular file" + usage + exit 1 +fi + # The name of the USB drive you want to create -usb_drive="/dev/sdd" +usb_drive="$2" # The location of the linux distribution you want to use -os_image="/mnt/os_images/xubuntu-18.04.2-desktop-amd64.iso" +os_image="$1" # Removing leading directory/folder name image_name="${os_image##*/}" -- 2.44.0