summaryrefslogtreecommitdiff
path: root/share/keyringer/recrypt
blob: ff1d60e47f25b36a924b61cb58bf5d7cc636ea98 (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
#!/bin/bash
#
# Re-encrypt files to multiple recipients.
#

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

# Config
BASEDIR="$1"
FILE="`keyringer_filename $2`"
KEYDIR="$BASEDIR/keys"
RECIPIENTS="$BASEDIR/config/recipients"
BASENAME="`basename $0`"

if [ -z "$FILE" ]; then
  echo "Usage: `basename $0` <basedir> <file>"
  exit 1
elif [ ! -f "$RECIPIENTS" ]; then
  echo "No recipient config was found"
  exit 1
elif [ ! -f "$KEYDIR/$FILE" ]; then
  echo "File not found: $KEYDIR/$FILE"
  exit 1
fi

gpg -d $KEYDIR/$FILE | gpg --armor -e -s $(keyringer_recipients $RECIPIENTS) > $KEYDIR/$FILE