#!/bin/bash set -e DEVICE=/dev/sdb MAPPED=backup if [ "$EUID" -ne 0 ]; then echo "Need to be root" >&2 exit 1 fi case "$1" in mount) cryptsetup open "$DEVICE" "$MAPPED" mount /dev/mapper/"$MAPPED" /mnt ;; umount) umount /mnt cryptsetup close "$MAPPED" ;; *) echo "Unknown argument $1" exit 1 ;; esac