#!/bin/zsh . $(dirname $0:A)/func.zsh check_root if [ "$#" -ne 1 ]; then echo "missing args: crypt-disk " 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="/dev/disk/by-id/scsi-SATA_WDC_WD1002FAEX-_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_dev ]]; 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