vim, gitconfig, update.sh
[dotfiles_afify.git] / .scripts / create_bootable_usb.sh
blobac723099b9acf9a1a948411705a647cfff8e197c
1 #!/bin/sh
3 usb=$(\
4 lsblk --noheadings --raw -o NAME,SIZE,MOUNTPOINT |\
5 awk '$1~/sd[a-z]$/' |\
6 dmenu -i -p "Choose disk"|\
7 awk '{print $1}')
8 if [ ! "$usb" ]; then exit;fi
11 target="/mnt/4tb/os/"
12 if [ ! -d "$target" ]; then
13 echo "please select iso file"
14 target=$(echo '/home/hassan/' | dmenu -p 'enter full path')
15 # exit
18 [ -z "$target" ] && target="$(realpath .)"
19 prompt="$2"
20 while true; do
21 p="$prompt"
22 [ -z "$p" ] && p="$target"
23 sel="$(ls -1a "$target" | grep -v '^\.$' | dmenu -p "$p" -l 25)"
24 ec=$?
25 [ "$ec" -ne 0 ] && exit $ec
26 c="$(echo "$sel" | cut -b1)"
27 if [ "$c" = "/" ]; then
28 newt="$sel"
29 else
30 newt="$(realpath "${target}/${sel}")"
32 if [ -e "$newt" ]; then
33 target="$newt"
34 if [ ! -d "$target" ]; then
36 # Got the iso file
37 if dmenu -P -p "Warning Device will be erased | sudo " |\
38 sudo -S dd bs=4M\
39 if="$target" of="/dev/$usb"\
40 status=progress oflag=sync; then
41 notify-send "Bootable USB Created" "$usb"
42 else
43 notify-send -u critical\
44 "Error Creating Bootable USB" "$usb"
46 exit 0
50 done