fix(prosody): Fix creating users.
Use env var for prosody port and move roster after user creation to guarantee the order.
This commit is contained in:
@@ -4,11 +4,12 @@ echo "[register-setup] Service starting..."
|
|||||||
|
|
||||||
# Wait for prosody to be ready
|
# Wait for prosody to be ready
|
||||||
echo "[register-setup] Waiting for prosody to be ready..."
|
echo "[register-setup] Waiting for prosody to be ready..."
|
||||||
|
[ -z "$PROSODY_HTTP_PORT" ] && PROSODY_HTTP_PORT="5280"
|
||||||
MAX_ATTEMPTS=60
|
MAX_ATTEMPTS=60
|
||||||
ATTEMPT=0
|
ATTEMPT=0
|
||||||
|
|
||||||
while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do
|
while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do
|
||||||
if curl --fail --silent --output /dev/null http://127.0.0.1:5280/health 2>&1; then
|
if curl --fail --silent --output /dev/null http://127.0.0.1:${PROSODY_HTTP_PORT}/health 2>&1; then
|
||||||
echo "[register-setup] Prosody is ready!"
|
echo "[register-setup] Prosody is ready!"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
@@ -133,7 +134,35 @@ if [[ ! -z $JIGASI_XMPP_PASSWORD ]]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "[register-setup] All users registered, service completed"
|
# Capture both stdout and stderr
|
||||||
|
OUTPUT=$(prosodyctl --config $PROSODY_CFG shell roster subscribe_both focus@$XMPP_AUTH_DOMAIN focus.$XMPP_DOMAIN 2>&1)
|
||||||
|
RESULT=$?
|
||||||
|
|
||||||
|
echo "[register-setup] Roster command output:"
|
||||||
|
echo "$OUTPUT"
|
||||||
|
|
||||||
|
if [ $RESULT -eq 0 ]; then
|
||||||
|
echo "[register-setup] Roster subscription completed successfully"
|
||||||
|
|
||||||
|
# Reload mod_client_proxy module to apply roster changes
|
||||||
|
echo "[register-setup] Reloading client_proxy module..."
|
||||||
|
RELOAD_OUTPUT=$(prosodyctl --config $PROSODY_CFG shell module reload client_proxy 2>&1)
|
||||||
|
RELOAD_RESULT=$?
|
||||||
|
|
||||||
|
echo "[register-setup] Module reload output:"
|
||||||
|
echo "$RELOAD_OUTPUT"
|
||||||
|
|
||||||
|
if [ $RELOAD_RESULT -eq 0 ]; then
|
||||||
|
echo "[register-setup] Module reloaded successfully"
|
||||||
|
else
|
||||||
|
echo "[register-setup] WARNING: Failed to reload module (exit code: $RELOAD_RESULT)"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "[register-setup] ERROR: Failed to setup roster subscription (exit code: $RESULT)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "[register-setup] All users registered and roster modified, service completed"
|
||||||
|
|
||||||
# This is a oneshot service - tell s6 to stop supervising and sleep
|
# This is a oneshot service - tell s6 to stop supervising and sleep
|
||||||
s6-svc -O /var/run/s6/services/70-register-setup
|
s6-svc -O /var/run/s6/services/70-register-setup
|
||||||
exec sleep infinity
|
exec sleep infinity
|
||||||
|
|||||||
@@ -1,77 +0,0 @@
|
|||||||
#!/usr/bin/with-contenv bash
|
|
||||||
|
|
||||||
echo "[roster-setup] Service starting..."
|
|
||||||
|
|
||||||
# Default to client mode if not set (matching init script behavior)
|
|
||||||
[ -z "$PROSODY_MODE" ] && PROSODY_MODE="client"
|
|
||||||
|
|
||||||
# Only run in client mode
|
|
||||||
if [[ "$PROSODY_MODE" != "client" ]]; then
|
|
||||||
echo "[roster-setup] Not in client mode (PROSODY_MODE=$PROSODY_MODE), exiting..."
|
|
||||||
s6-svc -O /var/run/s6/services/90-roster-setup
|
|
||||||
exec sleep infinity
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "[roster-setup] Running in client mode, proceeding with roster setup"
|
|
||||||
|
|
||||||
# Wait for prosody to be ready
|
|
||||||
echo "[roster-setup] Waiting for prosody to be ready..."
|
|
||||||
MAX_ATTEMPTS=60
|
|
||||||
ATTEMPT=0
|
|
||||||
|
|
||||||
while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do
|
|
||||||
if curl --fail --silent --output /dev/null http://127.0.0.1:5280/health 2>&1; then
|
|
||||||
echo "[roster-setup] Prosody is ready!"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
ATTEMPT=$((ATTEMPT + 1))
|
|
||||||
echo "[roster-setup] Attempt $ATTEMPT/$MAX_ATTEMPTS..."
|
|
||||||
sleep 2
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ $ATTEMPT -eq $MAX_ATTEMPTS ]; then
|
|
||||||
echo "[roster-setup] ERROR: Prosody did not become ready in time"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Set defaults for XMPP domains (matching init script)
|
|
||||||
[ -z "${XMPP_DOMAIN}" ] && XMPP_DOMAIN=meet.jitsi
|
|
||||||
[ -z "${XMPP_AUTH_DOMAIN}" ] && XMPP_AUTH_DOMAIN=auth.meet.jitsi
|
|
||||||
|
|
||||||
# Subscribe the focus user to the focus component proxy using prosodyctl shell
|
|
||||||
echo "[roster-setup] Setting up roster subscription..."
|
|
||||||
echo "[roster-setup] Command: prosodyctl shell roster subscribe_both focus@$XMPP_AUTH_DOMAIN focus.$XMPP_DOMAIN"
|
|
||||||
PROSODY_CFG="/config/prosody.cfg.lua"
|
|
||||||
|
|
||||||
# Capture both stdout and stderr
|
|
||||||
OUTPUT=$(prosodyctl --config $PROSODY_CFG shell roster subscribe_both focus@$XMPP_AUTH_DOMAIN focus.$XMPP_DOMAIN 2>&1)
|
|
||||||
RESULT=$?
|
|
||||||
|
|
||||||
echo "[roster-setup] Command output:"
|
|
||||||
echo "$OUTPUT"
|
|
||||||
|
|
||||||
if [ $RESULT -eq 0 ]; then
|
|
||||||
echo "[roster-setup] Roster subscription completed successfully"
|
|
||||||
|
|
||||||
# Reload mod_client_proxy module to apply roster changes
|
|
||||||
echo "[roster-setup] Reloading client_proxy module..."
|
|
||||||
RELOAD_OUTPUT=$(prosodyctl --config $PROSODY_CFG shell module reload client_proxy 2>&1)
|
|
||||||
RELOAD_RESULT=$?
|
|
||||||
|
|
||||||
echo "[roster-setup] Module reload output:"
|
|
||||||
echo "$RELOAD_OUTPUT"
|
|
||||||
|
|
||||||
if [ $RELOAD_RESULT -eq 0 ]; then
|
|
||||||
echo "[roster-setup] Module reloaded successfully"
|
|
||||||
else
|
|
||||||
echo "[roster-setup] WARNING: Failed to reload module (exit code: $RELOAD_RESULT)"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "[roster-setup] ERROR: Failed to setup roster subscription (exit code: $RESULT)"
|
|
||||||
echo "[roster-setup] This is a oneshot service, will sleep to prevent restart loop"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "[roster-setup] Oneshot service completed, sleeping..."
|
|
||||||
# This is a oneshot service - tell s6 to stop supervising and sleep
|
|
||||||
s6-svc -O /var/run/s6/services/90-roster-setup
|
|
||||||
exec sleep infinity
|
|
||||||
Reference in New Issue
Block a user