CSS animations for smoother 60fps feel despite 7Hz game ticks: - 130ms transitions on cell background/box-shadow - Head pop-in animation on direction changes - Food pulse animation - Smooth death state fade with grayscale Per-snake colored glow on head cells. Make server port configurable via PORT env var (default 8080). Add deploy/ with systemd service and scripts: - setup.sh: create games user, /opt/c4, install unit - deploy.sh: build and install binary, restart service - package.sh: cross-compile, tarball, base64 split for transfer - reassemble.sh: decode and extract on target server
88 lines
2.9 KiB
Bash
Executable File
88 lines
2.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Build the c4 binary, bundle it with deploy files into a tarball,
|
|
# base64-encode it, and split into 25MB chunks for transfer.
|
|
set -euo pipefail
|
|
|
|
REPO_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
|
cd "$REPO_DIR"
|
|
|
|
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
|
|
TARBALL="c4-deploy-${TIMESTAMP}.tar.gz"
|
|
BASE64_FILE="c4-deploy-${TIMESTAMP}_b64.txt"
|
|
|
|
#==============================================================================
|
|
# Clean previous artifacts
|
|
#==============================================================================
|
|
echo "--- Cleaning old artifacts ---"
|
|
rm -f ./c4 c4-deploy-*.tar.gz c4-deploy-*_b64*.txt
|
|
|
|
#==============================================================================
|
|
# Build
|
|
#==============================================================================
|
|
echo "--- Building CSS ---"
|
|
go tool gotailwind -i assets/css/input.css -o assets/css/output.css --minify
|
|
|
|
echo "--- Building binary (linux/amd64) ---"
|
|
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o c4 .
|
|
|
|
#==============================================================================
|
|
# Verify required files
|
|
#==============================================================================
|
|
echo "--- Verifying files ---"
|
|
REQUIRED_FILES=(
|
|
c4
|
|
deploy/setup.sh
|
|
deploy/deploy.sh
|
|
deploy/reassemble.sh
|
|
deploy/c4.service
|
|
)
|
|
for f in "${REQUIRED_FILES[@]}"; do
|
|
if [[ ! -f "$f" ]]; then
|
|
echo "ERROR: Missing required file: $f" >&2
|
|
exit 1
|
|
fi
|
|
echo " OK $f"
|
|
done
|
|
|
|
#==============================================================================
|
|
# Create tarball
|
|
#==============================================================================
|
|
echo "--- Creating tarball ---"
|
|
tar -czf "/tmp/${TARBALL}" --transform 's,^,c4/,' \
|
|
c4 \
|
|
deploy/setup.sh \
|
|
deploy/deploy.sh \
|
|
deploy/reassemble.sh \
|
|
deploy/c4.service
|
|
|
|
mv "/tmp/${TARBALL}" .
|
|
echo " -> ${TARBALL} ($(du -h "${TARBALL}" | cut -f1))"
|
|
|
|
#==============================================================================
|
|
# Base64 encode and split
|
|
#==============================================================================
|
|
echo "--- Base64 encoding ---"
|
|
base64 "${TARBALL}" > "${BASE64_FILE}"
|
|
echo " -> ${BASE64_FILE} ($(du -h "${BASE64_FILE}" | cut -f1))"
|
|
|
|
echo "--- Splitting into 25MB chunks ---"
|
|
split -b 25M -d --additional-suffix=.txt "${BASE64_FILE}" "c4-deploy-${TIMESTAMP}_b64_part"
|
|
rm -f "${BASE64_FILE}"
|
|
|
|
CHUNKS=(c4-deploy-${TIMESTAMP}_b64_part*.txt)
|
|
echo " -> ${#CHUNKS[@]} chunk(s):"
|
|
for chunk in "${CHUNKS[@]}"; do
|
|
echo " $chunk ($(du -h "$chunk" | cut -f1))"
|
|
done
|
|
|
|
#==============================================================================
|
|
# Done
|
|
#==============================================================================
|
|
echo ""
|
|
echo "=== Package Complete ==="
|
|
echo ""
|
|
echo "Transfer the chunk files to the target server, then run:"
|
|
echo " ./reassemble.sh"
|
|
echo " cd ~/c4 && sudo ./deploy/setup.sh # first time only"
|
|
echo " cd ~/c4 && sudo ./deploy/deploy.sh"
|