Skip to content

Instantly share code, notes, and snippets.

@yann2192
Last active September 5, 2020 18:04
Show Gist options
  • Save yann2192/768e2464049b1441507cbd60b002492f to your computer and use it in GitHub Desktop.
Save yann2192/768e2464049b1441507cbd60b002492f to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
DEVICE1=UUID="6319642d-a495-4505-8346-510a17ce587a"
DEVICE2=UUID="4908f36f-453d-4253-98c7-584200b0c17e"
RDEVICE=UUID="68493f2f-a2b4-4771-9193-487b0a221f23"
MOUNT_POINT="/mnt"
_mount() {
echo -n "LUKS key: "; read -s key; echo ""
cryptsetup luksOpen "$DEVICE1" ext1 < <(echo $key)
cryptsetup luksOpen "$DEVICE2" ext2 < <(echo $key)
mount /dev/mapper/ext1 "$MOUNT_POINT"
}
_umount() {
umount /dev/mapper/ext1
cryptsetup luksClose ext1
cryptsetup luksClose ext2
}
_mount_one() {
cryptsetup luksOpen "$DEVICE1" ext1
mount -r -odegraded /dev/mapper/ext1 "$MOUNT_POINT"
}
_umount_one() {
umount /dev/mapper/ext1
cryptsetup luksClose ext1
}
case "$1" in
mount) shift; _mount "$@" ;;
umount) shift; _umount "$@" ;;
mount_one) shift; _mount_one "$@" ;;
umount_one) shift; _umount_one "$@" ;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment