repositories / bugabinga.net
bugabinga.net
personal infrastructure for bugabinga!
owned by admin
scripts/local/deploy-valheim-relay.sh
Raw#!/usr/bin/env bash
set -euo pipefail
[[ "$#" -eq 2 ]] || {
echo "usage: deploy-valheim-relay.sh HOST SSH_PORT" >&2
exit 2
}
host="$1"
port="$2"
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
scratch_dir=/var/tmp/pufferpanel-fork/valheim-ingress-relay
mkdir -p "$scratch_dir"
local_stage="$(mktemp "${scratch_dir}/valheim-relay.nft.XXXXXX")"
remote_stage="/var/tmp/bugabinga-valheim.nft.$$"
[[ "$port" =~ ^[0-9]+$ && -n "${VALHEIM_RELAY_FRAGMENT:-}" ]] || {
echo "invalid Valheim relay deployment input" >&2
exit 2
}
printf '%s\n' "$VALHEIM_RELAY_FRAGMENT" >"$local_stage"
trap 'rm -f "${local_stage}"; ssh -p "${port}" "root@${host}" "rm -f ${remote_stage}" >/dev/null 2>&1 || true' EXIT
scp -P "$port" "$local_stage" "root@${host}:${remote_stage}"
ssh -p "$port" "root@${host}" 'bash -s' -- "$remote_stage" <"${repo_root}/scripts/remote/apply-valheim-relay.sh"