minigame 6 players position

This commit is contained in:
2026-04-28 08:32:48 +00:00
parent 0804411851
commit eb29e5636e
34 changed files with 2767 additions and 109 deletions
+1
View File
@@ -6,3 +6,4 @@ install -o root -g root -m 644 "$SRC" "$DST"
nginx -t
systemctl reload nginx
echo "OK: deployed $SRC -> $DST and nginx reloaded."
echo "Tip: ถ้า POST อัปโหลดรูปผ่าน Admin API ยังว่าง body — ตั้ง PHP-FPM post_max_size ≥20M (เช่น pool www.conf) · If uploads still fail, raise PHP post_max_size to match nginx 20M."
+7
View File
@@ -1,5 +1,6 @@
#!/bin/bash
# Deploy tracked web files from repo -> /var/www/html (ไม่ลบ node_modules บนเซิร์ฟเวอร์)
# ใช้ทุกครั้งหลังแก้ www/html ใน repo แล้วต้องการให้เว็บจริงตรงกับ repo
set -euo pipefail
REPO="$(cd "$(dirname "$0")/.." && pwd)"
SRC="$REPO/www/html/"
@@ -9,7 +10,13 @@ if [[ "$(id -u)" -ne 0 ]]; then
exit 1
fi
rsync -a \
--checksum \
--exclude 'node_modules' \
"$SRC" "$DST"
chown -R www-data:www-data "$DST"
# รูปป้าย quiz_carry — ให้เขียน/ลบได้ชัดเจน (FTP/Node); setgid ให้ไฟล์ใหม่ได้กลุ่ม www-data
PLAQUE="$DST/Game/public/img/quiz-carry-plaque-assets"
mkdir -p "$PLAQUE"
chown www-data:www-data "$PLAQUE"
chmod 2775 "$PLAQUE"
echo "OK: deployed $SRC -> $DST (node_modules on server untouched)"
+40
View File
@@ -0,0 +1,40 @@
#!/bin/bash
# ตั้งค่าโฟลเดอร์อัปโหลดรูปป้าย quiz_carry ให้ Node (www-data) อ่าน/เขียน/ลบได้
# และ (ถ้าตั้งค่า) ให้บัญชี FTP เขียนได้ด้วย ACL
#
# Usage:
# sudo bash scripts/fix-quiz-carry-plaque-assets-permissions.sh
# sudo WEBROOT=/var/www/html OWNER=www-data GROUP=www-data bash scripts/fix-quiz-carry-plaque-assets-permissions.sh
# sudo FTP_USER=yourftpuser bash scripts/fix-quiz-carry-plaque-assets-permissions.sh # ต้องมี package acl
#
# English: Ensures Game/public/img/quiz-carry-plaque-assets is writable by the game (www-data).
# Optional FTP_USER: setfacl so that Linux user can STOR/delete via FTP without 553.
set -euo pipefail
WEBROOT="${WEBROOT:-/var/www/html}"
OWNER="${OWNER:-www-data}"
GROUP="${GROUP:-www-data}"
DIR="$WEBROOT/Game/public/img/quiz-carry-plaque-assets"
if [[ "$(id -u)" -ne 0 ]]; then
echo "Run as root: sudo $0" >&2
exit 1
fi
mkdir -p "$DIR"
chown "$OWNER:$GROUP" "$DIR"
# rwxrwxr-x + setgid: ไฟล์ใหม่ได้กลุ่มเดียวกับโฟลเดอร์ (เหมาะถ้า FTP user อยู่กลุ่ม www-data)
chmod 2775 "$DIR"
if [[ -n "${FTP_USER:-}" ]]; then
if command -v setfacl >/dev/null 2>&1; then
setfacl -m "u:${FTP_USER}:rwx" "$DIR"
setfacl -d -m "u:${FTP_USER}:rwx" "$DIR"
echo "ACL: user ${FTP_USER} has rwx on $DIR (default ACL for new files)."
else
echo "WARN: FTP_USER set but setfacl not installed. Install acl package or run: usermod -aG ${GROUP} ${FTP_USER}" >&2
fi
fi
echo "OK: $DIR"
ls -ldn "$DIR"
+20
View File
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
# ทดสอบ POST /Game/api/quiz-carry-plaque-upload ที่ Node (ไม่ผ่าน PHP) — หลัง deploy รันบนเซิร์ฟ: bash scripts/test-plaque-upload-node.sh
set -euo pipefail
PORT="${GAME_NODE_PORT:-3001}"
PNG_B64='iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg=='
BODY=$(printf '%s' "{\"imageDataUrl\":\"data:image/png;base64,${PNG_B64}\"}")
code=$(curl -sS -o /tmp/plaque-up.json -w '%{http_code}' -X POST "http://127.0.0.1:${PORT}/Game/api/quiz-carry-plaque-upload" \
-H 'Content-Type: application/json' --data-binary "$BODY" || true)
echo "HTTP $code"
cat /tmp/plaque-up.json
echo
if [[ "$code" != "200" ]]; then
echo "FAIL: expected 200" >&2
exit 1
fi
if ! grep -q '"ok":true' /tmp/plaque-up.json; then
echo "FAIL: expected ok:true in JSON" >&2
exit 1
fi
echo "OK: Node plaque upload accepts minimal PNG"