]> git.friedersdorff.com Git - max/disk_creator.git/commitdiff
Expect 2 arguments, os image and usb drive
authorMaximilian Friedersdorff <max@friedersdorff.com>
Thu, 11 Jul 2019 15:17:47 +0000 (16:17 +0100)
committerMaximilian Friedersdorff <max@friedersdorff.com>
Thu, 11 Jul 2019 15:17:47 +0000 (16:17 +0100)
disk_creator.sh

index 4dd8217f3db1dc34377e6ff0235d7d6bd1fd266d..4ee7b5f7b1c1ff60094fb9a88c26c32d7eff47db 100755 (executable)
@@ -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##*/}"