3
# gpg-mailkeys: mail out just signed keys to their owners
5
# $Id: gpg-mailkeys 288 2006-07-09 15:39:16Z kink-guest $
12
echo "Send people their newly signed GPG key by mail."
13
echo "Usage: $0 keyid ..."
17
if [ -e ~/.gpg-mailkeysrc ] ; then
20
if [ -n "$EMAIL" ]; then
23
if [ -z "$SUBJECT" ]; then
24
SUBJECT="Your signed GPG key"
26
if [ -z "$NAME" ]; then
27
NAME=`getent passwd $USER | cut -d: -f5 | cut -d, -f1`
29
if [ -z "$TEXT" ]; then
32
Here is your signed GPG key.
42
TEMPFILE=`mktemp -t gpg2mail.XXXXXX`
43
ADDR=`gpg --with-colons --fixed-list-mode --list-key $1 | sed -e 's/^uid:[^re][^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:<]*<[^:>]*>\):.*/@@uid@@ \1/' -e '/^@@uid@@ /!d' -e 's/([^)]*)//g' -e 's/ */ /g' -e 's/^@@uid@@ //' | head -1`
44
if [ -z "$ADDR" ]; then
45
echo "(no usable user ids)"
46
FAILKEYS="$FAILKEYS:$1"
50
BOUNDARY="ksp-$$-boundary-$RANDOM"
54
echo >$TEMPFILE "From: $NAME <$FROM>"
56
cat << EOM >> $TEMPFILE
59
User-Agent: gpg-mailkeys/$VERSION
61
Content-Type: multipart/mixed; micalg=pgp-sha1;
63
Content-Disposition: inline
68
Content-Type: text/plain; charset=us-ascii
69
Content-Disposition: inline
70
Content-Transfer-Encoding: quoted-printable
77
if [ -f ~/.signature ];
78
then echo "--=20" >> $TEMPFILE
79
cat ~/.signature >> $TEMPFILE
82
cat << EOM >> $TEMPFILE
85
Content-Type: application/pgp-keys
86
Content-Disposition: attachment; filename="$1.asc"
88
`gpg --armor --export $1`
93
/usr/sbin/sendmail -ti <$TEMPFILE
99
if [ -n "$FAILKEYS" ]; then
101
echo "Note: The following keys could not be sent:"
102
echo "$FAILKEYS" | tr ':' '\n' | sed -e '/^ *$/d' -e 's/^/ /'