diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2009-04-26 13:33:04 +0200 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2009-04-26 13:33:04 +0200 |
commit | e5d29b3271da1eab48041032fd7f922486ad54a5 (patch) | |
tree | d2eda186dff3066fb2cfc79521394690e55b36fd | |
parent | ac0f5eb7ebb98c19220b1ed7044c282d72b72845 (diff) |
Added multi-send-key script
-rw-r--r-- | Makefile | 2 | ||||
-rwxr-xr-x | multi-send-key | 84 |
2 files changed, 85 insertions, 1 deletions
@@ -1,6 +1,6 @@ BINDIR = $(HOME)/bin -TARGETS = mkheader.py isprime +TARGETS = mkheader.py isprime multi-send-key all: $(TARGETS) @echo "Nothing to be done" diff --git a/multi-send-key b/multi-send-key new file mode 100755 index 0000000..0dad01c --- /dev/null +++ b/multi-send-key @@ -0,0 +1,84 @@ +#!/bin/bash +# +# multi-send-key - Send signed PGP/GPG keys to multiple keyservers +# +# Copyright (C) 2004-2006, Tobias Klauser <tklauser@distanz.ch> +# This file is licensed under the GNU General Public License v2 + +REV='1.18' + +gpg_bin=`which gpg` + +SCRIPT=`basename $0` +KEYS="" +KEYSERVERS=" + $KEYSERVERS + subkeys.pgp.net" +# pgp.uni-mainz.de +# sks.keyserver.penguin.de +# wwwkeys.ch.pgp.net +# keyserver.kjsl.com + +version() { + cat >&2 <<EOF +$SCRIPT $REV +Copyright (C) 2004-2006 Tobias Klauser <tklauser@distanz.ch> +Licensed under the GNU General Public License. +EOF + exit 1 +} + +usage() { + # XXX -f not implemented + cat >&2 <<EOF +Usage: $SCRIPT [options...] [-f keyring] [keyids...] +Options: + -f Send the keys contained in the specified keyring file + -o Send own key (specified in the \$MYKEY envvar) + -h Print this message and exit + -v Print version and exit + +This script sends all GPG public keys specified via the command line to the +keyservers specified in the \$KEYSERVERS envvar. +EOF + exit 1 +} + +eval set -- `getopt -n $SCRIPT "f:ovh" "$@"` || usage +for opt; do + case "$opt" in + -f) shift; keyring="$1"; shift;; # XXX + -o) shift; KEYS="$MYKEY";; + -h) shift; usage;; + -v) shift; version;; + --) shift; break;; + esac +done + +if [ -z "$KEYS" ] && [ -z "$@" ] ; then + echo "* Please specify at least one key identifier or use -o to send \$MYKEY." + echo + usage + exit 5; +fi + +KEYS="$KEYS $@" + +$gpg_bin --list-keys $KEYS &> /dev/null + +if [ $? -eq 0 ] ; then + for server in $KEYSERVERS ; do + for key in $KEYS ; do + echo "* Sending key [$key] to server [$server]" + $gpg_bin --keyserver $server --send-key $key &> /dev/null + if [ "$?" -gt 0 ]; then + echo "* An error happened while sending the key to [$server]." + fi + done + done +else + echo "* Keys [$KEYS] not found in GPG default keyring." + exit 5; +fi + +exit 0; |