aboutsummaryrefslogtreecommitdiff
path: root/share/keyringer/edit
blob: 10798e2292c3f846cbc0e41c2590f6c85676aeb7 (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
#!/bin/bash
#
# Edit keys.
#

# Load functions
LIB="`dirname $0`/../../lib/keyringer/functions"
source "$LIB" || exit 1

# Get file
keyringer_get_file "$2"

# Set recipients file
keyringer_set_recipients "$FILE"

# Warn user
echo "Make sure that $BASEDIR is atop of an encrypted volume."

# Set a tmp file
keyringer_set_tmpfile edit

# Decrypt the information to the file
$GPG --yes -o "$TMPWORK" --use-agent -d "$KEYDIR/$FILE"

# Prompt
echo "Press any key to open the decrypted data in $EDITOR, Ctrl-C to abort"
read key
"$EDITOR" "$TMPWORK"

# Encrypt again
$GPG --yes -o "$KEYDIR/$FILE" --use-agent --armor -e -s $(keyringer_recipients "$RECIPIENTS_FILE") "$TMPWORK"

# Remove temp file
keyringer_unset_tmpfile "$TMPWORK"