2 # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant)
4 # Monkeysphere host import-key subcommand
6 # The monkeysphere scripts are written by:
7 # Jameson Rollins <jrollins@finestructure.net>
8 # Jamie McClelland <jm@mayfirst.org>
9 # Daniel Kahn Gillmor <dkg@fifthhorseman.net>
11 # They are Copyright 2008-2010 and are all released under the GPL,
17 local serviceName="$2"
19 # check that key file specified
20 if [ -z "$keyFile" ] ; then
21 failure "Must specify PEM-encoded key file to import, or specify '-' for stdin."
24 # fail if hostname not specified
25 if [ -z "$serviceName" ] ; then
26 failure "You must specify a service name for use in the OpenPGP certificate user ID."
29 # check that the service name is well formatted
30 check_service_name "$serviceName"
33 mkdir -p "${MHDATADIR}"
34 mkdir -p "${GNUPGHOME_HOST}"
35 chmod 700 "${GNUPGHOME_HOST}"
37 # import pem-encoded key to an OpenPGP private key
38 if [ "$keyFile" = '-' ] ; then
39 log verbose "importing key from stdin..."
40 PEM2OPENPGP_USAGE_FLAGS=authenticate pem2openpgp "$serviceName" \
43 log verbose "importing key from file '$keyFile'..."
44 PEM2OPENPGP_USAGE_FLAGS=authenticate pem2openpgp "$serviceName" \
49 # export to gpg public key to file
52 log info "host key imported:"
54 # show info about new key
55 show_key "$serviceName"