summaryrefslogtreecommitdiff
path: root/archive
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2022-12-06 23:45:35 -0700
committerSean Whitton <spwhitton@spwhitton.name>2022-12-07 09:49:20 -0700
commitb9b15f3f18d6c8733341bcbfcfc47c8443a2ef91 (patch)
treea34e0d2341318de84bef5980bd41b30e27718442 /archive
parent13f08e9d36de02c54283993d2bd035adf13f0411 (diff)
downloaddotfiles-b9b15f3f18d6c8733341bcbfcfc47c8443a2ef91.tar.gz
replace load-trustdb with something simpler
Diffstat (limited to 'archive')
-rwxr-xr-xarchive/bin/load-trustdb33
1 files changed, 33 insertions, 0 deletions
diff --git a/archive/bin/load-trustdb b/archive/bin/load-trustdb
new file mode 100755
index 00000000..5d8508ff
--- /dev/null
+++ b/archive/bin/load-trustdb
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+STAMP="$HOME/.gnupg/.load-trustdb"
+
+mkdir -p "$HOME/.gnupg"
+
+if [ -f "$STAMP" ]; then
+ last_script_run="$(stat -c '%Y' $STAMP)"
+else
+ last_script_run=0
+fi
+if [ -f "$HOME/.gnupg/trustdb.gpg" ]; then
+ last_trustdb_mod="$(stat -c '%Y' $HOME/.gnupg/trustdb.gpg)"
+else
+ last_trustdb_mod=0
+fi
+
+if [ ! -f "$HOME/.gnupg/trustdb.gpg" \
+ -o "$last_trustdb_mod" -le "$last_script_run" \
+ ]; then
+ gpg --import-ownertrust "$HOME/lib/priv/.gnupg/otrust.lst"
+ # ensure that a check doesn't happen which set the trustdb mtime
+ # to newer than this script's last run time with no changes we
+ # have to backup
+ gpg --batch --check-trustdb
+ touch "$STAMP"
+else
+ echo >&2 "WARNING: The trustdb has been modified. You should probably run:"
+ echo >&2
+ echo >&2 " gpg --export-ownertrust >~/lib/priv/.gnupg/otrust.lst"
+ echo >&2
+ echo >&2 "to back it up. (or discard changes: rm ~/.gnupg/trustdb.gpg && load-trustdb)."
+fi