tvl-depot/users/wpcarro/configs/.gnupg/export.sh
William Carroll a415bdaeb5 feat(wpcarro/gpg): Zip output from configs/.gnupg/export.sh
This makes it easier to `scp` to the new host.

Change-Id: If746a71204c97255547b579252622005b4d13b20
Reviewed-on: https://cl.tvl.fyi/c/depot/+/4793
Tested-by: BuildkiteCI
Reviewed-by: wpcarro <wpcarro@gmail.com>
Autosubmit: wpcarro <wpcarro@gmail.com>
2022-01-08 05:53:42 +00:00

24 lines
639 B
Bash
Executable file

#!/usr/bin/env bash
set -e
# Run this script to export all the information required to transport your GPG
# information.
# Usage: ./export.sh [directory]
# TODO: run this periodically as a job.
destination="${1:-$(mktemp -d)}"
if [ ! -d "${destination}" ]; then
echo "${destination} does not exist. Creating it..."
mkdir -p "${destination}"
fi
gpg --armor --export >"${destination}/public.asc"
gpg --armor --export-secret-keys >"${destination}/secret.asc"
gpg --armor --export-ownertrust >"${destination}/ownertrust.txt"
zip -r "${destination}.zip" "${destination}"
rm -rf "${destination}"
echo $(realpath "${destination}.zip")