From 578ea18e6bd2c664dce878f5644f41a1f62ccf03 Mon Sep 17 00:00:00 2001 From: APAW Agent Sync Date: Thu, 14 May 2026 09:29:53 +0100 Subject: [PATCH] fix(deploy): auto-create static symlinks in sync script Previously git reset removed symlinks (css, js, images, uploads) which caused Nginx to return 404 for static assets. Now deploy() recreates them after git sync. Refs: production server, admin panel 404 fix --- scripts/sync-production.sh | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/scripts/sync-production.sh b/scripts/sync-production.sh index 90f8983..bd6d09c 100644 --- a/scripts/sync-production.sh +++ b/scripts/sync-production.sh @@ -66,27 +66,23 @@ deploy() { "${BUN}" install --production # Fix permissions + echo "Fixing permissions..." chown -R nero:nero "$PROJECT_DIR" chmod 600 "$PROJECT_DIR/.env" find "$PROJECT_DIR" -type f -not -path '*/node_modules/*' -exec chmod 644 {} \; find "$PROJECT_DIR" -type d -exec chmod 755 {} \; - chmod 644 "$PROJECT_DIR/data/tenerifeprop.db" 2>/dev/null || true - - # Restart - echo "=== Restarting $SERVICE ===" - systemctl restart "$SERVICE" - - # Healthcheck - sleep 2 - HTTP_CODE=$(curl -s -o /dev/null -w '%{http_code}' http://localhost:3003/api/settings) - if [ "$HTTP_CODE" = "200" ]; then - echo "✅ Deploy successful. Healthcheck: HTTP 200" - # Tag the deploy - git tag "deploy-$(date +%Y%m%d-%H%M%S)" || true - else - echo "❌ Deploy failed. Healthcheck: HTTP $HTTP_CODE" - echo "Check logs: journalctl -u $SERVICE --no-pager -n 50" - exit 1 + + # Create static symlinks (Nginx expects /css, /js, /images at root) + echo "Creating static symlinks..." + cd "$PROJECT_DIR" + ln -sf public/css css 2>/dev/null || true + ln -sf public/js js 2>/dev/null || true + ln -sf public/images images 2>/dev/null || true + ln -sf public/uploads uploads 2>/dev/null || true + chown -h nero:nero css js images uploads 2>/dev/null || true + + if [ -f "$PROJECT_DIR/data/tenerifeprop.db" ]; then + chmod 644 "$PROJECT_DIR/data/tenerifeprop.db" fi echo "=== Deploy completed at $(date) ==="