diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2022-12-06 23:45:35 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2022-12-07 09:49:20 -0700 |
commit | b9b15f3f18d6c8733341bcbfcfc47c8443a2ef91 (patch) | |
tree | a34e0d2341318de84bef5980bd41b30e27718442 /archive | |
parent | 13f08e9d36de02c54283993d2bd035adf13f0411 (diff) | |
download | dotfiles-b9b15f3f18d6c8733341bcbfcfc47c8443a2ef91.tar.gz |
replace load-trustdb with something simpler
Diffstat (limited to 'archive')
-rwxr-xr-x | archive/bin/load-trustdb | 33 |
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 |