#!/bin/bash
#
# adds another LUKS key to the backup target for eb-*
# which usually was previously prepared with eb-format

STICKPART=$(cat /proc/partitions |egrep " sd[a-z]1?$" |awk '{print $4}' |tail -1)

mount |grep sdb && exit 1

cryptsetup -v luksFormat -c aes-xts-plain64 -s 512 -h sha512 --verify-passphrase /dev/sdb1 || exit 2

cryptsetup -v luksOpen /dev/sdb1 eb_crypted || exit 3

mkfs.ext4 /dev/mapper/eb_crypted || exit 4

mount -v /dev/mapper/eb_crypted /media/eb || exit 5

mkdir -v /media/eb/bs || exit 6

