~cyplo/dotfiles

ref: 83ddcc09dc68389b129d598722eca9e90a6dff33 dotfiles/tools/mount-vault -rwxr-xr-x 901 bytes
83ddcc09 — Cyryl PÅ‚otnicki remove broken i3 msg call 29 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env bash

set -e
set -o pipefail

VERACRYPT="veracrypt"
if [[ "$OSTYPE" == "darwin"* ]]; then
  VERACRYPT="/Applications/VeraCrypt.app/Contents/MacOS/VeraCrypt"
fi

MOUNT_TARGET=$2
if [[ -z "$MOUNT_TARGET" ]]; then
  MOUNT_TARGET=$HOME/.vault
fi

sudo chown $USER "$MOUNT_TARGET"
mkdir -p "$MOUNT_TARGET"

MOUNT_SOURCE=$1
if [[ -z "$MOUNT_SOURCE" ]]; then
  MOUNT_SOURCE="$HOME/vaults/vault.vera"
fi

chmod a+x "$MOUNT_SOURCE"

if [[ -z "$VAULT_PASSWORD" ]]; then
  echo "interactive mount"
  $VERACRYPT -t --mount "$MOUNT_SOURCE" "$MOUNT_TARGET"
else
  echo "non-interactive mount of '$MOUNT_SOURCE' to '$MOUNT_TARGET'"
  sudo $VERACRYPT -t --non-interactive -p $VAULT_PASSWORD --mount "$MOUNT_SOURCE" "$MOUNT_TARGET"
fi
echo "mounted"
sudo chown $USER "$MOUNT_TARGET"
echo "chowned"

echo "$MOUNT_SOURCE -> $MOUNT_TARGET"

if [[ -z $NO_INSTALL_VAULT ]]; then
  "$MOUNT_TARGET/install"
fi