Counter-Strike 2
Недостаточно оценок
CSGO - dedicated server full setup - debian & workshop map fetching and usage
От Juksefantomet и соавторов
A step by step guide on how to install a csgo server on debian:

steamcmd
systemctl service
update script
start script
wokshop map downloading
rcon passwords
api key
steam access key for public server
   
Наградить
В избранное
В избранном
Удалить
Initial - root + sudo setup
This guide is assuming this VM / server is a fresh install, if you can already perform sudo commands, skip to the next step.

swap to root and install sudo and curl packages

su - root
apt-get install -f sudo curl

edit the sudoers file to grant your user sudo permissions:

nano /etc/sudoers

under the section:
# User privilege specification root ALL=(ALL:ALL) ALL


add:
yourusername ALL=(ALL:ALL) ALL

save and exit with:
ctrl + x, then y to confirm and enter

exit out of root account:
exit


test your sudo access with:

sudo ls
Add user 'csgo'
create your csgo user:
sudo adduser csgo

swap to that user:
sudo -i -u csgo
Download and install steamcmd
ensure you are in the home root folder of the csgo user with:
cd
pwd

your output should be:
/home/csgo



fetch steamcmd:


to confirm the install was succesfull:
./steamcmd.sh

press exit once possible by typing:
exit

if you by any chance cannot execute run steamcmd:
chmod +x+w+r steamcmd.sh
Creating the update script
preparations for update and run script:

get your 2 factor code:

Log out of steam and back in again with the correct steam account and make a note of the 2 factor code you recieve via email/application. If you do not use 2factor, here is my disclaimer regarding errors along the way as a result of that.

this goes in after the +set_steam_guard_code

let us make an update script:
nano csgo_updater.sh

#!/bin/sh ./steamcmd.sh +@ShutdownOnFailedCommand 1 +@NoPromptForPassword 1 +@sSteamCmdForcePlatformType linux +set_steam_guard_code XYZDA +login anonymous +force_install_dir "/home/csgo/csgo/" +app_update 740 +quit +exit # cd csgo # ./start

save and exit:
ctrl+x+y+enter

NOTE: we are commenting out the start section as the start script is not ready yet.

make the update script executable:
chmod +x+w+r csgo_updater.sh

run it:
./csgo_updater.sh
Start script
preparations for start script:

go to this url for steam access key, required to allow your server to go online:
steam account access key

add in appid: 730, and name your server.
copy the login token, this goes after the flag +sv_setsteamaccount


then proceed to the api key for the authkey flag:

API auth key for map downloading

add a representative name, domain if your server is related to that, then copy the api key.
this belongs after the -authkey flag


your public ip/servers public ip,
goes after +net_public_adr

your LAN ip,
goes after +ip

how to exceed player limits:

-maxplayers_override XX
where XX represents your desired number

+game_mode 0 = casual
+game_mode 1 = competitive

+game_type 0 = regular
+game_type 1 = arms race


let us create a start server script:

NOTE:
we are placing this inside the csgo folder, as we're still working outside the folder, there is no need to enter it yet.

nano /home/csgo/csgo/start


./srcds_run -game csgo -console -usercon +game_type 0 +game_mode 1 +mapgroup mg_bomb +map de_dust2 -maxplayers_override 12 +sv_setsteamaccount WIIIIDOOOOWSSUUUUUUUUCKSSSS +net_public_adr 84.213.47.30 +ip 192.168.0.44 -port 27015 -net_port_try 1 -authkey LIIIINUUUUUXRUUULES


If you require port forwarding
Depending on your setup, if you are at home you might have to open and forward ports:
Counter-Strike: Global Offensive - Steam TCP: 27015-27030,27036-27037 UDP: 4380,27000-27031,27036


As you can open port-ranges in most routers i suggest this range to keep the "clutter" to a minimum:

UDP - 4380 TCP & UDP - 27015-27037

Unfortunately i do not know your router model and information, so if you require assistance on this part you need to investigate topics:

port forwarding in relation to your router model.
let us create a system service
adding a service so the csgo server starts when you boot your VM/server:
sudo nano /etc/systemd/system/csgo.service

[Unit] Description=MY AWESOME CSGO Server RefuseManualStart=no RefuseManualStop=no [Service] WorkingDirectory=/home/csgo ExecStart=/bin/bash csgo_updater.sh User=csgo Group=csgo [Install] WantedBy=multi-user.target

save+exit

now before we enable the service, remember we commented out the start script commands in the csgo_updater.sh file

so:
nano csgo_updater.sh

remove # infront of:
cd csgo start

save+exit


enable and check the status of the created service:
sudo systemctl enable csgo.service sudo systemctl status csgo.service

NOTE:
if you need to edit and change something, do not forget to reload the service daemon:

sudo systemctl daemon-reload


Journey the output of the service and see how it goes:

this outputs the log and scrolls to the end
sudo journalctl -u csgo.service -e

this outputs the log and scrolls to the end and follows the log, ctrl+c to exit tailing
sudo journalctl -u csgo.service -e -f
Post setup - maps
Now your server is up and running with some default settings


enter the root of your csgo server folder:
cd /home/csgo/csgo

just to clarify content, here you'll find your start script which we made earlier and the run-times for source server. (confirm with ls command)

enter one step further into the folder called csgo.
cd /home/csgo/csgo/csgo
or
cd csgo

you can confirm path with:
pwd

here you will find the cfg folder and the maps folder. (confirm with ls command)


HERE you create the file which takes your workshop map ids:
nano subscribed_file_ids.txt

122443683 270124159 257166103 147545033 1173989333 707984520 765936384 644518351 496123922 1079988970

(yes, these are working steam workshop ids)

save+exit

--- important note ---
you do not have to restart your server if you add to this while the server is running
BUT you will have to restart if the file never existed in the first place


so invoke:
sudo systemctl restart csgo.service
Post setup - configs
now let us add a rcon passord so you can remote interface with your server:

cd into the cfg folder:

cd /home/csgo/csgo/csgo/cfg

NOTE: if you create the user steam instead, and call the install location for game, that path with look more human readable, but this guide was made from the actual install output, and i named my account csgo.

if file does not exist it will be created when you nano it with:
nano server.cfg

hostname "MY AWESOME CSGO SERVER" rcon_password "ijusthatestrongpasswords" sv_allowupload "1" sv_allowdownload "1" sv_password "onlyishallpass" bot_quota "0"


notes:
bot_quota will not be able to exceed maxplayers_override XX set in the start script
allow uploads and downloads required for "custom maps" not served via workshop.

some clients might also need to enable these if they get errors in console when attempting to download maps.

BUT, with workshop provided ids, you will download from the workshop - not the server.
Connecting and interfacing with the server
now you can connect to your server, it should now be possible to find it in the public steam list, but that is quite long.

you might want to simply add it to favorites or via console.

if your server had a password set:
password thatpassword

then
connect publicip:27015

once loaded in, pull up the console again and perform this:
rcon_password yourrconpassword


lists maps on the server:
rcon maps *

workshop maps are identified with a workshop/ prefix to it.

NOTE: According to the documentation on valve pages, it claims the download starts on server boot. this is NOT a fact.

so you need to invoke:
rcon ds_get_newest_subscribed_files
if your API key is missing or wrong, you will be informed here.

TIP: you can add that command to your server.cfg file


there is no output when it runs or finishes. so simply use:
rcon maps *

to confirm map list

NOTE: keep in mind, while downloading is active your server might lag, so do it when you have low traffic.

and finally:
rcon changelevel mapname

FINAL NOTE:
You do not need to specify the workshop/mapname path, simply use the map name

rcon changelevel fy_pool_day