#!/bin/bash if [[ $1 == "mount" ]]; then DEVICE=`dmesg | tail | grep 'Attached SCSI' | sed -n 's/.*: \[\(sd[a-z]\)\] Attac.*/\1/p'` if [[ $DEVICE == "" ]]; then echo "Error finding device" exit 1 fi echo "Mounting /dev/${DEVICE}1" sudo cryptsetup luksOpen /dev/${DEVICE}1 usbkey sudo mount -o user,exec /dev/mapper/usbkey /home/jason/sdb elif [[ $1 == "unmount" ]]; then echo "Unmounting /dev/mapper/usbkey" sudo umount /dev/mapper/usbkey sudo cryptsetup luksClose /dev/mapper/usbkey else echo "mount or unmount?" fi