mirror of
https://github.com/spantaleev/matrix-docker-ansible-deploy.git
synced 2026-08-18 14:50:54 +00:00
Add a meowlnir-whoami diagnostic script to matrix-bot-meowlnir
Asks the homeserver who Meowlnir's appservice token belongs to. A 401 (M_UNKNOWN_TOKEN) response means the homeserver is running without Meowlnir's appservice registration, which is the usual cause of Meowlnir's "Failed to connect to homeserver" log messages. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -296,6 +296,10 @@ The playbook drives Meowlnir's management API for you based on `matrix_bot_meowl
|
||||
|
||||
# Create another management room for an existing bot, with the given users able to command it there
|
||||
/matrix/meowlnir/bin/meowlnir-create-management-room meowlnir_bot @alice:example.com
|
||||
|
||||
# Ask the homeserver who Meowlnir's appservice token belongs to.
|
||||
# A 401 response means the homeserver is running without Meowlnir's appservice registration, which is also what Meowlnir's own "Failed to connect to homeserver" log messages usually mean.
|
||||
/matrix/meowlnir/bin/meowlnir-whoami
|
||||
```
|
||||
|
||||
`meowlnir-create-management-room` prints the new room's ID, which you then register with `meowlnir-api PUT /_meowlnir/v1/management_room/<room ID>`.
|
||||
|
||||
@@ -89,6 +89,7 @@
|
||||
- meowlnir-api
|
||||
- meowlnir-bots
|
||||
- meowlnir-create-management-room
|
||||
- meowlnir-whoami
|
||||
|
||||
- name: Ensure matrix-bot-meowlnir container network is created
|
||||
when: matrix_bot_meowlnir_container_network != 'host'
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
# Asks the homeserver who Meowlnir's appservice token belongs to.
|
||||
#
|
||||
# A `200` response proves the homeserver has Meowlnir's appservice registration loaded.
|
||||
# A `401` (`M_UNKNOWN_TOKEN`) response means it is running without it — the condition that otherwise surfaces as Meowlnir endlessly logging "Failed to connect to homeserver".
|
||||
#
|
||||
# Usage: meowlnir-whoami
|
||||
#
|
||||
# Prints the response body, followed by the HTTP status code on its own final line.
|
||||
|
||||
set -eu
|
||||
|
||||
CONFIG_FILE='{{ matrix_bot_meowlnir_config_path }}/config.yaml'
|
||||
CONTAINER_NAME='matrix-bot-meowlnir'
|
||||
HOMESERVER_ADDRESS='{{ matrix_bot_meowlnir_config_homeserver_address }}'
|
||||
REQUEST_TIMEOUT='{{ matrix_bot_meowlnir_api_request_timeout_seconds }}'
|
||||
|
||||
# The configuration file is generated by Ansible, so its layout is predictable.
|
||||
as_token="$(awk '$1 == "as_token:" { print $2; exit }' "$CONFIG_FILE" | sed 's/^"//; s/"$//')"
|
||||
|
||||
if [ -z "$as_token" ]; then
|
||||
echo "Could not read as_token from $CONFIG_FILE" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Runs curl inside the container, because the homeserver is only reachable over the container network.
|
||||
exec {{ devture_systemd_docker_base_host_command_docker }} exec "$CONTAINER_NAME" \
|
||||
curl -sS --max-time "$REQUEST_TIMEOUT" \
|
||||
-H "Authorization: Bearer $as_token" \
|
||||
-w '\n%{http_code}' \
|
||||
"$HOMESERVER_ADDRESS/_matrix/client/v3/account/whoami"
|
||||
@@ -0,0 +1,3 @@
|
||||
SPDX-FileCopyrightText: 2026 Slavi Pantaleev
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
Reference in New Issue
Block a user