summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rwxr-xr-xmulti-send-key84
2 files changed, 85 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index b207c9f..2b9b618 100644
--- a/Makefile
+++ b/Makefile
@@ -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;