Begin Wyrm from the game kit

This commit is contained in:
Eric Wagoner committed 2026-10-26 16:08:50 -04:00
commit d91b95cfab
73 files changed
+10509

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
# A word from the keeper in a table's talk, signed as the keeper, whether or
# not the host lets the gallery talk: the answer to a call that came too late,
# or anything else the table should hear from the keeper. Runs ON the droplet,
# through the game server's keeper door.
# wyrm-say.sh ROOM "text"
set -euo pipefail
ROOM="${1:?usage: wyrm-say.sh ROOM \"text\"}"
TEXT="${2:?usage: wyrm-say.sh ROOM \"text\"}"
DOOR="http://127.0.0.1:8791/keeper/rooms/${ROOM^^}"
[ -s /etc/wyrm/keeper.key ] || { echo "No keeper's key at /etc/wyrm/keeper.key; a deploy makes it." >&2; exit 1; }
# The key goes as a header read from a file descriptor, never on a command line another user could see.
KEY="@/dev/fd/3"
exec 3< <(printf 'x-keeper-key: %s\n' "$(cat /etc/wyrm/keeper.key)")
BODY=$(TEXT="$TEXT" python3 -c 'import json, os; print(json.dumps({"text": os.environ["TEXT"]}))')
CODE=$(curl -s -o /tmp/wyrm-say.$$ -w '%{http_code}' -X POST -H "$KEY" -H 'content-type: application/json' -d "$BODY" "$DOOR/say")
if [ "$CODE" = 204 ]; then echo "said at ${ROOM^^}"; else cat /tmp/wyrm-say.$$ >&2; echo >&2; rm -f /tmp/wyrm-say.$$; exit 1; fi
rm -f /tmp/wyrm-say.$$