Skip to content

Commit 2c31c4c

Browse files
committed
fix(prosody): Fix creating users.
Use env var for prosody port and move roster after user creation to guarantee the order.
1 parent eab4bff commit 2c31c4c

File tree

2 files changed

+31
-79
lines changed
  • prosody/rootfs/etc/services.d
    • 70-register-setup
    • 90-roster-setup

2 files changed

+31
-79
lines changed

prosody/rootfs/etc/services.d/70-register-setup/run

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ echo "[register-setup] Service starting..."
44

55
# Wait for prosody to be ready
66
echo "[register-setup] Waiting for prosody to be ready..."
7+
[ -z "$PROSODY_HTTP_PORT" ] && PROSODY_HTTP_PORT="5280"
78
MAX_ATTEMPTS=60
89
ATTEMPT=0
910

1011
while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do
11-
if curl --fail --silent --output /dev/null http://127.0.0.1:5280/health 2>&1; then
12+
if curl --fail --silent --output /dev/null http://127.0.0.1:${PROSODY_HTTP_PORT}/health 2>&1; then
1213
echo "[register-setup] Prosody is ready!"
1314
break
1415
fi
@@ -133,7 +134,35 @@ if [[ ! -z $JIGASI_XMPP_PASSWORD ]]; then
133134
fi
134135
fi
135136

136-
echo "[register-setup] All users registered, service completed"
137+
# Capture both stdout and stderr
138+
OUTPUT=$(prosodyctl --config $PROSODY_CFG shell roster subscribe_both focus@$XMPP_AUTH_DOMAIN focus.$XMPP_DOMAIN 2>&1)
139+
RESULT=$?
140+
141+
echo "[register-setup] Roster command output:"
142+
echo "$OUTPUT"
143+
144+
if [ $RESULT -eq 0 ]; then
145+
echo "[register-setup] Roster subscription completed successfully"
146+
147+
# Reload mod_client_proxy module to apply roster changes
148+
echo "[register-setup] Reloading client_proxy module..."
149+
RELOAD_OUTPUT=$(prosodyctl --config $PROSODY_CFG shell module reload client_proxy 2>&1)
150+
RELOAD_RESULT=$?
151+
152+
echo "[register-setup] Module reload output:"
153+
echo "$RELOAD_OUTPUT"
154+
155+
if [ $RELOAD_RESULT -eq 0 ]; then
156+
echo "[register-setup] Module reloaded successfully"
157+
else
158+
echo "[register-setup] WARNING: Failed to reload module (exit code: $RELOAD_RESULT)"
159+
fi
160+
else
161+
echo "[register-setup] ERROR: Failed to setup roster subscription (exit code: $RESULT)"
162+
fi
163+
164+
echo "[register-setup] All users registered and roster modified, service completed"
165+
137166
# This is a oneshot service - tell s6 to stop supervising and sleep
138167
s6-svc -O /var/run/s6/services/70-register-setup
139168
exec sleep infinity

prosody/rootfs/etc/services.d/90-roster-setup/run

Lines changed: 0 additions & 77 deletions
This file was deleted.

0 commit comments

Comments
 (0)