decrypt_gnupg 570 B

1234567891011121314151617181920212223242526
  1. #!/bin/sh
  2. decrypt_gpg () {
  3. echo "Performing GPG symmetric decryption ..." >&2
  4. if ! /lib/cryptsetup/askpass "Enter passphrase for key $1: " | \
  5. /usr/bin/gpg -q --batch --no-options \
  6. --no-random-seed-file --no-default-keyring \
  7. --keyring /dev/null --secret-keyring /dev/null \
  8. --trustdb-name /dev/null --passphrase-fd 0 --decrypt -- "$1"; then
  9. return 1
  10. fi
  11. return 0
  12. }
  13. if [ ! -x /usr/bin/gpg ]; then
  14. echo "$0: /usr/bin/gpg is not available" >&2
  15. exit 1
  16. fi
  17. if [ -z "$1" ]; then
  18. echo "$0: missing key as argument" >&2
  19. exit 1
  20. fi
  21. decrypt_gpg "$1"
  22. exit $?