aboutsummaryrefslogtreecommitdiff
path: root/duply/scripts/duplicity/duply_common.sh
blob: 41ae389e5c55ca38d3a267241289e205a39d9444 (plain)
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
42
43
44
45
JSON_CONF=$(mktemp)
cleanup() {
    rm -f "${JSON_CONF}"
}
trap cleanup INT TERM EXIT

gpg_export_if_needed() {
    echo "Prevent GPG keys for beeing exported"
}

# Always mark the secret key as available (do not try to import it)
gpg_sec_avail() {
    true
}

# Override the read command with zenity
read() {
  if command -v zenity &> /dev/null
  then
    RESULT=$(zenity --password 2>/dev/null) 
    if [ $? -ne 0 ]; then
      command read $*
  else
      eval $2=${RESULT}
    fi
  else
    command read $*
  fi
}
. ~/.config/ovh/duplicity-$(whoami).sh

#Generate the configuration
case $2 in 
    restore)
        export COLD_PATH=$(zenity --file-selection --directory --title="Chemin des sauvegardes")
        ~/scripts/duplicity/gen_config_restore.sh "${JSON_CONF}"
        ;;
    *)
        ~/scripts/duplicity/gen_config_remote.sh "${JSON_CONF}"
        ;;
esac

TARGET="multi:${JSON_CONF}?mode=mirror&onfail=abort"

DUPL_PARAMS="$DUPL_PARAMS --file-prefix-manifest 'hot_' --file-prefix-signature 'hot_' --file-prefix-archive 'cold_' "