drop-expired-sub-keys 787 B

123456789101112131415161718192021
  1. #!/bin/bash
  2. # Drop expired and revoked sub-keys from a keyring file
  3. #
  4. # usage: drop-expired-sub-keys <keyring-file>
  5. #
  6. # Note: this script only handles the case where all expired and revoked
  7. # sub-keys should be removed, so it cannot be used in the cases where
  8. # some of the expired sub-keys need to be kept. It is also only handling
  9. # one small part of the process to clean the keyring files and is not
  10. # supposed to be run on all keyring files.
  11. #
  12. # See the README file for the complete process for cleaning keyring files.
  13. set -e
  14. keyring="$1"
  15. test -f "$keyring"
  16. tmpfile=$(mktemp)
  17. gpg --no-auto-check-trustdb --no-default-keyring --keyring "$keyring" --export-options export-clean --export-filter 'drop-subkey=expired -t || revoked -t' --export > "$tmpfile"
  18. mv -f "$tmpfile" "$keyring"