+# FIXME: need to figure out how to automate this, in a batch mode
+# or something.
+trust_uids() {
+ for userID ; do
+ gpg --keyserver "$KEYSERVER" --search ="$userID"
+ gpg --edit-key "$userID"
+ done
+}
+
+########################################################################
+# MAIN
+########################################################################
+
+# set ms home directory
+MS_HOME=${MS_HOME:-/etc/monkeysphere}
+
+# load configuration file
+MS_CONF=${MS_CONF:-"$MS_HOME"/monkeysphere.conf}
+[ -e "$MS_CONF" ] && . "$MS_CONF"
+
+GNUPGHOME=${GNUPGHOME:-"$MS_HOME"/gnupg}
+export GNUPGHOME
+KEYSERVER=${KEYSERVER:-subkeys.pgp.net}
+export KEYSERVER
+
+COMMAND="$1"
+[ "$COMMAND" ] || failure "Type '$PGRM help' for usage."
+shift 1
+
+case $COMMAND in
+ 'gen-key')
+ gen_key
+ ;;
+ 'publish-key')
+ publish_key
+ ;;
+ 'trust-uids')
+ trust_uids "$@"
+ ;;
+ 'help')
+ usage
+ exit
+ ;;
+ *)
+ failure "Unknown command: '$COMMAND'
+Type '$PGRM help' for usage."
+ ;;
+esac