-# check for presense of secret key
-# FIXME: is this the proper test to be doing here?
-fingerprint_host_key >/dev/null \
- && failure "An OpenPGP host key already exists."
-
-# get options
-while true ; do
- case "$1" in
- -f|--keyfile)
- keyFile="$2"
- shift 2
- ;;
- -e|--expire)
- keyExpire="$2"
- shift 2
- ;;
- *)
- if [ "$(echo "$1" | cut -c 1)" = '-' ] ; then
- failure "Unknown option '$1'.
-Type '$PGRM help' for usage."
- fi
- hostName="$1"
- shift
- ;;
- break
- ;;
- esac
-done
-
-if [ ! -f "$keyFile" ] ; then
- failure "SSH secret key file '$keyFile' not found."
+hostName="$1"
+
+# use the default hostname if not specified
+if [ -z "$hostName" ] ; then
+ hostName=$(hostname -f)
+ # test that the domain is not obviously illegitimate
+ domain=${foo##*.}
+ case $domain in
+ 'local'|'localdomain')
+ failure "Host domain '$domain' is not legitimate. Aborting key import."
+ ;;
+ esac
+ # test that there are at least two parts
+ if (( $(echo "$hostName" | tr . ' ' | wc -w) < 2 )) ; then
+ failure "Host name '$hostName' is not legitimate. Aborting key import."
+ fi