From 2fa272436e42d9d8722c1a59545c1d38e091ce2d Mon Sep 17 00:00:00 2001 From: Andreas Dueren Date: Mon, 16 Jun 2025 12:25:50 -0600 Subject: [PATCH] Fix homeserver domain configuration for existing configs --- start.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/start.sh b/start.sh index 53f8a21..6fe668a 100755 --- a/start.sh +++ b/start.sh @@ -76,6 +76,7 @@ EOF if [ -n "${CLOUDRON_APP_DOMAIN:-}" ]; then echo "=> Configuring homeserver and appservice settings" + # For whatsapp.matrix.as.ci -> matrix.as.ci and domain as.ci BASE_DOMAIN=$(echo "$CLOUDRON_APP_DOMAIN" | cut -d. -f2-) # Update homeserver configuration @@ -103,9 +104,9 @@ EOF echo " 5. Authenticate with WhatsApp using QR code scanning" else echo "=> Using existing configuration" - # Fix logging configuration in existing config if needed + # Fix configuration in existing config if needed if [ -f "$CONFIG_PATH" ]; then - # Check if config has problematic logging path and fix it + # Fix logging configuration if grep -q "filename.*logs/" "$CONFIG_PATH" 2>/dev/null || ! grep -q "/app/data/" "$CONFIG_PATH" 2>/dev/null; then echo "=> Fixing logging configuration in existing config" # Ensure logging goes to the writable /app/data directory @@ -114,6 +115,18 @@ else yq -i ".logging.handlers.console.format = \"json\"" "$CONFIG_PATH" 2>/dev/null || true yq -i ".logging.level = \"info\"" "$CONFIG_PATH" 2>/dev/null || true fi + + # Fix homeserver domain configuration + if [ -n "${CLOUDRON_APP_DOMAIN:-}" ]; then + BASE_DOMAIN=$(echo "$CLOUDRON_APP_DOMAIN" | cut -d. -f2-) + CURRENT_DOMAIN=$(yq -r ".homeserver.domain // empty" "$CONFIG_PATH" 2>/dev/null) + if [ "$CURRENT_DOMAIN" != "$BASE_DOMAIN" ] || [ -z "$CURRENT_DOMAIN" ]; then + echo "=> Fixing homeserver domain configuration" + yq -i ".homeserver.address = \"https://matrix.$BASE_DOMAIN\"" "$CONFIG_PATH" + yq -i ".homeserver.domain = \"$BASE_DOMAIN\"" "$CONFIG_PATH" + yq -i ".appservice.address = \"https://$CLOUDRON_APP_DOMAIN\"" "$CONFIG_PATH" + fi + fi fi fi