Skip to content

Commit a24d0f4

Browse files
committed
#build
1 parent ea1fa6c commit a24d0f4

5 files changed

Lines changed: 95 additions & 31 deletions

File tree

Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ ENV NVIDIA_DRIVER_CAPABILITIES=all
66
ENV NVIDIA_VISIBLE_DEVICES=all
77
ENV DISPLAY=:0
88
ENV HOME=/root
9+
# Silence GTK accessibility-bus lookup so Steam's zenity dialogs don't
10+
# deadlock when a11y isn't available in a headless container.
11+
ENV GTK_A11Y=none
12+
ENV NO_AT_BRIDGE=1
913

1014
RUN apt-get update && apt-get install -y --no-install-recommends \
1115
software-properties-common \
@@ -68,6 +72,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
6872
libatk-bridge2.0-0t64 \
6973
libcups2t64 \
7074
libdbus-1-3 \
75+
dbus \
76+
dbus-x11 \
77+
zenity \
7178
libxkbcommon0 \
7279
libgbm1 \
7380
libcurl4t64 \

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,9 @@ docker run --rm --gpus all \
7575

7676

7777

78-
export MATCH_ID=8d3b87c5-cf7a-49b8-b49e-faca8ca0113a
79-
export 76.139.106.28:30037; password tv:user:QxPCZpx6q9cS0P2VzEAMMIkSCWOw0jTyvYaPFS2acjY=
78+
export MATCH_ID=8d3b87c5-cf7a-49b8-b49e-faca8ca0113a
79+
export CONNECT_ADDR=76.139.106.28:30037
80+
export CONNECT_PASSWORD='tv:user:QxPCZpx6q9cS0P2VzEAMMIkSCWOw0jTyvYaPFS2acjY='
81+
82+
export STEAM_USERNAME=cs2_servers
83+
export STEAM_PASSWORD=Gc2UYVgqHuWdHzugHWpQ

scripts/entrypoint.sh

Lines changed: 54 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -88,26 +88,43 @@ install_cs2() {
8888
}
8989

9090
ensure_steamclient() {
91-
# CS2 dlopens ~/.steam/sdk64/steamclient.so. Symlink whichever copy
92-
# steamcmd/steam bootstrapped into that well-known path. Idempotent.
91+
# CS2 dlopens ~/.steam/sdk64/steamclient.so. Point it at whichever copy
92+
# steamcmd/steam has bootstrapped. Idempotent.
9393
local link="$HOME/.steam/sdk64/steamclient.so"
94-
if [ -e "$link" ]; then return 0; fi
94+
if [ -L "$link" ] && [ -e "$link" ]; then return 0; fi
9595
mkdir -p "$(dirname "$link")"
96-
local sc
97-
sc=$(find "$HOME" -name 'steamclient.so' -path '*linux64*' 2>/dev/null | head -1)
96+
local sc=""
97+
# Check all the places steamcmd/steam might drop it.
98+
for d in \
99+
"$HOME/.local/share/Steam/linux64" \
100+
"$HOME/.steam/steam/linux64" \
101+
"$HOME/.steam/steamcmd/linux64" \
102+
"$HOME/Steam/linux64" \
103+
/root/.steam/steam/linux64; do
104+
if [ -f "$d/steamclient.so" ]; then sc="$d/steamclient.so"; break; fi
105+
done
98106
if [ -z "$sc" ]; then
99107
log "steamclient.so not found — bootstrapping steamcmd"
100108
steamcmd +quit >/dev/null 2>&1 || true
101-
sc=$(find "$HOME" -name 'steamclient.so' -path '*linux64*' 2>/dev/null | head -1)
109+
sc=$(find / -xdev -name 'steamclient.so' -path '*linux64*' 2>/dev/null | head -1)
102110
fi
103111
if [ -n "$sc" ]; then
104-
ln -sf "$sc" "$link"
112+
ln -sfn "$sc" "$link"
105113
log "linked steamclient.so: $sc -> $link"
106114
else
107-
log "WARN: could not locate steamclient.so; CS2 will crash on Steamworks init"
115+
log "WARN: could not locate steamclient.so; CS2 will fail Steamworks init"
108116
fi
109117
}
110118

119+
# Resolve the steam binary — Ubuntu's steam-installer puts it in /usr/games/steam.
120+
find_steam_bin() {
121+
command -v steam 2>/dev/null && return 0
122+
for p in /usr/games/steam /usr/bin/steam /usr/local/bin/steam; do
123+
[ -x "$p" ] && { echo "$p"; return 0; }
124+
done
125+
return 1
126+
}
127+
111128
# Persist the Steam session cache (config.vdf machine token, saved login)
112129
# to the hostPath. Only touch ~/.local/share/Steam — that's where Steam
113130
# actually stores persistent state. ~/.steam is mostly symlinks into it
@@ -118,6 +135,19 @@ persist_steam_state() {
118135
local target="$HOME/.local/share/Steam"
119136
mkdir -p "$persist"
120137

138+
# Legacy cleanup: an earlier version symlinked $HOME/.steam at
139+
# $persist/dot-steam, which shadowed the baked sdk64/steamclient.so.
140+
# Undo that if we see it.
141+
if [ -L "$HOME/.steam" ]; then
142+
local tgt
143+
tgt=$(readlink "$HOME/.steam" 2>/dev/null || true)
144+
if [[ "$tgt" == "$persist"* ]]; then
145+
log "removing legacy ~/.steam symlink ($tgt)"
146+
rm -f "$HOME/.steam"
147+
fi
148+
fi
149+
rm -rf "$persist/dot-steam" 2>/dev/null || true
150+
121151
# If target is a regular dir with real content (from a previous pod
122152
# that didn't symlink), migrate it once into the hostPath.
123153
if [ -d "$target" ] && [ ! -L "$target" ]; then
@@ -134,9 +164,8 @@ persist_steam_state() {
134164

135165
start_steam() {
136166
# Start the Steam client in the background so CS2's IPC pipe peer exists.
137-
# Silent / no UI. First-ever run needs STEAM_USERNAME + STEAM_PASSWORD +
138-
# a one-time interactive Steam Guard code confirmation; after that the
139-
# cached session is enough.
167+
# Silent / no UI. STEAM_USERNAME + STEAM_PASSWORD env vars required; the
168+
# account MUST have Steam Guard disabled for this to be fully non-interactive.
140169
if pgrep -x steam >/dev/null 2>&1; then
141170
log "steam already running"
142171
return 0
@@ -145,21 +174,29 @@ start_steam() {
145174
log "WARN: STEAM_USERNAME / STEAM_PASSWORD not set — CS2 will hit 'Steam not running'"
146175
return 0
147176
fi
148-
log "launching steam -silent -login $STEAM_USERNAME"
149-
nohup steam -silent -login "$STEAM_USERNAME" "$STEAM_PASSWORD" \
177+
local steam_bin
178+
steam_bin=$(find_steam_bin) || {
179+
log "WARN: steam binary not installed in image — install steam-installer in Dockerfile"
180+
return 1
181+
}
182+
183+
log "launching $steam_bin -silent -login $STEAM_USERNAME (via dbus-launch)"
184+
# dbus-launch gives steam a session bus (required by its zenity prompts
185+
# and the tray; without it steam exits early on startup).
186+
nohup dbus-launch --exit-with-session \
187+
"$steam_bin" -silent -login "$STEAM_USERNAME" "$STEAM_PASSWORD" \
150188
>/tmp/steam.log 2>&1 &
151189

152-
# Wait for the IPC pipe CS2 expects.
153-
for i in $(seq 1 60); do
190+
for i in $(seq 1 120); do
154191
if ls /tmp/steam_pipe_* >/dev/null 2>&1 || [ -S "$HOME/.steam/steam.pipe" ]; then
155192
log "steam IPC pipe is up (${i}s)"
156193
return 0
157194
fi
158195
sleep 1
159196
done
160-
log "WARN: steam IPC pipe never appeared — CS2 may still fail to connect"
197+
log "WARN: steam IPC pipe never appeared after 120s"
161198
log "--- /tmp/steam.log tail ---"
162-
tail -n 30 /tmp/steam.log >&2 || true
199+
tail -n 60 /tmp/steam.log >&2 || true
163200
}
164201

165202
cleanup() {

scripts/live.sh

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,22 @@ rm -f /tmp/source_engine_*.lock 2>/dev/null || true
6767
# Make sure the Steam client is running for CS2's IPC. No-op if already up.
6868
if ! pgrep -x steam >/dev/null 2>&1; then
6969
if [ -n "${STEAM_USERNAME:-}" ] && [ -n "${STEAM_PASSWORD:-}" ]; then
70-
log "starting steam -silent -login $STEAM_USERNAME"
71-
nohup steam -silent -login "$STEAM_USERNAME" "$STEAM_PASSWORD" \
72-
>/tmp/steam.log 2>&1 &
73-
for i in $(seq 1 60); do
74-
ls /tmp/steam_pipe_* >/dev/null 2>&1 && break
75-
sleep 1
70+
STEAM_BIN=""
71+
for p in "$(command -v steam 2>/dev/null)" /usr/games/steam /usr/bin/steam /usr/local/bin/steam; do
72+
[ -n "$p" ] && [ -x "$p" ] && { STEAM_BIN="$p"; break; }
7673
done
74+
if [ -n "$STEAM_BIN" ]; then
75+
log "starting $STEAM_BIN -silent -login $STEAM_USERNAME (via dbus-launch)"
76+
nohup dbus-launch --exit-with-session \
77+
"$STEAM_BIN" -silent -login "$STEAM_USERNAME" "$STEAM_PASSWORD" \
78+
>/tmp/steam.log 2>&1 &
79+
for i in $(seq 1 120); do
80+
ls /tmp/steam_pipe_* >/dev/null 2>&1 && break
81+
sleep 1
82+
done
83+
else
84+
log "WARN: steam binary not found — rebuild image with steam-installer"
85+
fi
7786
else
7887
log "WARN: no STEAM_USERNAME/STEAM_PASSWORD set — CS2 will fail IPC to Steam"
7988
fi

scripts/render.sh

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,20 @@ rm -f /tmp/source_engine_*.lock 2>/dev/null || true
4848

4949
if ! pgrep -x steam >/dev/null 2>&1; then
5050
if [ -n "${STEAM_USERNAME:-}" ] && [ -n "${STEAM_PASSWORD:-}" ]; then
51-
log "starting steam -silent -login $STEAM_USERNAME"
52-
nohup steam -silent -login "$STEAM_USERNAME" "$STEAM_PASSWORD" \
53-
>/tmp/steam.log 2>&1 &
54-
for i in $(seq 1 60); do
55-
ls /tmp/steam_pipe_* >/dev/null 2>&1 && break
56-
sleep 1
51+
STEAM_BIN=""
52+
for p in "$(command -v steam 2>/dev/null)" /usr/games/steam /usr/bin/steam /usr/local/bin/steam; do
53+
[ -n "$p" ] && [ -x "$p" ] && { STEAM_BIN="$p"; break; }
5754
done
55+
if [ -n "$STEAM_BIN" ]; then
56+
log "starting $STEAM_BIN -silent -login $STEAM_USERNAME (via dbus-launch)"
57+
nohup dbus-launch --exit-with-session \
58+
"$STEAM_BIN" -silent -login "$STEAM_USERNAME" "$STEAM_PASSWORD" \
59+
>/tmp/steam.log 2>&1 &
60+
for i in $(seq 1 120); do
61+
ls /tmp/steam_pipe_* >/dev/null 2>&1 && break
62+
sleep 1
63+
done
64+
fi
5865
fi
5966
fi
6067

0 commit comments

Comments
 (0)