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

# Load functions
LIB="`dirname $0`/../../lib/keyringer/functions"
source $LIB
keyringer_set_env $*

# Aditional parameters
FILE="`keyringer_filename $2`"

# Setup
if [ -z "$FILE" ]; then
  echo "Usage: keyringer <keyring> `basename $0` <file>"
  exit 1
elif [ ! -f "$RECIPIENTS" ]; then
  echo "No recipient config was found"
  exit 1
fi

# Encrypt
mkdir -p $KEYDIR/`dirname $FILE`
echo "Type your message and finish your input with EOF (Ctrl-D)."
gpg --use-agent --armor -e -s $(keyringer_recipients $RECIPIENTS) - > $KEYDIR/$FILE

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