Fixing CS:GO auto-updater.

Fixing CS:GO auto-updater.

This fix will work on “vanilla” CS:GO, since this is not a problem with OpenGamePanel itself, but the main scripts used to boot CS:GO. I used OGP here because that’s what I use to host my servers.

Problem 1:

A CS:GO server requesting for restart, but waiting for hibernation or changelevel.

MasterRequestRestart
Your server is out of date and will be shutdown during hibernation or changelevel, whichever comes first.
Host state 4 at Thu Mar 7 10:49:43 2019
-- sv_shutdown live server, delaying request.

Fix:

Configure server to hibernate when empty.

sv_hibernate_when_empty 1

Problem 2.1:

After entering hibernation, the server will close, printing lots of errors similar to this:

File /home/ogpbot/OGP_User_Files/68/csgo/pak01_094.vpk was never closed

This is not a problem itself, but may mask the real problem. The server will restart normally and it will not be updated.

Inspecting the screen logs:

Server will auto-restart if there is a crash.
----------------------------
Updating server using Steam.
----------------------------
./srcds_run: 1: eval: ./steam.sh: not found

Before starting the binaries themselves, srcds_run will attempt to run a script called ./steam.sh, this is caused by the following code at line 296 inside srcds_run

if test -d "$STEAM_DIR"; then
    echo "Updating server using Steam."
    echo "----------------------------"
    OLDWD=$(pwd)
    eval "cd $STEAM_DIR"
    eval "STEAMEXE=steamcmd ./steam.sh +runscript $STEAMCMD_SCRIPT"
    eval "cd $OLDWD"
    echo "----------------------------"
else

This block of code is executed when $STEAM_DIR is defined by using the -steam_dir command. OpenGamePanel does this by default. This can be seen seconds before the server boots up, on the Dashboard before being redirected to the console:

-game csgo 
-console 
-usercon 
+ip 123.123.123.123 
-port 27001 
+clientport 27101 
-maxplayers_override 16 
-pidfile ogp_game_startup.pid 
+map "de_mirage" 
+sv_setsteamaccount "xxx" 
-autoupdate 
-steam_dir {OGP_STEAM_CMD_DIR} 
-steamcmd_script {STEAMCMD_INSTALL_FILE}  

Problem 2.2

We figured out that we have a missing file, but where? We can find out the value of those placeholders by checking the arguments of a running server with the following command:

ps -aux | grep 'srcds_run'

Which outputs:

ogpbot   28273  0.0  0.0   4504  1712 pts/0    S+   11:20   0:00 /bin/sh ./srcds_run -game csgo -console -usercon +ip 123.123.123.123 -port 27001 -maxplayers_override 16 -pidfile ogp_game_startup.pid +map de_mirage -autoupdate -steam_dir /home/ogpbot/OGP/steamcmd -steamcmd_script 000000068_install.txt

Here it is:

-autoupdate 
-steam_dir /home/ogpbot/OGP/steamcmd
-steamcmd_script 000000068_install.txt

As you can see, steamcmd.sh exists, but there is no steam.sh. After lots of lots of time spent trying to figure out what the srcds_run scripts is doing, I reached the conclusion that it’s trying to access steamcmd.sh and somehow it’s typed wrong.

At this point I’m trying to understand my line of thoughts when I managed to fix this, but I really can’t seem to understand what I figured out.

Fix and TL;DR:

After debugging every variable possible, I managed to fix the problem creating a file called steam.sh on /home/ogpbot/OGP/ with the following script:

!/bin/sh
eval "STEAMEXE=steamcmd ./steamcmd.sh +runscript $2"

This script is basically the same thing that you see inside srcds_run but with the correct file name. What the previous script was trying to do, is set the STEAMEXE environment variable to steamcmd then execute ./steamcmd.sh passing 2 parameters +runscript and what was inside $STEAMCMD_SCRIPT.

Since steam.sh didn’t exist, I created the script (so I don’t have to edit the default srcds_run file, that will “forward” the call to ./steamcmd.sh. That why it’s almost exactly the same: setting the same variable, running the CORRECT script, and just “forwarding” the second parameter it received $STEAMCMD_SCRIPT ($s was the first find that came to mind at the same, and replacing it with $STEAMCMD_SCRIPT should also work the same, since the variables are also passed to the called script.

Conclusion

After redirecting the call to the missing script, every time your servers starts, it will check for updates and general missing files as expected. This will cause servers to take a bit longer to completely boot depending on how fast your server disks are.

 

Leave a Reply

Your email address will not be published. Required fields are marked *