From 139fd2894f5bd944b58ba4bd61375997c1eec8b2 Mon Sep 17 00:00:00 2001 From: yurisuki Date: Sun, 21 Apr 2019 14:45:05 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=98=B2=20Doctors=20hate=20him!=20This=20t?= =?UTF-8?q?rick=20will=20help=20you=20make=20a=20bootable=20drive!=20?= =?UTF-8?q?=F0=9F=98=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .scripts/tools/bootiso | 67 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100755 .scripts/tools/bootiso diff --git a/.scripts/tools/bootiso b/.scripts/tools/bootiso new file mode 100755 index 00000000..b6bef808 --- /dev/null +++ b/.scripts/tools/bootiso @@ -0,0 +1,67 @@ +#!/bin/bash +# This script will make a bootable +# USB/drive/SD, etc.. from given ISO. + +[ -z "$1" ] && echo "Usage: $0 " && exit + +if [ ! -f "$1" ] +then + echo "File $1 doesn't exist." + exit +fi + +echo "$1" > /tmp/image +image=$(cat /tmp/image) +prepare() { +for dev in $(ls /sys/block|grep -E '^([sv]|xv)d|mmcblk|nvme'); do +echo $dev +done + + +clear +lsblk |grep sd*|egrep -v "sr|├─|└" >/tmp/drives +awk '{print "/dev/" $0}' /tmp/drives >/tmp/newdrives + +drives=$(cat /tmp/newdrives) +} + +selection() { +echo -e "DRIVES\n======" +echo "$drives" + +echo -e "\n\nWhich one do you want to use? (/dev/sdb)" +read chosen +[ "$chosen" = "" ] && echo lol || check2 +} + +check2() { +if ls $chosen ; then + pressy +else + clear + echo "Drive $chosen doesn't exist." + selection +fi +} + +pressy() { +read -n1 -p "WARNING!! By pressing [y] your selected drive will be wiped (Press [n] to abort.)" sure +if [[ "$sure" = "y" ]] ; then + burn +elif [[ "$sure" = "n" ]] ; then + clear + echo "Aborting." + exit +else + pressy +fi +} + +burn() { +clear +sudo dd bs=4M if=$image of=$chosen status=progress oflag=sync +} + +check +prepare +selection