Files
ReSkate/contrib/setup-linux-server-libs.sh
T
juan 22ed651a88 Add setup-linux-server-libs.sh for Steam .so files
- fetches libsteam_api.so (SDK mirror) + steamclient/tier0/vstdlib
  via SteamCMD app 1007, links ~/.steam/sdk64, verifies exports
- fixes pipefail+grep -q SIGPIPE trap in the nm check
- README: document script as the primary path
2026-10-03 17:39:11 -03:00

101 lines
4.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# Steam shared libraries for the Linux ReSkateServer.
#
# Installs next to ReSkateServer:
# libsteam_api.so (Steamworks SDK redistributable_bin/linux64)
# steamclient.so, libtier0_s.so, libvstdlib_s.so (SteamCMD app 1007, SDK Redist)
# and links ~/.steam/sdk64/steamclient.so (where libsteam_api.so looks).
#
# Usage:
# ./setup-linux-server-libs.sh [--server-dir DIR] [--sdk-url URL] [--force] [--no-steamclient]
#
# Defaults:
# --server-dir: directory containing ReSkateServer (or current directory)
# --sdk-url: https://raw.githubusercontent.com/rlabrecque/SteamworksSDK/main/redistributable_bin/linux64/libsteam_api.so
# (public SDK mirror, Valve binaries; official source: partner.steamgames.com)
set -euo pipefail
SERVER_DIR=""
SDK_URL="https://raw.githubusercontent.com/rlabrecque/SteamworksSDK/main/redistributable_bin/linux64/libsteam_api.so"
FORCE=0
NO_STEAMCLIENT=0
while [ $# -gt 0 ]; do
case "$1" in
--server-dir) SERVER_DIR="${2:?missing DIR}"; shift 2 ;;
--sdk-url) SDK_URL="${2:?missing URL}"; shift 2 ;;
--force) FORCE=1; shift ;;
--no-steamclient) NO_STEAMCLIENT=1; shift ;;
-h|--help) sed -n '2,14p' "$0"; exit 0 ;;
*) if [ -z "$SERVER_DIR" ] && [ -d "$1" ]; then SERVER_DIR="$1"; shift
else echo "Unknown argument: $1" >&2; exit 2; fi ;;
esac
done
if [ -z "$SERVER_DIR" ]; then
if [ -x "./ReSkateServer" ]; then SERVER_DIR="."
else echo "error: give --server-dir DIR containing ReSkateServer" >&2; exit 2; fi
fi
SERVER_DIR="$(cd "$SERVER_DIR" && pwd)"
[ -x "$SERVER_DIR/ReSkateServer" ] || { echo "error: no ReSkateServer in $SERVER_DIR" >&2; exit 2; }
command -v curl >/dev/null || { echo "error: curl is required" >&2; exit 2; }
command -v tar >/dev/null || { echo "error: tar is required" >&2; exit 2; }
# 1. libsteam_api.so ---------------------------------------------------------
if [ -f "$SERVER_DIR/libsteam_api.so" ] && [ "$FORCE" -eq 0 ]; then
echo "libsteam_api.so already present, skipping (use --force to replace)."
else
echo "Downloading libsteam_api.so ..."
tmp="$(mktemp)"
curl -fSL --retry 3 -o "$tmp" "$SDK_URL"
if [ "$(wc -c <"$tmp")" -lt 100000 ]; then echo "error: download looks wrong ($(wc -c <"$tmp") bytes)" >&2; rm -f "$tmp"; exit 2; fi
if command -v nm >/dev/null && ! nm -D --defined-only "$tmp" 2>/dev/null | grep "SteamAPI_SteamGameServerNetworkingSockets_SteamAPI_v01" >/dev/null; then
echo "error: downloaded file has no game-server sockets export" >&2; rm -f "$tmp"; exit 2
fi
cp "$tmp" "$SERVER_DIR/libsteam_api.so"
chmod 644 "$SERVER_DIR/libsteam_api.so"
rm -f "$tmp"
echo "Installed $SERVER_DIR/libsteam_api.so"
fi
# 2. steamclient.so (+ tier0/vstdlib) ------------------------------------------
if [ "$NO_STEAMCLIENT" -eq 1 ]; then
echo "Skipping steamclient (--no-steamclient)."
elif [ -f "$SERVER_DIR/steamclient.so" ] && [ "$FORCE" -eq 0 ]; then
echo "steamclient.so already present, skipping (use --force to replace)."
else
work="$(mktemp -d)"
trap 'rm -rf "$work"' EXIT
echo "Fetching SteamCMD SDK Redist (app 1007) ..."
curl -fSL --retry 3 -o "$work/steamcmd.tar.gz" \
"https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz"
tar xzf "$work/steamcmd.tar.gz" -C "$work"
( cd "$work" && ./steamcmd.sh +@sSteamCmdForcePlatformType linux +login anonymous +app_update 1007 +quit )
if [ ! -f "$work/linux64/steamclient.so" ]; then echo "error: steamclient.so not downloaded" >&2; exit 2; fi
cp "$work/linux64/steamclient.so" "$SERVER_DIR/"
for extra in libtier0_s.so libvstdlib_s.so; do
[ -f "$work/linux64/$extra" ] && cp "$work/linux64/$extra" "$SERVER_DIR/"
done
chmod 644 "$SERVER_DIR/"*.so
rm -rf "$work"
trap - EXIT
echo "Installed steamclient.so (+ tier0/vstdlib if present)."
fi
# 3. sdk64 symlink (where libsteam_api.so looks) --------------------------------
if [ -f "$SERVER_DIR/steamclient.so" ]; then
mkdir -p "$HOME/.steam/sdk64"
ln -sf "$SERVER_DIR/steamclient.so" "$HOME/.steam/sdk64/steamclient.so"
echo "Linked ~/.steam/sdk64/steamclient.so"
fi
# 4. Verify ---------------------------------------------------------------------
echo "---"
ls -lh "$SERVER_DIR/ReSkateServer" "$SERVER_DIR/"*.so
if command -v nm >/dev/null; then
nm -D --defined-only "$SERVER_DIR/libsteam_api.so" 2>/dev/null \
| grep -o "SteamGameServerNetworkingSockets_SteamAPI_v[0-9]*" | sort -u | sed 's/^/sockets: /'
fi
echo "Done. Next: edit $SERVER_DIR/ReSkateServer.json (name, admins), then run $SERVER_DIR/ReSkateServer"