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
30 lines
862 B
Bash
Executable File
30 lines
862 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# One-time setup: create the games user, install directory, and systemd unit.
|
|
# Run as root (or with sudo).
|
|
set -euo pipefail
|
|
|
|
if [[ $EUID -ne 0 ]]; then
|
|
echo "Run as root: sudo $0" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Create system user if it doesn't exist
|
|
if ! id -u games &>/dev/null; then
|
|
useradd --system --shell /usr/sbin/nologin --home-dir /opt/c4 --create-home games
|
|
echo "Created system user: games"
|
|
else
|
|
echo "User 'games' already exists"
|
|
fi
|
|
|
|
# Ensure install directory exists with correct ownership
|
|
install -d -o games -g games -m 755 /opt/c4
|
|
install -d -o games -g games -m 755 /opt/c4/data
|
|
|
|
# Install systemd unit
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
cp "$SCRIPT_DIR/c4.service" /etc/systemd/system/c4.service
|
|
systemctl daemon-reload
|
|
systemctl enable c4.service
|
|
|
|
echo "Setup complete. Run deploy.sh to build and start the service."
|