#!/usr/bin/env bash set -euo pipefail SERVER_NAME="${1:-play.agrariangame.com}" GAME_PORT="${AGRARIAN_GAME_PORT:-7777}" INSTALL_DIR="${AGRARIAN_INSTALL_DIR:-/opt/agrarian/server}" SERVICE_USER="${AGRARIAN_SERVICE_USER:-agrarian}" MAP_NAME="${AGRARIAN_MAP_NAME:-L_GroundZeroTerrain_Test?listen}" SERVER_BINARY="${AGRARIAN_SERVER_BINARY:-AgrarianGameServer}" log() { printf '[agrarian-game-server] %s\n' "$*" } if [[ "${EUID}" -ne 0 ]]; then printf 'Run as root or with sudo.\n' >&2 exit 1 fi log "Preparing Ubuntu host for ${SERVER_NAME} on udp/${GAME_PORT}." export DEBIAN_FRONTEND=noninteractive apt-get update apt-get install -y ca-certificates curl rsync tar unzip ufw if ! id "${SERVICE_USER}" >/dev/null 2>&1; then useradd --system --home-dir "${INSTALL_DIR}" --create-home --shell /usr/sbin/nologin "${SERVICE_USER}" fi install -d -o "${SERVICE_USER}" -g "${SERVICE_USER}" "${INSTALL_DIR}" install -d -o "${SERVICE_USER}" -g "${SERVICE_USER}" /var/log/agrarian cat >/etc/systemd/system/agrarian-game-server.service </dev/null 2>&1; then ufw allow "${GAME_PORT}/udp" comment "Agrarian gameplay server" fi cat >"${INSTALL_DIR}/DEPLOY_README.txt" <