summaryrefslogtreecommitdiff
path: root/crypt-disk
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2016-04-27 12:19:55 +0200
committerPatrick Simianer <p@simianer.de>2016-04-27 12:19:55 +0200
commitf599f44fe1452350087509b4a26d2250f771a45e (patch)
treed624d3bbc6628db8bf90a0d061ed13d84e2c455b /crypt-disk
parent95b3e4bb744932ce4eac14bb350cc0455d15848a (diff)
better crypt script
Diffstat (limited to 'crypt-disk')
-rwxr-xr-xcrypt-disk47
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
+