Thursday, 18 September 2014

CS:GO DS on DO

Behind this cryptic title hides the sentence "Counter-Strike: Global Offensive Dedicated Server on Digital Ocean". This is a "how to" on setting up your own CS:GO dedicated server, that I wrote after setting up "RipHard CS:GO Server".


The Server
First of all you do need a server to install the software on. I went for Digital Ocean. Currently, for as little as $5 a month, you can get your own virtual server. It only takes seconds to get it up and running. Debian is a good choice. Pick a location near you.

The droplet settings.

The tasks below were done to the server.

Change root password
This was done automatically on first login.

Change ssh port
From default port 22 to something else, to increase security.

root@gameit:~# nano /etc/ssh/sshd_config 
port 22 changed to port XXXX
root@gameit:~# /etc/init.d/ssh restart
[ ok ] Restarting OpenBSD Secure Shell server: sshd.

Update packages
Nice to do, now and then. At least when the server is new.

root@gameit:/home/gameit# apt-get upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Add new steam user
Add a new user, named "steam", to be used for the dedicated server installation.

root@gameit:~# adduser steam
Adding user `steam' ...
Adding new group `steam' (1001) ...
Adding new user `steam' (1001) with group `steam' ...
Creating home directory `/home/steam' ...
Copying files from `/etc/skel' ...
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully
Changing the user information for steam
Enter the new value, or press ENTER for the default
Full Name []: 
Room Number []: 
Work Phone []: 
Home Phone []: 
Other []: 
Is the information correct? [Y/n] Y

Disable root ssh login
Being able to login as root using SSH is never a good thing. Turn it off.

root@gameit:~# nano /etc/ssh/sshd_config 
PermitRootLogin yes changed to PermitRootLogin no
root@gameit:~# /etc/init.d/ssh restart
[ ok ] Restarting OpenBSD Secure Shell server: sshd.

CS:GO Dedicated Server
The server is ready, next step is to install the CS:GO Dedicated Server software. A complete receipt on how to do this is found on Valve's own pages.

Install Steam
steam@gameit:~$ mkdir /home/steam/steamcmd
steam@gameit:~$ cd /home/steam/steamcmd
steam@gameit:~/steamcmd$ wget http://media.steampowered.com/installer/steamcmd_linux.tar.gz
steam@gameit:~/steamcmd$ tar -xvzf steamcmd_linux.tar.gz
steam@gameit:~/steamcmd$ rm steamcmd_linux.tar.gz

At this point you can start Steam. In my case that lead to an error:

steam@gameit:~/steamcmd$ ./steamcmd.sh 
./steamcmd.sh: line 29: /home/steam/steamcmd/linux32/steamcmd: No such file or directory

Solution:
root@gameit:~# apt-get install ia32-libs

Install CS:GO
Start Steam and install CS:GO

steam@gameit:~/steamcmd$ ./steamcmd.sh 
Steam>login anonymous
Steam>force_install_dir ./csgo/
Steam>app_update 740 validate

Run CS:GO
Start the dedicated server from the command line, to check that everything is working.

cd /home/steam/steamcmd/csgo/
./srcds_linux -steam_dir /home/steam/steamcmd -game csgo -console -usercon +game_type 0 +game_mode 0 +mapgroup mg_active +map de_dust2

If the server starts (yes, you will see a few error messages / warnings) and you can log on, you are set to start with the configuration.

Server Launcher
A helpful tool is the "CSGO Server Launcher". A command line tool for starting and updating your server.

Trying to run this you might see the error message:
./csgo-server-launcher.sh: line 132: screen: command not found

Solution:
root@gameit:~# apt-get install screen

Example of using the tool:
steam@gameit:~/steamcmd$ ./csgo-server-launcher.sh start
steam@gameit:~/steamcmd$ ./csgo-server-launcher.sh restart
steam@gameit:~/steamcmd$ ./csgo-server-launcher.sh stop

Remember, to close console, without shutting down server press
CTRL + A
CTRL + D

Note:
I ended up renaming this script to "csgo_launcher.sh" and moved it to a separate "scripts" folder.

Auto update
You can use "CSGO Server Launcher" and Cron for auto updating of the server. However, I wrote my own little script.

csgo_updater.sh
/home/steam/steamcmd/steamcmd.sh +runscript /home/steam/scripts/csgo_updater.txt

csgo_updater.txt
// update cs:go
login anonymous
force_install_dir ./csgo/
app_update 740
quit

cron daemon
0 4 * * * /home/steam/scripts/csgo_updater.sh >/dev/null 2>&1

Startup Errors
When starting your server you see several errors. To fix (some of ) them you can do:

steam@gameit:~/steamcmd/csgo/csgo/addons$ mkdir /home/steam/.steam
steam@gameit:~/steamcmd/csgo/csgo/addons$ mkdir /home/steam/.steam/sdk32
steam@gameit:~/steamcmd/csgo/csgo/addons$ ln -s /home/steam/steamcmd/linux32/steamclient.so /home/steam/.steam/sdk32/steamclient.so

You might also see the message "Error parsing BotProfile.db - unknown attribute 'Rank'" when starting your server. A solution to this can be found here. And if you want to check my updated "botfile.db" that fixes this error, that can be done here.

To avoid the "Invalid file size for host.txt" create a file named "host.txt" under the "csgo/csgo" directory. Not sure what the purpose of this file is. I read somewhere that it was related to what banner to display upon server login, but it had no other effect than removing the error message on my server. View my version of this file here.

Those Config Files
You have several cfg, or config, files that you need to add or update. I find it slightly confusing and not straight forward to know where to put the different server and game settings. These files are located in the "csgo/cfg" (or "csgo/csgo/cfg") directory.

autoexec.cfg
This file should be created if you want to add some logging to your server. More on that further down. Check my version of this file here.

server.cfg
This file you need, to specify name and maybe some basic server settings. Check my version of this file here.

gamemode_xxxxxx_server.cfg
You will also need some config files to setup different game modes, for the server. I copied the existing gamemode files ("gamemode_armsrace.cfg" to "gamemode_armsrace_server.cfg", "gamemode_casual.cfg" to "gamemode_casual_server.cfg"  and so on) and tuned them slightly. These files change the game settings for each game mode. Check all my versions of these files here.

go_xxxxx.cfg
As a server admin it is also nice being able to quickly change game mode on the server. For that I created a few cfg files of my own. "go_armsrace.cfg" changes to armsrace mode (note that "gamemode_armsrace_server.cfg" automatically will be executed), "go_casual.cfg" changes mode to classic casual mode, and so on. Check these files here.

From the "CSGO Server Launcher" console this script can be executed by writing:
exec go_armsrace

From the game, you need to open the in-game console (Activate the console in Help & Options -> Game Settings -> Enable developer console. This will then allow you to open the console using the tilde key ~.), and write this:
rcon_password yourrconpasswordhere
rcon exec go_armsrace

set_bots.cfg
I also made a little script that fills up CT side with bots. Nice if you want to play against bots without bots on your own team. Check the file here.

gamemodes_server.txt
Directly under the "csgo" directory you should add the file "gamemodes_server.txt". In this file you should specify your mapgroups, what maps to be played with what game modes. Note that you manually have to download non standard maps to your server, if you want to use any. Check my version of this file here.

motd.txt
Under the "csgo" game directory ("...steamcmd/csgo/csgo" on the server) you find the file to update the server's message of the day. Just edit the "motd.txt" file. My version of this file can be viewed here.

All My Tuned files
All the files I have updated or created on my server can be viewed on GitHub.

Appendix

Workshop
I had some issues starting the CS:GO server in Workshop mode. However, after having spent some time I managed to set it up. Follow the guide given in the link on the above line. I added "webapi_authkey.txt" (generate own key here), "subscribed_collection_ids.txt" and "subscribed_file_ids.txt" to the "csgo" game directory. As well I have added all workshop maps into one mapgroup, in the "gamemodes_server.txt". To quickly generate the list of workshop maps, used in the "gamemode_server.txt" I wrote a little Perl program.

Note: I ran into problem that I was unable to change map to any workshop map at all. I realised that this was because some maps never got downloaded to the server. The map folder, under the "maps/workshop" had been created, but was empty. The fix was to delete those failed maps from the "subscribed_file_ids.txt" (and delete the empty folders). My little Perl program mentioned above warns you if it find any workshop folder without map files in them.

Server failed to download several maps, unknown why.

CVAR
List of all CVARs will come in handy. You can see a complete overview here:
https://developer.valvesoftware.com/wiki/List_of_CS:S_Cvars

Statistics
You might want some statistics for your server.

GameTracker
GameTracker.com is a nice solution. A few extra lines in "server.cfg" is needed:
host_name_store       1
host_info_show        1
host_players_show     2

GameMe
If you want more server specific statistics you should check out gameme.com. It costs $5 a month. For this to work you have to add a few lines to "autoexec.cfg". You will find what to write in your autoexec.cfg in your own GameMe console. Please note that you do not need to install any mods for this to work. The only reason for using a mod (SourceMod or AMX Mod X) is for the GameMe ingame plugin, which display real time statistics, while playing. However that is not at all needed. Keep it simple. Stats can be viewed after the match is over.

Server Mods
You have several server mods that can be installed on the server. I tried MetaMod, SourceMod and Mani Admin Plugin. However, I did realised that I did not at all need any of these mods. So I threw them all out. They only cluttered up the server installation. With CS:GO you have included much of the functionality that these mods was very nice for in CS:Source, like map voting, and other votes.

SourceMod also messed up the built in map vote. Below an example from the logs:
CHANGELEVEL: ConVar 'nextlevel' is set, next map will be 'de_sugarcane'
CHANGE LEVEL: de_sugarcane
L 09/04/2014 - 20:50:33: [SM] Changed map to "de_aztec"

Opening ports
This should not be necessary. If you have done what I did above you have no firewall running. However, in case you can not access your server you might try running the following commands:

root@gameit:~# /sbin/iptables -A INPUT -p udp -m udp --dport 27000:27030 -j ACCEPT
root@gameit:~# /sbin/iptables -A INPUT -p tcp -m tcp --dport 27014:27050 -j ACCEPT
root@gameit:~# /sbin/iptables -A INPUT -p udp -m udp --dport 4380 -j ACCEPT
root@gameit:~# /sbin/iptables -A INPUT -p udp -m udp --dport 3478 -j ACCEPT
root@gameit:~# /sbin/iptables -A INPUT -p udp -m udp --dport 4379 -j ACCEPT
root@gameit:~# /sbin/iptables -A INPUT -p udp -m udp --dport 1200 -j ACCEPT
root@gameit:~# /sbin/iptables -A INPUT -p udp -m udp --dport 4380 -j ACCEPT




No comments:

Post a Comment

Allowed HTML tags:
<b>bold</b>
<strong>strong</strong>
<i>italics</i>
<em>emphasis</em>
<a href="">hyperlink</a>


Please, show the courtesy of identifying yourself when adding a comment. Anonymous comments will, most likely, be removed.