diff options
Diffstat (limited to 'crypt-disk')
-rwxr-xr-x | crypt-disk | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/crypt-disk b/crypt-disk new file mode 100755 index 0000000..482fbd8 --- /dev/null +++ b/crypt-disk @@ -0,0 +1,47 @@ +#!/bin/zsh + +. $(dirname $0:A)/func.zsh +check_root + +if [ "$#" -ne 1 ]; then + echo "missing args: crypt-disk <mount|umount>" + exit +fi +CMD=$1 + +dock_dev="/dev/disk/by-id/ata-HGST_HTS721010A9E630_JR10046P3Z3SMN-part1" +dock1_dev="/dev/disk/by-id/ata-HGST_HTS721010A9E630_JR10046P3ZMMJN-part1" +remote_backup_dev="ata-WDC_WD1002FAEX-00Y9A0_WD-WCAW32441082-part1" + +DEVICE="" +NAME="" + +if [[ -e $dock_dev ]]; then + DEVICE=$dock_dev + NAME="dock" +elif [[ -e $dock1_dev ]]; then + DEVICE=$dock1_dev + NAME="dock1" +elif [[ -e $remote_backup ]]; then + DEVICE=$remote_backup_dev + NAME="remote_backup" +else + echo "No known encrypted disk found." + exit +fi + +echo "disk: $NAME" + +if [[ "$CMD" == "mount" ]]; then + echo " mount" + cryptsetup luksOpen $DEVICE $NAME + mount /dev/mapper/$NAME +elif [[ "$CMD" == "umount" ]]; then + echo " umount" + umount /media/$NAME + cryptsetup luksClose /dev/mapper/$NAME +else + echo "Can't '$CMD' $NAME." + exit +fi + |