2019-03-11 19:00:03 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2022-01-11 20:13:32 +01:00
|
|
|
set -euo pipefail
|
2019-03-11 19:00:03 +01:00
|
|
|
|
|
|
|
# Run this script to export all the information required to transport your GPG
|
|
|
|
# information.
|
2022-01-11 20:13:32 +01:00
|
|
|
# Usage: ./export.sh
|
2019-03-11 19:00:03 +01:00
|
|
|
# TODO: run this periodically as a job.
|
|
|
|
|
2022-01-11 20:13:32 +01:00
|
|
|
output="$(pwd)/export.zip"
|
|
|
|
destination="$(mktemp -d)"
|
2019-03-11 19:00:03 +01:00
|
|
|
|
2022-01-11 20:13:32 +01:00
|
|
|
function cleanup() {
|
|
|
|
rm -rf "${destination}"
|
|
|
|
}
|
|
|
|
trap cleanup EXIT
|
2019-03-11 19:00:03 +01:00
|
|
|
|
2021-10-24 01:07:39 +02:00
|
|
|
gpg --armor --export >"${destination}/public.asc"
|
|
|
|
gpg --armor --export-secret-keys >"${destination}/secret.asc"
|
|
|
|
gpg --armor --export-ownertrust >"${destination}/ownertrust.txt"
|
2019-03-11 19:00:03 +01:00
|
|
|
|
2022-01-11 20:13:32 +01:00
|
|
|
# Strangely enough this appears to be the only way to create a zip of a
|
|
|
|
# directory that doesn't contain the (noisy) full paths of each item from the
|
|
|
|
# source filesystem. (i.e. -j doesn't cooperate with -r)
|
|
|
|
pushd "${destination}"
|
|
|
|
zip -r "${output}" ./*
|
|
|
|
popd
|
2021-10-24 01:07:39 +02:00
|
|
|
|
2022-01-11 20:13:32 +01:00
|
|
|
echo "$(realpath ${output})"
|