summaryrefslogtreecommitdiff
path: root/src/share/mh/publish_key
blob: b433ad726195554e454dd030ddf6a4256b3a7c99 (plain)
  1. # -*-shell-script-*-
  2. # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant)
  3. # Monkeysphere host publish-key subcommand
  4. #
  5. # The monkeysphere scripts are written by:
  6. # Jameson Rollins <jrollins@finestructure.net>
  7. # Jamie McClelland <jm@mayfirst.org>
  8. # Daniel Kahn Gillmor <dkg@fifthhorseman.net>
  9. #
  10. # They are Copyright 2008-2009, and are all released under the GPL, version 3
  11. # or later.
  12. # publish server key to keyserver
  13. publish_key() {
  14. local GNUPGHOME
  15. if [ "$PROMPT" = "true" ] ; then
  16. read -p "Really publish host key to $KEYSERVER? (y/N) " OK; OK=${OK:=N}
  17. if [ ${OK/y/Y} != 'Y' ] ; then
  18. failure "key not published."
  19. fi
  20. else
  21. log debug "publishing key without prompting."
  22. fi
  23. # create a temporary gnupg directory from which to publish the key
  24. export GNUPGHOME=$(mktemp -d)
  25. # trap to remove tmp dir if break
  26. trap "rm -rf $GNUPGHOME" EXIT
  27. # import the host key into the tmp dir
  28. su_monkeysphere_user \
  29. "gpg --quiet --import" <"$HOST_KEY_FILE"
  30. # publish host key
  31. su_monkeysphere_user \
  32. "gpg --keyserver $KEYSERVER --send-keys '0x${HOST_FINGERPRINT}!'"
  33. # remove the tmp file
  34. trap - EXIT
  35. rm -rf "$GNUPGHOME"
  36. }