ksphelper 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. help() {
  4. cat<<HELP 2>&1
  5. USAGE:
  6. ksphelper <party name> <keymaster> <keysfile>
  7. ksphelper helps create a gpgparticipants file from a list of keys.
  8. Outputs a ksp-text.txt in the current directory from gpgparticipants
  9. and won't mess with your normal gpg keyring to do it.
  10. OPTIONS:
  11. <party name> Name for your keysigning party, passed as title to
  12. gpgparticipants(1)
  13. <keymaster> KSP organizer in the format: "Name <email@domain.tld>",
  14. passed as organizer to gpgparticipants(1)
  15. <keysfile> Path to text file that contains the keys of all
  16. participants, one per line, comments and blank lines
  17. are ignored.
  18. EXAMPLE:
  19. ksphelper "WMFRelEng" "Tyler Cipriani <tcipriani@wikimedia.org>" keys
  20. HELP
  21. }
  22. if (( $# < 3 )); then
  23. help
  24. exit 1
  25. fi
  26. KSP_NAME="$1"
  27. KEYMASTER="$2"
  28. KEYS_FILE="$3"
  29. KEYRING_DIR="$(mktemp -d -q --suffix=_ksphelper)"
  30. KEYRING="pubring.kbx"
  31. touch "${KEYRING_DIR}/${KEYRING}"
  32. # Grab all the keys into a local keychain
  33. grep -v '^#' keys | \
  34. grep -v '^\s*$' | xargs gpg \
  35. --no-options \
  36. --no-default-keyring \
  37. --keyring="${KEYRING_DIR}/${KEYRING}" \
  38. --recv-keys
  39. grep -v '^#' keys | \
  40. grep -v '^\s*$' | GNUPGHOME="$KEYRING_DIR" gpgparticipants \
  41. - ksp-file.txt "$(date --iso=seconds)" "$KEYMASTER" "$KSP_NAME"
  42. \rm -rf "$KEYRING_DIR"