aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/bin/pny
blob: f8da92cf445d2c1244c63b2defc273023f5d55f2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/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