diff --git a/start.sh b/start.sh index 5553875..53f8a21 100755 --- a/start.sh +++ b/start.sh @@ -45,8 +45,11 @@ bridge: logging: handlers: + console: + format: json file: filename: /app/data/mautrix-whatsapp.log + level: info EOF cat > "$REGISTRATION_PATH" << 'EOF' id: whatsapp @@ -100,6 +103,18 @@ EOF echo " 5. Authenticate with WhatsApp using QR code scanning" else echo "=> Using existing configuration" + # Fix logging configuration in existing config if needed + if [ -f "$CONFIG_PATH" ]; then + # Check if config has problematic logging path and fix it + 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 + yq -i ".logging.handlers.file.filename = \"/app/data/mautrix-whatsapp.log\"" "$CONFIG_PATH" 2>/dev/null || true + # Add console logging as well for debugging + 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 + fi fi # Final permission fix before starting @@ -112,6 +127,7 @@ if [ -f "/run/tls/tls.crt" ] && [ -f "/run/tls/tls.key" ]; then yq -i ".appservice.tls_key = \"/run/tls/tls.key\"" "$CONFIG_PATH" fi -# Start the bridge +# Start the bridge from the data directory to ensure relative paths work echo "=> Starting mautrix-whatsapp bridge" +cd /app/data exec gosu cloudron:cloudron /app/pkg/mautrix-whatsapp -c "$CONFIG_PATH" \ No newline at end of file