2019-03-26 09:55:52 +00:00
|
|
|
#!/usr/bin/env bash
|
2016-10-07 21:46:23 +01:00
|
|
|
|
|
|
|
set -e
|
2020-02-22 15:02:48 +00:00
|
|
|
set -o pipefail
|
|
|
|
|
2017-11-01 15:11:51 +00:00
|
|
|
VERACRYPT="veracrypt"
|
|
|
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
|
|
VERACRYPT="/Applications/VeraCrypt.app/Contents/MacOS/VeraCrypt"
|
|
|
|
fi
|
2018-01-10 11:08:12 +00:00
|
|
|
|
|
|
|
MOUNT_TARGET=$2
|
|
|
|
if [[ -z "$MOUNT_TARGET" ]]; then
|
2018-02-02 20:33:26 +00:00
|
|
|
MOUNT_TARGET=$HOME/.vault
|
2018-01-10 11:08:12 +00:00
|
|
|
fi
|
2020-02-01 15:38:30 +00:00
|
|
|
|
|
|
|
sudo chown $USER "$MOUNT_TARGET"
|
2018-01-10 11:08:12 +00:00
|
|
|
mkdir -p "$MOUNT_TARGET"
|
|
|
|
|
|
|
|
MOUNT_SOURCE=$1
|
|
|
|
if [[ -z "$MOUNT_SOURCE" ]]; then
|
2018-02-02 20:33:26 +00:00
|
|
|
MOUNT_SOURCE="$HOME/vaults/vault.vera"
|
2018-01-10 11:08:12 +00:00
|
|
|
fi
|
|
|
|
|
2020-02-22 15:02:48 +00:00
|
|
|
chmod a+x "$MOUNT_SOURCE"
|
|
|
|
|
2018-01-10 11:08:12 +00:00
|
|
|
if [[ -z "$VAULT_PASSWORD" ]]; then
|
2020-02-01 15:38:30 +00:00
|
|
|
echo "interactive mount"
|
2018-01-10 11:08:12 +00:00
|
|
|
$VERACRYPT -t --mount "$MOUNT_SOURCE" "$MOUNT_TARGET"
|
|
|
|
else
|
2020-02-01 15:38:30 +00:00
|
|
|
echo "non-interactive mount of '$MOUNT_SOURCE' to '$MOUNT_TARGET'"
|
|
|
|
sudo $VERACRYPT -t --non-interactive -p $VAULT_PASSWORD --mount "$MOUNT_SOURCE" "$MOUNT_TARGET"
|
2018-01-10 11:08:12 +00:00
|
|
|
fi
|
2020-02-22 15:02:48 +00:00
|
|
|
echo "mounted"
|
2018-01-10 11:08:12 +00:00
|
|
|
sudo chown $USER "$MOUNT_TARGET"
|
2020-02-22 15:02:48 +00:00
|
|
|
echo "chowned"
|
2018-01-10 11:08:12 +00:00
|
|
|
|
|
|
|
echo "$MOUNT_SOURCE -> $MOUNT_TARGET"
|
2018-10-15 15:55:13 +01:00
|
|
|
|
2020-02-22 15:02:48 +00:00
|
|
|
"$MOUNT_TARGET/install"
|