aboutsummaryrefslogtreecommitdiff
path: root/share/keyringer/encrypt
blob: 3680d0b91f43beb763592354c3b20eac77723384 (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
#!/bin/bash
#
# Encrypt files to multiple recipients.
#

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

# Aditional parameters
keyringer_get_new_file "$2"

# Set recipients file
keyringer_set_recipients "$FILE"

# Encrypt
mkdir -p "$KEYDIR/`dirname $FILE`"

if [ "$BASENAME" == "encrypt" ]; then
  # Only display directions if we're running encrypt, not encrypt-batch
  echo "Type your message and finish your input with EOF (Ctrl-D)."
fi

$GPG --use-agent --armor -e -s $(keyringer_recipients "$RECIPIENTS_FILE") - > "$KEYDIR/$FILE"

err="$?"

if [ "$err" != "0" ]; then
  exit "$err"
fi

# Stage
if [ -d "$BASEDIR/.git" ]; then
  keyringer_exec git "$BASEDIR" add "keys/$FILE"
fi

exit "$?"