#!/bin/bash

if [ -z "$PGPPATH" ]; then
  export PGPPATH=$HOME/.pgp
fi

## text from PGP 2.6.3 (pgp -g)
echo
echo "You need a user ID for your public key.  The desired form for this"
echo "user ID is your name, followed by your E-mail address enclosed in"
echo "<angle brackets>, if you have an E-mail address."
echo "For example:  First M. Last <$USER@$HOSTNAME>"
echo "Enter a user ID for your public key:"; read USERID
echo

mkdir $PGPPATH
chmod 0700 $PGPPATH

if [ "$USEPGP5" = "TRUE" ]; then
  touch $PGPPATH/pgp.cfg

## in Linux PGP 5.0 beta 11 the '-u' option is ignored with '-g' -- the user
## id will need to be typed twice because of this minor problem.

  pgpk -g #-u "$USERID"
  pgpk -xa "$USERID" -o ~/.pgpkey.asc
else
  pgp -kg -u "$USERID"
  pgp -kxa "$USERID" ~/.pgpkey
fi
mv ~/.pgpkey.asc ~/.pgpkey
chmod 0644 ~/.pgpkey