@@ -88,26 +88,43 @@ install_cs2() {
8888}
8989
9090ensure_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
135165start_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
165202cleanup () {
0 commit comments