~cyplo/dotfiles

ref: 1ca69547b9a678da7a89ac93b7822ac478a2ab7d dotfiles/tools/deescalate.sh -rwxr-xr-x 805 bytes
1ca69547 — Cyryl Płotnicki update 5 months 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
#!/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