#!/usr/bin/env bash # Deploy the games binary to /opt/games, then restart the service. # Works from the repo (builds first) or from an extracted tarball (pre-built binary). set -euo pipefail ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)" INSTALL_DIR="/opt/games" BINARY="$ROOT_DIR/games" # If Go is available and we have source, build fresh if [[ -f "$ROOT_DIR/go.mod" ]] && command -v go &>/dev/null; then echo "Building CSS..." (cd "$ROOT_DIR" && go tool gotailwind -i assets/css/input.css -o assets/css/output.css --minify) echo "Building binary..." (cd "$ROOT_DIR" && CGO_ENABLED=0 go build -o games .) fi if [[ ! -f "$BINARY" ]]; then echo "ERROR: Binary not found at $BINARY" >&2 exit 1 fi echo "Installing to $INSTALL_DIR..." install -o games -g games -m 755 "$BINARY" "$INSTALL_DIR/games" echo "Restarting service..." systemctl restart games.service echo "Done. Status:" systemctl status games.service --no-pager