diff options
-rwxr-xr-x | crypt-disk | 47 | ||||
-rwxr-xr-x | crypt-make | 17 | ||||
-rwxr-xr-x | crypt-mount | 16 | ||||
-rwxr-xr-x | crypt-umount | 15 |
4 files changed, 47 insertions, 48 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 + diff --git a/crypt-make b/crypt-make deleted file mode 100755 index 65cb4bf..0000000 --- a/crypt-make +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/zsh - -. $(dirname $0:A)/func.zsh -check_root - -if [ "$#" -ne 2 ]; then - echo "missing args: make_crypt </dev/device> <name>" - exit -fi - -DEVICE=$1 -NAME=$2 - -cryptsetup -c aes-xts-plain64 -s 256 -h sha256 -i 1000 --use-random -y luksFormat $DEVICE -cryptsetup luksOpen $DEVICE $NAME -mkfs.xfs -L $NAME /dev/mapper/$NAME - diff --git a/crypt-mount b/crypt-mount deleted file mode 100755 index 9faa47f..0000000 --- a/crypt-mount +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/zsh - -. $(dirname $0:A)/func.zsh -check_root - -if [ "$#" -ne 2 ]; then - echo "missing args: mount_crypt </dev/device> <name>" - exit -fi - -DEVICE=$1 -NAME=$2 - -cryptsetup luksOpen $DEVICE $NAME -mount /dev/mapper/$NAME - diff --git a/crypt-umount b/crypt-umount deleted file mode 100755 index 9b99e10..0000000 --- a/crypt-umount +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/zsh - -. $(dirname $0:A)/func.zsh -check_root - -if [ "$#" -ne 1 ]; then - echo "missing args: umount_crypt <name>" - exit -fi - -NAME=$1 - -umount /media/$NAME -cryptsetup luksClose /dev/mapper/$NAME - |