aboutsummaryrefslogtreecommitdiff
path: root/scripts/recrypt
blob: 48c4d40d0bf8e5e0096ecf0d49371814f08ccf4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash
#
# Re-encrypt files to multiple recipients.
#

FILE="$1"
BASENAME="`basename $0`"
RECIPIENTS="config/recipients"

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

recipients="$(awk '{ print "-r " $2 }' $RECIPIENTS | xargs)"
gpg -d keys/$FILE | gpg --armor -e -s $recipients > keys/$FILE