+# set up monkeysphere-server
+echo "### configuring monkeysphere..."
+mkdir -p -m 750 "$MONKEYSPHERE_SYSDATADIR"/host
+mkdir -p -m 700 "$MONKEYSPHERE_SYSDATADIR"/authentication
+mkdir -p -m 700 "$MONKEYSPHERE_SYSDATADIR"/authentication/authorized_keys
+mkdir -p -m 750 "$MONKEYSPHERE_SYSDATADIR"/authentication/sphere
+mkdir -p -m 700 "$MONKEYSPHERE_SYSDATADIR"/tmp
+cp etc/monkeysphere/monkeysphere-server.conf "$TEMPDIR"/monkeysphere-server.conf
+cat <<EOF >> "$TEMPDIR"/monkeysphere-server.conf
+AUTHORIZED_USER_IDS="$MONKEYSPHERE_HOME/authentication/authorized_user_ids"
+EOF
+cat <<EOF > "$MONKEYSPHERE_SYSDATADIR"/authentication/sphere/gpg.conf
+primary-keyring ${MONKEYSPHERE_SYSDATADIR}/authentication/sphere/pubring.gpg
+keyring ${MONKEYSPHERE_SYSDATADIR}/authentication/core/pubring.gpg
+EOF
+
+
+### SERVER TESTS
+
+# create a new host key
+echo "### generating server key..."
+# add gpg.conf with quick-random
+get_gpg_prng_arg >> "$MONKEYSPHERE_SYSCONFIGDIR"/host/gpg.conf
+echo | monkeysphere-host expert gen-key --length 1024 --expire 0 testhost
+# remove the gpg.conf
+rm "$MONKEYSPHERE_SYSCONFIGDIR"/host/gpg.conf
+
+HOSTKEYID=$( monkeysphere-host show-key | grep '^OpenPGP fingerprint: ' | cut -f3 -d\ )
+
+# certify it with the "Admin's Key".
+# (this would normally be done via keyservers)
+echo "### certifying server key..."
+monkeysphere-authentication expert gpg-cmd "--armor --export $HOSTKEYID" | gpgadmin --import
+echo y | gpgadmin --command-fd 0 --sign-key "$HOSTKEYID"