Add encryption support with GPG for Levelhead emails

This commit is contained in:
Jomar Milan 2024-03-28 21:51:37 -07:00
parent e767a82050
commit a621e01ec4
1 changed files with 27 additions and 2 deletions

View File

@ -1,6 +1,6 @@
#!/bin/sh
# Define RUMPUS_DELEGATION_KEY and SEND_ADDR
# Define RUMPUS_DELEGATION_KEY, SEND_ADDR, and optionally USE_GPG
RCFILE="$(dirname $0)/.checklevelsrc"
if [ -f $RCFILE ]; then
@ -30,5 +30,30 @@ LEVEL_TITLE=$(jq -r '.title' <<< $LEVEL)
echo "Found new level: $LEVEL_TITLE ($LEVEL_ID) by $LEVEL_CREATOR!" >> $COMPOSE
done <<< $LEVELS
mail -s "New Levelhead Levels" $SEND_ADDR < $COMPOSE
if [ ! -z "$USE_GPG" ]
then
gpg --refresh-keys
sendmail $SEND_ADDR <<EOF
Subject: New Levelhead Levels
Content-Type: multipart/encrypted;
protocol="application/pgp-encrypted";
boundary="contentboundary"
This message is encrypted with PGP/MIME.
--contentboundary
Content-Type: application/pgp-encrypted
Version: 1
--contentboundary
Content-Type: application/octet-stream; name="encrypted.asc"
$(gpg --batch --armor --recipient "$SEND_ADDR" -o- --encrypt "$COMPOSE")
--contentboundary--
EOF
else
mail -s "New Levelhead Levels" "$SEND_ADDR" < "$COMPOSE"
fi
rm $COMPOSE