Skip to content

Instantly share code, notes, and snippets.

@cofi89
Created July 25, 2015 01:28
Show Gist options
  • Save cofi89/3f98654a410d8e0d3726 to your computer and use it in GitHub Desktop.
Save cofi89/3f98654a410d8e0d3726 to your computer and use it in GitHub Desktop.
TRIOS Image writer - Detect and list USB devices...
# usb_detection
USB_DET=(`ls -l /dev/disk/by-path/*usb* | grep -v "part" | awk '{print $NF}' | awk -F "/" '{print $NF}' | sort`)
for usb in "${USB_DET[@]}"; do
if [ ! -b "/dev/$usb" ];
then
USB_DET=(${USB_DET[@]/$usb})
fi
done
USB_REST=( ${USB_DET[@]:1:9} )
(snip)
drive_select() {
USB=$(zenity --entry --ok-label=Continue --cancel-label=Quit \
--title="Select the drive to write to:" --entry-text=/dev/ \
--text="$(echo "Selected image is:\n$ISO\n" \
&& echo "Find the target USB drive on the list bellow,
then enter it's node in the \"/dev/sdX\" format.\n" \
&& lsblk -i -l -d -o NAME,MODEL,VENDOR,SIZE,RM && echo "Detected as USB:\n" && lsblk /dev/${USB_DET[@]:0:1} -d -o NAME,MODEL,VENDOR,SIZE; if [ "${#USB_DET[@]}" -gt "1" ] ; then for usb in "${USB_REST[@]}" ; do lsblk /dev/$usb -n -d -o NAME,MODEL,VENDOR,SIZE;done ; fi )")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment