Last active
June 15, 2022 17:45
-
-
Save feklee/3d931bdb3d7582bb862e8d9e9443e83e to your computer and use it in GitHub Desktop.
Appends a PDF file to a PGP encrypted PDF file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Felix E. Klee <[email protected]> | |
set -e | |
# Usage info | |
show_help() { | |
cat << EOF | |
Usage: ${0##*/} PGP_ENCRYPTED_PDF NEW_PDF PGP_ENCRYPTED_RESULT | |
Appends NEW_PDF to PGP_ENCRYPTED_PDF and saves it to PGP_ENCRYPTED_RESULT. | |
EOF | |
} | |
if [ "$#" -ne 3 ]; then | |
show_help >&2 | |
exit 1 | |
fi | |
PGP_ENCRYPTED_PDF="$1" | |
NEW_PDF="$2" | |
PGP_ENCRYPTED_RESULT="$3" | |
TEMP_PDF=$(mktemp -t XXXXXXXX.pdf) | |
gpg --batch --yes -o "$TEMP_PDF" -d "$PGP_ENCRYPTED_PDF" | |
qpdf "$TEMP_PDF" --replace-input --pages "$TEMP_PDF" "$NEW_PDF" -- | |
gpg -e -r "$EMAIL" "$TEMP_PDF" | |
mv "$TEMP_PDF.gpg" "$PGP_ENCRYPTED_RESULT" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment