Deescalate vault conflict (#155)

* Add arbitrary vault mount target

* Deescalate
This commit is contained in:
Cyryl Płotnicki 2018-01-10 11:08:12 +00:00 committed by GitHub
parent d12306e66b
commit db06e277b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 53 additions and 3 deletions

33
tools/deescalate.sh Executable file
View file

@ -0,0 +1,33 @@
#!/bin/bash
set -e
vaults_directory=~/vaults/
resolved_directory=$vaults_directory/resolved
target_vault="$vaults_directory/vault.vera"
target_mount="/tmp/target_vault"
conflicted_mount=/tmp/conflicted_vault
mkdir -p $resolved_directory
umount-vault
conflicted=`find "$vaults_directory" -maxdepth 1 -iname "*vault*sync-conflict*"`
read -s -p "password: " vault_password
echo
for current_vault in $conflicted; do
echo
VAULT_PASSWORD="$vault_password" mount-vault $current_vault "$conflicted_mount"
VAULT_PASSWORD="$vault_password" mount-vault $target_vault $target_mount
cd $target_mount
hg pull $conflicted_mount
cd $vaults_directory
umount-vault
rm -fr "$conflicted_mount"
mv $current_vault $resolved_directory
done
mkdir -p $vaults_directory/deescalated

View file

@ -1,10 +1,27 @@
#!/bin/bash #!/bin/bash
set -e set -e
mkdir -p ~/.vault
VERACRYPT="veracrypt" VERACRYPT="veracrypt"
if [[ "$OSTYPE" == "darwin"* ]]; then if [[ "$OSTYPE" == "darwin"* ]]; then
VERACRYPT="/Applications/VeraCrypt.app/Contents/MacOS/VeraCrypt" VERACRYPT="/Applications/VeraCrypt.app/Contents/MacOS/VeraCrypt"
fi fi
$VERACRYPT -t --mount ~/vaults/vault.vera ~/.vault
sudo chown $USER ~/.vault MOUNT_TARGET=$2
if [[ -z "$MOUNT_TARGET" ]]; then
MOUNT_TARGET=~/.vault
fi
mkdir -p "$MOUNT_TARGET"
MOUNT_SOURCE=$1
if [[ -z "$MOUNT_SOURCE" ]]; then
MOUNT_SOURCE="~/vaults/vault.vera"
fi
if [[ -z "$VAULT_PASSWORD" ]]; then
$VERACRYPT -t --mount "$MOUNT_SOURCE" "$MOUNT_TARGET"
else
$VERACRYPT -t --non-interactive -p $VAULT_PASSWORD --mount "$MOUNT_SOURCE" "$MOUNT_TARGET"
fi
sudo chown $USER "$MOUNT_TARGET"
echo "$MOUNT_SOURCE -> $MOUNT_TARGET"