about summary refs log tree commit diff
path: root/configs/shared/gpg/.gnupg/export.sh
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2019-03-11T18·00+0000
committerWilliam Carroll <wpcarro@gmail.com>2019-03-11T18·00+0000
commiteaf42b68c25e9bfdb2e5f62f9e9bd460405071d9 (patch)
treeab1841ec8e4f14245fcc5c9a9d158af0ee39ad61 /configs/shared/gpg/.gnupg/export.sh
parente774ce5d1c8ddb62fc62c69719390eff1c4f50b0 (diff)
Better support GPG migrations
After yet another unpleasant experience starting up GPG on a new system, I
decided to encode my learnings and mistakes as aliases, functions, scripts,
hoping to protect my future me from myself. Fingers crossed!
Diffstat (limited to 'configs/shared/gpg/.gnupg/export.sh')
-rwxr-xr-xconfigs/shared/gpg/.gnupg/export.sh21
1 files changed, 21 insertions, 0 deletions
diff --git a/configs/shared/gpg/.gnupg/export.sh b/configs/shared/gpg/.gnupg/export.sh
new file mode 100755
index 000000000000..571689773b0e
--- /dev/null
+++ b/configs/shared/gpg/.gnupg/export.sh
@@ -0,0 +1,21 @@
+#!/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"
+
+echo $(realpath "$destination")