#!/bin/bash # ดึงไฟล์จาก /var/www/html เข้า repo www/html หลังอัปโหลด/แก้บนเซิร์ฟ — ให้ git ใน repo ตรงกับของจริง # ย้อนกับ deploy-www.sh (exclude ชุดเดียวกัน; ไม่ใช้ --delete เพื่อไม่ลบไฟล์ที่มีแค่ใน repo) set -euo pipefail REPO="$(cd "$(dirname "$0")/.." && pwd)" DST="/var/www/html/" SRC="$REPO/www/html/" if [[ "$(id -u)" -ne 0 ]]; then echo "Run as root: sudo $0" >&2 exit 1 fi rsync -a --checksum \ --exclude 'node_modules' \ --exclude '**/node_modules/**' \ --exclude 'Game/data/maps/' \ --exclude 'Game/data/game-timing.json' \ "$DST" "$SRC" if [[ -n "${SUDO_UID:-}" ]]; then chown -R "$SUDO_UID:$SUDO_GID" "$SRC" fi echo "OK: pulled $DST -> $SRC (no --delete; excludes match deploy-www.sh)"