Fix read-only filesystem issues by improving logging config and working directory

This commit is contained in:
Andreas Dueren
2025-06-16 12:22:35 -06:00
parent 4118b49738
commit 89d86b3f57

View File

@ -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"