Provides install/update systemd workflow for git-based deploys to Ubuntu VPS. Co-authored-by: Cursor <[email protected]>
56 lines
1.4 KiB
Bash
Executable File
56 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
ENV_FILE="${REPO_DIR}/.env"
|
|
BINARY="${REPO_DIR}/bin/eden-room"
|
|
BANLIST="${REPO_DIR}/banlist.txt"
|
|
LOG_FILE="${REPO_DIR}/logs/eden-room.log"
|
|
|
|
if [[ ! -f "${ENV_FILE}" ]]; then
|
|
echo "Missing ${ENV_FILE}. Copy env.example to .env and configure it." >&2
|
|
exit 1
|
|
fi
|
|
|
|
# shellcheck source=/dev/null
|
|
source "${ENV_FILE}"
|
|
|
|
: "${ROOM_NAME:?ROOM_NAME is required in .env}"
|
|
: "${PREFERRED_GAME:?PREFERRED_GAME is required in .env}"
|
|
: "${PREFERRED_GAME_ID:?PREFERRED_GAME_ID is required in .env}"
|
|
: "${PORT:=24872}"
|
|
: "${MAX_MEMBERS:=8}"
|
|
: "${BIND_ADDRESS:=0.0.0.0}"
|
|
: "${WEB_API_URL:=https://api.ynet-fun.xyz}"
|
|
|
|
if [[ ! -x "${BINARY}" ]]; then
|
|
echo "Missing ${BINARY}. Run scripts/install.sh first." >&2
|
|
exit 1
|
|
fi
|
|
|
|
mkdir -p "${REPO_DIR}/logs"
|
|
|
|
ARGS=(
|
|
--room-name "${ROOM_NAME}"
|
|
--room-description "${ROOM_DESCRIPTION:-Smash Ultimate lobby}"
|
|
--preferred-game "${PREFERRED_GAME}"
|
|
--preferred-game-id "${PREFERRED_GAME_ID}"
|
|
--port "${PORT}"
|
|
--max-members "${MAX_MEMBERS}"
|
|
--bind-address "${BIND_ADDRESS}"
|
|
--ban-list-file "${BANLIST}"
|
|
--log-file "${LOG_FILE}"
|
|
)
|
|
|
|
if [[ -n "${PASSWORD:-}" ]]; then
|
|
ARGS+=(--password "${PASSWORD}")
|
|
fi
|
|
|
|
if [[ -n "${EDEN_TOKEN:-}" ]]; then
|
|
ARGS+=(--token "${EDEN_TOKEN}" --web-api-url "${WEB_API_URL}")
|
|
else
|
|
echo "Warning: EDEN_TOKEN is empty — hosting as unlisted/private room." >&2
|
|
fi
|
|
|
|
exec "${BINARY}" "${ARGS[@]}"
|