kus / cs2-modded-server

Modded Counter Strike 2 (CS2) Dedicated Server with Metamod and CounterStrikeSharp for Windows and Linux that can automatically be setup on Google Cloud.
GNU Lesser General Public License v3.0
359 stars 73 forks source link

[Bug]: U #26

Closed escaparrac closed 11 months ago

escaparrac commented 11 months ago

Server is up to date

I've followed the instructions

Game Server Login Token

Operating System

Linux Ubuntu 22.04

Which mod are you playing

No mod

Are you trying to host online or on LAN?

Online off a machine on my local network

Metamod:Source Version

none

Metamod:Source Plugins loaded

none

CounterStrikeSharp Version

none

CounterStrikeSharp Plugins loaded

none

What is the bug

on clean ubuntu install server won't start and several errors can be seen in the shell.

Game console output

No response

Server log output

Updating Operating System...
Obj:1 http://es.archive.ubuntu.com/ubuntu jammy InRelease
Obj:2 http://es.archive.ubuntu.com/ubuntu jammy-updates InRelease
Obj:3 http://es.archive.ubuntu.com/ubuntu jammy-backports InRelease
Obj:4 http://es.archive.ubuntu.com/ubuntu jammy-security InRelease
Leyendo lista de paquetes...
Adding i386 architecture...
Installing required packages for Ubuntu 22.04...
Checking steam user exists...
Checking steamcmd exists...
Downloading any updates for CS2...
WARNING: setlocale('en_US.UTF-8') failed, using locale: 'C'. International characters may not work.
Redirecting stderr to '/home/steam/Steam/logs/stderr.txt'
Logging directory: '/home/steam/Steam/logs'
[  0%] Checking for available updates...
[----] Verifying installation...
Steam Console Client (c) Valve Corporation - version 1700160359
-- type 'quit' to exit --
Loading Steam API...dlmopen steamservice.so failed: steamservice.so: cannot open shared object file: No such file or directory
OK

Connecting anonymously to Steam Public...OK
Waiting for client config...OK
Waiting for user info...OK
 Update state (0x5) verifying install, progress: 39.09 (13874042090 / 35491303349)
Error! App '730' state is 0x202 after update job.
ln: failed to create symbolic link '/root/.steam/sdk32/steamclient.so': File exists
ln: failed to create symbolic link '/root/.steam/sdk64/steamclient.so': File exists
ln: failed to create symbolic link '/home/steam/.steam/sdk32/steamclient.so': File exists
ln: failed to create symbolic link '/home/steam/.steam/sdk64/steamclient.so': File exists
rm: cannot remove '/home/steam/cs2/bin/libgcc_s.so.1': No such file or directory
Downloading mod files...
Dynamically writing /home/steam/cs2/game/csgo/cfg/secrets.cfg
Merging in custom files from custom_files
grep: game/csgo/gameinfo.gi: No such file or directory
awk: fatal: cannot open file `game/csgo/gameinfo.gi' for reading: No such file or directory
game/csgo/gameinfo.gi successfully patched for Metamod.
MySQL is already installed.
Starting server on xxx.xxx.xxx.xxx:
sudo: ./game/bin/linuxsteamrt64/cs2: command not found

Steps to reproduce

  1. Clean ubuntu server install
  2. access as root + add the env + install
    sudo su
    export RCON_PASSWORD="changeme"
    export API_KEY="changeme"
    export STEAM_ACCOUNT=""
    export MOD_URL="https://github.com/kus/cs2-modded-server/archive/master.zip"
    export SERVER_PASSWORD=""
    export PORT="27015"
    export TICKRATE="128"
    export MAXPLAYERS="32"
    cd / && curl --silent --output "install.sh" "https://raw.githubusercontent.com/kus/cs2-modded-server/master/install.sh" && chmod +x install.sh && bash install.sh
  3. console throws errors. Can't install again. stop.sh -> kill: (5341): No such process
kus commented 11 months ago

The CS2 server isn’t fully downloading from SteamCMD.

I’m pretty sure that error Error! App '730' state is 0x202 after update job. means you don’t have enough hard disk space.

How big is the HDD and how much free space do you have?

You want to have at least a 60Gb free space before installing.

escaparrac commented 11 months ago

Oh! It was written 40GB, so I gave it 42GB. Let me try with a bigger disk, then. Brb.

escaparrac commented 11 months ago

Ok. I managed to install it and access it through the game client, but RCON is not working.

If I RCON from the local network i get: "Unable to connect to the remote server" Tried to use CS2 GameServer Manager, but can't connect.

Is there any port that I should open?

ufw status

27015                      ALLOW       Anywhere
22                         ALLOW       Anywhere
27015:27020/tcp            ALLOW       Anywhere
27015:27020/udp            ALLOW       Anywhere
80/tcp                     ALLOW       Anywhere
27015 (v6)                 ALLOW       Anywhere (v6)
22 (v6)                    ALLOW       Anywhere (v6)
27015:27020/tcp (v6)       ALLOW       Anywhere (v6)
27015:27020/udp (v6)       ALLOW       Anywhere (v6)
80/tcp (v6)                ALLOW       Anywhere (v6)

Also, I saw that some options are not passing through. Max players should have been 32, and it's 64 in reality.

Adding the log here: loginstalsh.txt

kus commented 11 months ago

Thanks for picking up the 40GB, it was left over from the old CS:GO instructions. I have updated it.

Thanks for picking up the maxplayers issue, I have fixed that.

Rcon currently doesn't work when you are connected to the server.

You did try use a third party program which should work, I just tested it on my server and it works with a third party program.

The only ports you need to forward are 27015 TCP, 27015 UDP, 27020 UDP which you have, so I'm not sure what the issue is, are you sure the IP is correct?

You can use !rcon in chat if you set yourself up as an admin.

escaparrac commented 11 months ago

It just can't connect. I tried your suggested app, the one I used with other servers, and the game console. They're not working either.

Tried both local and remote ip. Ports are open in router too.

image image image

kus commented 11 months ago

So if you open up CS2 and don't connect to any servers, open console and enter:

rcon_address ip:port
rcon_password "password"
rcon say "hi"

This doesn't work?

If so, it's definately an issue on the machine it's running on.

What's the output of this command sudo lsof -i -P -n | head -n 1; sudo lsof -i -P -n | grep cs2

escaparrac commented 11 months ago

Console:

> rcon_address 192.168.1.155:27015
CSwapChainBase::QueuePresentAndWait() looped for 21 iterations without a present event.
CSwapChainBase::QueuePresentAndWait() looped for 21 iterations without a present event.
CSwapChainBase::QueuePresentAndWait() looped for 22 iterations without a present event.
> rcon_password XXXXXXXX
CSwapChainBase::QueuePresentAndWait() looped for 21 iterations without a present event.
CSwapChainBase::QueuePresentAndWait() looped for 21 iterations without a present event.
CSwapChainBase::QueuePresentAndWait() looped for 22 iterations without a present event.
> rcon say "hi"
Unable to connect to remote server (192.168.1.155:27015)

Your command:

ubuntu@cs2-ds:~$ sudo lsof -i -P -n | head -n 1; sudo lsof -i -P -n | grep cs2
[sudo] password for ubuntu:
COMMAND     PID            USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
cs2       13935           steam  305u  IPv4  43035      0t0  TCP 127.0.0.1:35129 (LISTEN)
cs2       13935           steam  316u  IPv4  43042      0t0  TCP 192.168.1.155:46037->2.16.8.184:80 (ESTABLISHED)
cs2       13935           steam  321u  IPv4  43044      0t0  TCP 192.168.1.155:47595->23.223.83.229:443 (ESTABLISHED)
cs2       13935           steam  322u  IPv6  42295      0t0  UDP *:27015
cs2       13935           steam  325u  IPv4  42296      0t0  TCP 127.0.1.1:27015 (LISTEN)
cs2       13935           steam  345u  IPv4  43050      0t0  TCP 192.168.1.155:33131->155.133.246.36:27038 (ESTABLISHED)

adding the "quit" log just in case that helps:

quit
CHostStateMgr::QueueNewRequest( Quitting, 3 )
HostStateRequest::Start(HSR_QUIT)
SV:  Server shutting down: NETWORK_DISCONNECT_EXITING (59)
CNetworkGameServerBase::SetServerState (ss_active -> ss_dead)
CSteam3ServerS1::ShutdownGameServer
CNetworkSystem::ShutdownGameServer
Closing 'server' UDP listen socket
Closing 'server' poll group
CNetworkSystem::CleanupDebugOutputFunction()
CSource2Server::GameServerSteamAPIDeactivated()
SV:  IGameSystem::LoopDeactivateAllSystems {
[S_API FAIL] Tried to access Steam interface SteamUtils010 before SteamAPI_Init succeeded.
HO:  IGameSystem::LoopDeactivateAllSystems {
HO:  } IGameSystem::LoopDeactivateAllSystems done
SV:  } IGameSystem::LoopDeactivateAllSystems done
SV: CNetworkStringTableContainer::RemoveAllTables:  removing 12 tables
CL: CNetworkStringTableContainer::RemoveAllTables:  removing 12 tables
SV:  CGameRulesGameSystem::GameShutdown uninstalled game rules
SV:  CGameRules::CGameRules destructed
Host activate: Quitting
Dispatching EventAppShutdown_t {
Requested non-existent write path USRLOCAL!
Requested non-existent write path USRLOCAL!
Error writing user config file 'cfg/cs2_user_keys_0_slot0.vcfg'
Requested non-existent write path USRLOCAL!
Error writing user config file 'cfg/cs2_user_convars_0_slot0.vcfg'
} Dispatched EventAppShutdown_t
MainLoop returning
Source2Shutdown
ShutdownSource2Logging
CNetworkSystem::Shutdown()
CNetworkSystem::CloseAllSockets()
Forgot to remove resource type manager for type vpost!
Forgot to remove resource type manager for type vpcf!
Forgot to remove resource type manager for type vsnap!
./install.sh: line 309: 13933 Segmentation fault      sudo -u $user ./game/bin/linuxsteamrt64/cs2 -dedicated -console -usercon -autoupdate -tickrate $TICKRATE -port $PORT +map de_dust2 -maxplayers_override $MAXPLAYERS -authkey $API_KEY +sv_setsteamaccount $STEAM_ACCOUNT +game_type 0 +game_mode 0 +mapgroup mg_active
kus commented 11 months ago

Wait you are setting this up as an online server right (not LAN)?

If you are using it as an online server you need to connect to it from it's public IP, not the lan IP.

In the install.sh script you should see a message Starting server on XXX.XXX.XXX.XXX:27015 use that IP to connect to it and use RCON.

kus commented 11 months ago

If connecting via the public IP doesn't work, is this running on bare metal or in a vm/container/docker?

escaparrac commented 11 months ago

Hi again!

The message in the console is:

Starting server on (x.x.x.x public IP):

*No port is written there

It's inside a Ubuntu 22.04 VM.

I can access the server with local or remote IP from game client and able to play.

P.S.: The 64-player thing is still happening.

kus commented 11 months ago

Did you download the latest install script?

kus commented 11 months ago

64 players is definitely fixed, you must be using an old install script.

In your log you posted me you had the port Starting server on 79.153.130.124:27015 that's from your log you uploaded.

Post me your whole server console from the point you run the install.sh script.

escaparrac commented 11 months ago

I'll try to sneak and reboot my VM, download the new script, paste the env variables again and start the server.

If not, I'll try to do it at night.

Would that be ok?

escaparrac commented 11 months ago

First time I executed the command:

[sudo] password for ubuntu:
root@cs2-ds:/home/ubuntu# export RCON_PASSWORD="XXXXXXXXX"
export API_KEY="XXXXXXXXXXXXXXXXXXXXXXXX"
export STEAM_ACCOUNT="XXXXXXXXXXXXXXXXXXXXXXXX"
export MOD_URL="https://github.com/kus/cs2-modded-server/archive/master.zip"
export SERVER_PASSWORD=""
export PORT="27015"
export TICKRATE="128"
export MAXPLAYERS="12"
cd / && curl --silent --output "install.sh" "https://raw.githubusercontent.com/kus/cs2-modded-server/master/install.sh" && chmod +x install.sh && bash install.sh
Updating Operating System...
Des:1 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
Obj:2 http://es.archive.ubuntu.com/ubuntu jammy InRelease
Des:3 http://es.archive.ubuntu.com/ubuntu jammy-updates InRelease [119 kB]
Des:4 http://security.ubuntu.com/ubuntu jammy-security/main amd64 Packages [991 kB]
Obj:5 http://es.archive.ubuntu.com/ubuntu jammy-backports InRelease
Des:6 http://es.archive.ubuntu.com/ubuntu jammy-updates/main i386 Packages [536 kB]
Des:7 http://security.ubuntu.com/ubuntu jammy-security/main i386 Packages [372 kB]
Des:8 http://es.archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages [1.200 kB]
Des:9 http://security.ubuntu.com/ubuntu jammy-security/main Translation-en [192 kB]
Des:10 http://security.ubuntu.com/ubuntu jammy-security/restricted amd64 Packages [1.147 kB]
Des:11 http://security.ubuntu.com/ubuntu jammy-security/restricted Translation-en [187 kB]
Des:12 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 Packages [799 kB]
Des:13 http://es.archive.ubuntu.com/ubuntu jammy-updates/restricted amd64 Packages [1.167 kB]
Des:14 http://security.ubuntu.com/ubuntu jammy-security/universe i386 Packages [567 kB]
Des:15 http://security.ubuntu.com/ubuntu jammy-security/universe Translation-en [148 kB]
Des:16 http://es.archive.ubuntu.com/ubuntu jammy-updates/restricted i386 Packages [32,8 kB]
Descargados 7.570 kB en 2s (3.986 kB/s)
Leyendo lista de paquetes...
Scanning processes...
Scanning candidates...
Scanning linux images...

Running kernel seems to be up-to-date.

Restarting services...

Had to press Enter to advance.

Here the rest of the console log. log2.txt

12 player OK :)

Ports are open image

No results, either by local or public ip (ip changed, just in case it doesn't match with that you saw before) image

The server runs correctly both locally and with remote ip or domain: image

RCON from console not working either. image

kus commented 11 months ago

Can you do something for me:

Now your CS2 is a standard CS2 installation, not modded.

Create a file /run.sh:

user="steam"
PUBLIC_IP=$(dig +short myip.opendns.com @resolver1.opendns.com)

echo "Downloading any updates for CS2..."
sudo -u $user /steamcmd/steamcmd.sh \
  +force_install_dir /home/${user}/cs2 \
  +login anonymous \
  +app_update 730 \
  +quit

cd /home/${user}/cs2

echo "Starting server on $PUBLIC_IP:$PORT"
sudo -u $user ./game/bin/linuxsteamrt64/cs2 \
    -dedicated \
    -console \
    -usercon \
    -autoupdate \
    -tickrate $TICKRATE \
    -port $PORT \
    +map de_dust2 \
    -maxplayers $MAXPLAYERS \
    -authkey $API_KEY \
    +sv_setsteamaccount $STEAM_ACCOUNT \
    +game_type 0 \
    +game_mode 0 \
    +mapgroup mg_active

Run it:

sudo su
export RCON_PASSWORD="changeme"
export API_KEY="changeme"
export STEAM_ACCOUNT="changeme"
export SERVER_PASSWORD=""
export PORT="27015"
export TICKRATE="128"
export MAXPLAYERS="32"
./run.sh

If your RCON still doesn't work (which I'm assuming it won't) it is out of the support of this mod. It is an issue you have with your own setup either network or your VM.

escaparrac commented 11 months ago

Hi!

I did your tests, and unfortunately, RCON is not working. But I found a solution :)

There is another project similar to yours that is working, both with public IP and local IP. Maybe you could check it out: https://github.com/Soren90/cs2-docker

Same config, same OS (Ubuntu 22.04), one project in one port, one in another, ports open with ufw and router:

image image

I wanted to try yours since the mods and custom modes look sick. I don't need Web UI for RCON either, but it looks like I can't make it work, and it's just a simple script. Adding the run.sh log just in case:

logrunsh.txt

But GOOD NEWS!

I added this code to the launch options, and RCON is working now, so you might have an issue around there. I saw that Soren90's project has the +ip command added to his launch options.

+ip xx.xx.xx.xx \ <- with my local ip

Adding that to the install.sh, I can use RCON with my local IP and remote IP.

image image

I hope this helps!

kus commented 11 months ago

Finally we have tracked down the problem.

I have updated the install.sh script so you can specify an IP environment variable.

Please download the latest install.sh

# As root (sudo su)
cd / && curl --silent --output "install.sh" "https://raw.githubusercontent.com/kus/cs2-modded-server/master/install.sh" && chmod +x install.sh && bash install.sh

Note: the repo you linked uses +ip but on Valve documentation they specify it's -ip and other repos I've seen use -ip too. So I've used -ip as per Valves documentation.

Let me know if this works for you.

So with the IP set as your local IP can you still connect when you aren't on the same network?

escaparrac commented 11 months ago

Hi!

Yup, now, with a fresh install, RCON works both from local and public IP (also hostname).

I detected another issue but it's unrelated to RCON, should I open a new thread for that, or do you want me to keep it here?

kus commented 11 months ago

That’s good to hear.

Just post it here

escaparrac commented 11 months ago

Ok! It is regarding custom_files.

I was checking the install.sh code trying to understand how this operation works and:

echo "Downloading mod files..."
wget --quiet https://github.com/kus/cs2-modded-server/archive/${BRANCH}.zip
unzip -o -qq ${BRANCH}.zip
rm -r /home/${user}/cs2/custom_files/ /home/${user}/cs2/custom_files_example/
cp -R cs2-modded-server-${BRANCH}/game/csgo/ /home/${user}/cs2/game/
cp -R cs2-modded-server-${BRANCH}/custom_files/ /home/${user}/cs2/custom_files/
cp -R cs2-modded-server-${BRANCH}/custom_files_example/ /home/${user}/cs2/custom_files_example/
....
echo "Merging in custom files from ${CUSTOM_FILES}"
cp -RT /home/${user}/cs2/${CUSTOM_FILES}/ /home/${user}/cs2/game/csgo/

From my little bash understanding: we download files from git, then we delete the current content from the custom_files folders, and then copy the contents to their respective folders. After that, we merge the custom files folder to the game server folders.

Are we not deleting the modified files BEFORE they are even transferred to their folders? If I modify my files before starting the server, won't they always be overridden by the fresh ones from the repo?

Also, there is some mixed information about admins in the README.md, I think some old info is still there, and the folder routes are not super clear (I would add the /home/steam/cs2/ to all, so it's easier to copy paste and understand the folder structures)

kus commented 11 months ago

Yep you are right, can you please download the new install.sh and let me know if it's fixed.

kus commented 11 months ago

Also RE: the old admin information that has been removed, thanks

RE: folder routes not being clear, I always reference to your root install location because I support Windows and Linux I can't hardcode paths. If you are on linux always prepend /home/steam/cs2/ to any path in the documentation.

I've added a note to try make this clearer https://github.com/kus/cs2-modded-server#custom-files

escaparrac commented 11 months ago

Perfect! All of what I was testing is working now. I will keep testing, but now it seems solid!

image

Just a simple question to end this topic: If I want to have the same hostname for all game modes, should I edit every game mode cfg or what would be the best way to do it so I don't need to edit files every now and then? custom_all.cfg can be used like that?

kus commented 11 months ago

If you want one hostname that doesn't change you are correct, the easiest way is adding the file /custom_files/cfg/custom_all.cfg and put your settings you want across all modes i.e.:

hostname "My Custom Server"
sv_tags "128,AntiCheat"

If you want to change the hostname for each mode you can use mine as an example.

escaparrac commented 11 months ago

Thank you. For me, this is done. I will tinker next week and let you know!

P.S.: Is there any way to contact you? I saw your Twitter DMs are closed and no email around :(

I want to learn more about creating .sh files. I am trying to make the service accessible for free (usually behind a big paywall) so people can self-host their own solution. My goal is to create a script similar to yours so people can install it with little knowledge.

kus commented 11 months ago

Thanks let me know if you see any more things that need to be tweaked. I’ve only personally played on a few game modes with friends so there are some that are not real world tested.

You can message me on Discord, username: kus

escaparrac commented 11 months ago

@kus, I can't find you, I tried to add you as a friend, but it says you cannot accept requests :(

Mine is: escaparrac