This guide will describe the installation and configuration of simultaneous operation of several dedicated Steam game servers for Linux using the example of Team Fortress 2.
We will need:
All of the following is described in relation to a separate server, physical or virtual, with installed and configured Linux, console access. In all examples, the server has an ip address of 192.0.2.0, our client computer has 198.51.100.0
The game server does not need root privileges to start and work, so we will install and run everything from under the unprivileged game user. Log in as root and add the user:
# useradd --user-group --create-home --comment "Source dedicated server" game
Since we will run a number of scripts on a schedule, weβll check if the game user can create his crontab file:
# su - game $ crontab -e
If the editor window has opened, well, maybe. If something like this is displayed on the screen:
cannot chdir(/var/spool/cron), bailing out. /var/spool/cron: Permission denied
it cannot. Then, depending on the cron program used and its settings, we allow the user (after leaving the game back to root) to create his crontab file.
So, the user is created, authorization is configured. Close the root session, continue to work as a game.
Our goal of installing and configuring the simultaneous operation of multiple game servers can be achieved in different ways. In the simplest case - creating separate instances of servers, each in its own directory. This, at the cost of inefficient use of disk space (if the file system or data storage does not use deduplication) and the increased consumption of traffic to download the same updates, makes it possible to independently configure, update and manage servers, although using all the same ip address for all game servers different ports. Another way is to use a single directory for the game, but with individual settings of the game servers. This way we go.
If we have a 64-bit distribution of Linux, then you need to install additional compatibility libraries (as root). What exactly - is googled for the phrase steamcmd x64 YOUR_DISTRIBUT . For Ubuntu 13.10 x64, for example, apt-get install lib32gcc1
, for ArchLinux - pacman -S lib32-gcc-libs
(with the multilib repository enabled in /etc/pacman.conf), for CentOS - yum install glibc.i686 libstdc++.i686
and etc.
If they are not installed, an error of the form will be generated:
./steamcmd.sh: line 29: /home/game/Steam/linux32/steamcmd: No such file or directory
or
./steamcmd.sh: /home/game/Steam/linux32/steamcmd: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory
We will install the Steam client in the directory of the same name in the user's home directory game, and the game itself in the tf2 directory. It is assumed that in / etc / fstab the partition with / home is mounted without noexec and there is enough free space.
Create directories for our servers and go to the first one:
$ mkdir ~/Steam $ mkdir ~/tf2 $ cd ~/Steam
Download the console client Steam , unpack the archive.
$ wget http://media.steampowered.com/client/steamcmd_linux.tar.gz $ tar -xvzf steamcmd_linux.tar.gz
For greater clarity, we divide the next launch of steamcmd.sh into two. First, run the self-update procedure:
$ ./steamcmd.sh +quit
Steam client needs to be updated. In case of any problems, read the logs in ~ / Steam / logs.
Now install a dedicated game server:
$ ./steamcmd.sh +login anonymous +force_install_dir ~/tf2/ +app_update 232250 validate +quit
The number "232250" in the command line parameters is appid, the application identifier, in our case Team Fortress 2 dedicated server. More commands are described in the section "Update servers".
If everything is ok, then the download will start spontaneously:
Redirecting stderr to '/home/game/Steam/logs/stderr.txt' ... Connecting anonymously to Steam Public...Logged in OK Waiting for license info...OK Update state (0x3) reconfiguring, progress: 0.00 (0 / 0) Update state (0x11) preallocating, progress: 8.28 (561715882 / 6785978023) Update state (0x61) downloading, progress: 0.20 (13671159 / 6785978023) Update state (0x61) downloading, progress: 0.70 (47497460 / 6785978023) ... Update state (0x61) downloading, progress: 99.96 (6783415033 / 6785978023) Update state (0x81) committing, progress: 7.66 (519615292 / 6785978023) Success! App '232250' fully installed.
A few minutes, and we have to download six and a half gigabytes for Team Fortress 2 (as of October 2016).
Go to the folder ~ / tf2 and try to start the game manually, let's see how it is.
$ cd ~/tf2 $ ./srcds_run -game tf +map cp_cloak
On the console should appear something like:
Auto detecting CPU Using default binary: ./srcds_linux Server will auto-restart if there is a crash. WARNING: Failed to load 32-bit libtinfo.so.5 or libncurses.so.5. Please install (lib32tinfo5 / ncurses-libs.i686 / equivalent) to enable readline. Using Breakpad minidump system. Version: 3475087 AppID: 232250 Setting breakpad minidump AppID = 232250 Using breakpad crash handler Loaded 7510 VPK file hashes from /home/game/tf2/tf/tf2_textures.vpk for pure server operation. ... Network: IP 192.0.2.0, mode MP, dedicated Yes, ports 27015 SV / 27005 CL Initializing Steam libraries for secure Internet server ... Connection to Steam servers successful. Public IP is 192.0.2.0. Assigned anonymous gameserver Steam ID [A:1:1724597452:5521]. VAC secure mode is activated. Received 3825164 bytes item schema version DBDD1115 direct data; update is queued.
You can respect the request by installing the ncurses-libs.i686 library. And the rest is all good. Make sure that in lines 13 (Network: ...) and 17 (Public IP ...) the server chose the correct IP.
We donβt pay attention to errors about "/home/game/.steam/sdk32/steamclient.so: cannot be shared"; this is normal. However, you can fix it:
$ mkdir -p ~/.steam/sdk32 $ ln -s ~/Steam/linux32/steamclient.so ~/.steam/sdk32
We launch on our computer Team Fortress 2, call the console ( ~
), then connect 192.0.2.0:27015
(Either immediately steam: //connect/192.0.2.0: 27015 - you can then create a shortcut on the desktop). We start to connect to the game server, and on the server console at this time a line of the form was displayed
Client "Ich" connected (198.51.100.0:42380).
If the connection failed, then we check that the server is listening on the correct interface. If there is a firewall, we check if the necessary ports are open according to the Valve manual . In the case of more complex network configurations (server for NAT, etc.) refer to the relevant manuals.
We stop the game server with the quit
command, typing it into its console, return to the command line and start the configuration.
Historically, over the years of development, various possibilities have emerged for configuring the server.
By default, the server uses several basic configuration files that it searches for in ~ / tf2 / tf / cfg /: autoexec.cfg - runs once at server start, server.cfg - when starting any card, <card_name> .cfg - when starting the corresponding cards.
Also, when you start the server, you can specify the +servercfgfile my.cfg
parameter in its command line - the server will no longer use server.cfg but my.cfg, and several parameters like +exec file1.cfg +exec file2.cfg +exec file3.cfg
- these files will be executed once at server start, immediately after autoexec.cfg.
In addition, even before checking the main directory, the server searches for ~ / tf2 / tf / custom files with the extension .vpk and directory structures of the form my_dir / cfg /, my_dir / maps /, my_dir / materials / and the like and files found there uses instead of the standard ones of the same name.
But that's not all. In Team Fortress 2 update dated May 14, 2013, a new command line parameter -insert_search_path
. It serves to add a custom directory structure (similar to custom /), but with the ability to specify an absolute path, that is, not necessarily inside the server directory ~ / tf2 / tf /. Previously, it had to be clever, but now it is enough to specify -insert_search_path / var / dir1 in the srcds_run command line and this directory will be used as a search path (/ var / dir1 / maps, / var / dir1 / cfg,) before custom / and to the main directory with configuration files ~ / tf2 / tf / cfg /. In -insert_search_path, you can specify multiple directories separated by commas. And the directories will be processed in the order in which they are listed, unlike the directory structure in custom /, where they are processed alphabetically.
That is, if we have several server.cfg files in different directories:
~/tf2/tf/cfg/server.cfg ~/tf2/tf/custom/my_files/cfg/server.cfg ~/tf2/tf/custom/another/cfg/server.cfg /var/dir1/cfg/server.cfg
and in the command line of the server, we also specify -insert_search_path /var/dir1
, then when the server is started and when exec server.cfg
commands are executed in the console and scripts, this file will first be searched in / var / dir1 / cfg, then in custom / another / cfg /, further in custom / my_files / cfg / (directories in custom / are sorted alphabetically) and finally in the main cfg /. This applies not only to server.cfg, but also to motd.txt, maps, etc. For more information about search paths, you can read (and pick up the settings) in ~ / tf2 / tf / gameinfo.txt - there are also ways to configure paths from the system language, not covered here and a lot of interesting things.
It is very simple to look at the sequence of search paths search - just enter the path
command in the console of a running server:
path --------------- Paths: "maps/cp_cloak.bsp" "GAME" (map) "/home/game/tf2/bin/" "EXECUTABLE_PATH" "/home/game/tf2/" "BASE_PATH" "/var/dir1/" "GAME" "/var/dir1/" "MOD" "/home/game/tf2/tf/custom/another/" "GAME" "/home/game/tf2/tf/custom/another/" "MOD" "/home/game/tf2/tf/custom/my_files/" "GAME" "/home/game/tf2/tf/custom/my_files/" "MOD" , ,
Also, do not forget about the configuration files of the form <card name> .cfg. In addition, there is replay.cfg, sourcemod.cfg, mmm ... yes, thousands of them!
Such a zoo allows for setting up individual configurations for servers to shoot themselves in a variety of ways. And since srcds is a young, dynamically developing server, it can deliver quite a lot of fun hours in search of an answer to the question "Why did the players suddenly stop downloading user cards. Even through slow download, not to mention fast ... Everything was fine for two years ... "
Of the total wealth of choices we have proposed, we will focus on specifying the configuration files in + exec and + servercfgfile in the launch parameters.
It should be noted that any complete files installed during installation in ~ / tf2 can be changed during the next server update, including files in ~ / tf2 / tf / cfg. Therefore, we will not directly use the available configuration files, but will begin to create our own, even if based on them.
That is, instead of using an existing, complete file with a list of maps for rotation, for example, +mapcyclefile mapcycle_quickplay_cp.txt
, even if it currently suits us completely, we will copy it into our mapcycle.txt and connect it.
The complete files that we modified or deleted (not only configurations, but any) can be returned to its original state by running the game server update with the "validate" parameter - steamcmd.sh +login anonymous +force_install_dir ~/tf2/ +app_update 232250 validate +quit
. Then, even if there is no new update for us as such, the checksums of all the complete files will be checked, and, if there is a mismatch, the modified files will be downloaded again.
In our example, we will configure two game servers:
Create a directory for storing files with server settings. At the same time make a directory for logs. At the moment we already have the logs of the Steam client, so immediately make a link there:
$ mkdir ~/cfg $ mkdir ~/log $ ln -s ~/Steam/logs ~/log/steam
If possible, we will create all configuration files in ~ / cfg and symbolic links in the corresponding directories of the server. This placement will significantly simplify the backup and restore process of the server, and reduce mixing settings of different servers, although this can not be completely avoided.
Settings can be grouped into three categories:
But in the command line of the server, you canβt specify a lot, either due to restrictions on maximum length or for security reasons - if there are no properly tightened nuts, other users on your Linux server with shell access can see each otherβs processes and command lines - cat /proc/<id>/cmdline
with such delicate parameters as rcon_password, tf_server identity <...>, sv_setsteamaccount, sv_password and so on.
Thus, we will first use only five files for our settings - the general settings for both servers in the autoexec.cfg file, the individual settings of the first server are autoexec1.cfg and server1.cfg, the second one is autoexec2.cfg and server2.cfg. The expediency of dividing individual settings into two files is dictated by the above dividing the parameters into three categories, and the need to use files (such as server.cfg) that are performed each time the map is changed - to restore the settings changed in the individual map settings files, or manually in the console , either by cron, or in any other way. After all, files like autoexec.cfg are executed only at the start of the game server.
Not to mention three very useful commands. The first isecho "- , "
.echo "- , "
When used at the beginning of each configuration file, it allows you to visually see the sequence of execution of various files, in the case of analysis of non-obvious server behavior. The second one isdifferences
, when entered into the server console, it shows all variables whose values ββare different from the default values. Facilitates the search for an answer to the question "Why is everything wrong? It seems everything is as always ...". The third -exec <config>
- allows you to call some configuration files from others. With thoughtful configuration, and in combination with the ability to replace files by cron and together with the ability to run them from scripts (using tmux send-keys - an example in the update.sh script in the section "Updating servers") allows you to turn a game server into a living organism that lives own life.
The detailed configuration of the internal configuration of the game server will not be described here - each has its own, let us dwell only on the moments associated with the simultaneous operation of two servers.
If you already have ready configuration files for a single server, then you can start with them, and if not (well, that's not enough - our first game server), then you can google the server.cfg setting for tf2 . The only thing I can advise is not to look for someoneβs clever configuration file a decade ago, which lists all possible, including already obsolete parameters, the vast majority with default values ββand descriptions taken from the cvarlist, and look for actual and Most documented descriptions, although it may be difficult, yes.
In general, it is better to start without a ready server.cfg at all - the game server will start fine without it, we have already seen this, but when you want to change something - the number and duration of the rounds, auto-balancing of teams, etc., then you will already recognize write down the parameters that control this.
If you still want to know the "all-all-all" server-side public commands and variables, then in the console of the running server just enter:
cvarlist log allcvars.txt cvar list -------------- _resetgamestats : cmd : : Erases current game stats and writes out a blank stats file _restart : cmd : : Shutdown and restart the engine. ... -------------- 1908 total convars/concommands
and in the file ~ / tf2 / tf / allcvars.txt all console variables will be listed, often with brief descriptions. You can only output commands with a specific prefix, for example, cvarlist tf_
, cvarlist sv_
. You can search by the substring - find log
. In this case, the search is performed both by name and by description.
So, we create our configuration files.
It should be borne in mind that many teams depend on each other, and in some cases their sequence is important. So, for example, if you first enable logging to a file (log on), and then start pointing to which directory (sv_logsdir) and under what name (sv_logfilename_format) - the results will not meet expectations.
In the file ~ / cfg / autoexec.cfg - it is executed first, we prescribe settings common to both servers:
// echo "*** ~/cfg/autoexec.cfg (global)" // , exec banned_user.cfg exec banned_ip.cfg writeid writeip // , // -1 - , 0 - , 1 - , 2 - , 3 - , // 4 - , 5 - , 6 - , 7 - sv_region 3 // // (1), // (0) sv_log_onefile 0 // sv_logbans 1 // , , UDP. // sv_logfile 1 // sv_logecho 0 // (log on) // - (sv_logsdir)
Log management commands are discussed in more detail in the "Logs" section.
Create (for now) empty banned_user.cfg and banned_ip.cfg files
$ touch ~/cfg/banned_user.cfg ~/cfg/banned_ip.cfg
In the file ~ / cfg / autoexec1.cfg we set the settings for the first server:
// echo "*** ~/cfg/autoexec1.cfg" // , hostname Public Server No 1 // . // rcon_password rconPasswordServer1 // . // . map cp_granary // sv_allow_point_servercommand // message of the day motdfile motd1.html motdfile_text motd1.txt // mapcyclefile mapcycle1.txt // sv_logsdir /home/game/log/server1 // log on
About the motd and mapcyclefile files will be mentioned below. A directory for logs will be created by the server itself.
And on the second server we install the cp_orange_x3 map, not included in the standard delivery of Team Fortress 2. The easiest way to install custom maps is to put the file with the map in ~ / tf2 / tf / maps, or in a directory in one of the search paths. But there is another way to connect third-party cards. If such a map is presented in Steam Workshop , then we can refer to it as to "workshop /", or "workshop / <map name> .ugc" both in the map command and in the mapcycle file. Then when you start the game, our server downloads it from the Valve servers, and when you connect a player, his computer will download the card from there. Each time you change the card, it will be checked for updates. When using non-standard maps only from Steam Workshop, the inclusion of Fast Download becomes unnecessary. But the reverse side of the coin - there is also a dependence on the Workshop servers.
So, open the Steam Workshop browser using the link above, in the search bar, enter "cp_orange_x3", in the search results go to the map page - https://steamcommunity.com/sharedfiles/filedetails/?id=454299390 . From this url we take the numeric id and write it in our autoexec2.cfg in the format "workshop / 454299390" or "workshop / cp_orange_x3.ugc454299390". The second option is clearer.
In the file ~ / cfg / autoexec2.cfg we set the settings for the second server:
echo "*** ~/cfg/autoexec2.cfg" hostname Private Server No 2 rcon_password rconPasswordServer2 //map workshop/454299390 map workshop/cp_orange_x3.ugc454299390 sv_allow_point_servercommand always motdfile "motd2.txt" mapcyclefile "mapcycle2.txt" sv_logsdir /home/game/log/server2 log on
Another little moment. For each map, you can create a file-satellite <map name> .cfg - for commands executed by the server when this map is started, immediately after server.cfg is executed. For standard maps, the file should be in ~ / tf2 / tf / cfg. Steam Workshop, "< >.ugc.cfg" ~/tf2/tf/cfg/workshop. , , Steam Workshop. cp_orange_x3, id 454299390, ~/tf2/tf/cfg/workshop/cp_orange_x3.ugc454299390.cfg
sv_allow_point_servercommand, "official" β Allowed for valve maps only. "always" autoexec2.cfg
- Steam Workshop,tf_workshop_map_sync <id >
. βchangelevel wohrkshop/<id>
.tf_workshop_map_status
, ~/tf2/steamapps/workshop{1,2}/appworkshop_440.acf.
~/cfg/server1.cfg , :
// echo "*** ~/cfg/server1.cfg" // *** // , UDP HLstatsX // // 127.0.0.1 (!) // "log on" - ( autoexec1.cfg) logaddress_delall logaddress_add 192.0.2.0:27500 // (1 - , 0 - ) sv_cheats 0
- HLstatsX ( β , ) logaddress_delall
< >.cfg, - , logaddress_add server1.cfg . logaddress_delall logaddress_add "logaddress_add: 192.0.2.0:27500 is already in the list"
, sv_cheats "0" β , - ( , ) "1".
~/cfg/server2.cfg :
echo "*** ~/cfg/server2.cfg" // - 27500, - 27501 !!! logaddress_delall logaddress_add 192.0.2.0:27501 sv_cheats 0 tf_bot_quota 0
. , Control Point, mapcycle_quickplay_cp.txt, .
$ cp ~/tf2/tf/cfg/mapcycle_quickplay_cp.txt ~/cfg/mapcycle1.txt $ dos2unix ~/cfg/mapcycle1.txt $ chmod 664 ~/cfg/mapcycle1.txt
, ~/cfg/mapcycle1.txt :
cp_5gorge cp_badlands cp_coldfront cp_fastlane cp_freight_final1 cp_granary cp_well cp_yukon_final cp_foundry cp_gullywash_final1 cp_process_final cp_standin_final cp_snakewater_final1 cp_powerhouse cp_vanguard cp_sunshine cp_metalworks
~/cfg/mapcycle2.txt . cp_orange_x3 , autoexec2.cfg β "workshop/454299390", "workshop/cp_orange_x3.ugc454299390":
// cp_orange_x3 https://steamcommunity.com/sharedfiles/filedetails/?id=454299390 workshop/cp_orange_x3.ugc454299390
. , html , url. - 1-2 .
~/cfg/motd1.html :
<html> <head> <title>Message of the day</title> </head> <body> <h1>Welcome to our server!</h1> </body> </html>
~/cfg/motd1.txt , html motd (cl_disablehtmlmotd 1):
Welcome! Have fun and be safe
~/cfg/motd2.txt url, motd :
http://m.forum.example.org/news.html
url motdfile. motdfile_text, url .
MOTD β from Jimo , .
, , cfg :
$ ln -s -v ~/cfg/* ~/tf2/tf/cfg/
( ), netstat -lpn | grep srcds
, :
tcp 0 0 192.0.2.0:27015 0.0.0.0:* LISTEN 3456/./srcds_linux udp 0 0 192.0.2.0:27005 0.0.0.0:* 3456/./srcds_linux udp 0 0 192.0.2.0:27015 0.0.0.0:* 3456/./srcds_linux udp 0 0 192.0.2.0:27020 0.0.0.0:* 3456/./srcds_linux udp 0 0 192.0.2.0:26901 0.0.0.0:* 3456/./srcds_linux
. srcds:
UDP/27005
+clientport
β Game client port
UDP/27015
-port
β The port the server advertises to clients
TCP/27015
, RCON, -port
, TCP. ssh ( β ), TCP ( UDP!) , . , . .
UDP/27020
-tv_port
β SourceTV port ( "SourceTV")
UDP/26901
-steamport
β Steam/VAC connection port
, , , "-port 27015 -steamport 26900 +clientport 27005 +tv_port 27020". 26900 β , .
. , , (27015 -> 27017 -> 27019 ). . .
"-port 27016 -steamport 26901 +clientport 27006 +tv_port 27021".
, , , . , , :
WARNING: Port 27015 was unavailable - bound to port 27016 instead WARNING: Port 27005 was unavailable - bound to port 27006 instead WARNING: Port 27020 was unavailable - bound to port 27021 instead Network: IP 192.0.2.0, mode MP, dedicated Yes, ports 27016 SV / 27006 CL
. , -strictportbind
( ).
, , "-port 50000 +clientport 50001 +tv_port 50002 -steamport 50003", ISteamApps/GetServersAtAddress . .
-:
, / , β ~/start1.sh ~/start2.sh. . , ~/start1.sh:
#!/bin/sh # # . # , srcds_run GAMEFOLDER=/home/game/tf2 CMDLINE="-port 27015 -steamport 26900 +clientport 27005 +tv_port 27020 -strictportbind \ +sv_pure 2 -game tf +maxplayers 24 \ -pidfile ${GAMEFOLDER}/tf/srcds1.pid \ -ugcpath ${GAMEFOLDER}/steamapps/workshop1 \ +exec autoexec1.cfg +servercfgfile server1.cfg" # ${GAMEFOLDER}/srcds_run ${CMDLINE}
( "-") ( "+"):
-port
. β 27015. , ,
-steamport
VAC (Valve Anti-Cheat). . 26900, 26901
+clientport
+tv_port
SourceTV. , +tv_port -nohltv
-strictportbind
, , "ERROR: Port 27015 was unavailable β quitting due to "-strictportbind" command-line flag!". .
-ip
ip , . - , 0.0.0.0 β . , , ip
-game
. β "tf" β Team Fortress 2.
+maxplayers
. . β 24, 32. Mann vs. Machine 32
-pidfile
PID .
-ugcpath
Steam Workshop. β ~/tf2/steamapps/workshop. , ~/tf2/tf. , workshop , .
+sv_pure
β , ( , , ). -1, 0, 1, 2. sv_pure 0 , , ( , ), , , . pure_server_full.txt, pure_server_minimal.txt pure_server_whitelist_example.txt ~/tf2/tf/cfg/. β sv_pure 2
, srcds_run, , .vpk .
+exec
, autoexec.cfg. .
+servercfgfile
, server.cfg β ,
+map
( ). , autoexec.cfg ( server.cfg !). , . . , autoexec.cfg
Valve Developer Community wiki
~/start2.sh, CMDLINE ( ), .
#!/bin/sh # . GAMEFOLDER=/home/game/tf2 CMDLINE="-port 27016 -steamport 26901 +clientport 27006 +tv_port 27021 -strictportbind \ +sv_pure 2 -game tf +maxplayers 24 \ -pidfile ${GAMEFOLDER}/tf/srcds2.pid \ -ugcpath ${GAMEFOLDER}/steamapps/workshop2 \ +exec autoexec2.cfg +servercfgfile server2.cfg" # ${GAMEFOLDER}/srcds_run ${CMDLINE}
$ chmod u+x ~/start{1,2}.sh
(- game, root !), -. :
... *** ~/cfg/autoexec.cfg (global) Writing cfg/banned_user.cfg. Writing cfg/banned_ip.cfg. -------------------------------------------------------- sv_pure set to 2. -------------------------------------------------------- maxplayers set to 24 *** ~/cfg/autoexec1.cfg Server logging enabled. Server logging data to file /home/game/log/server1/L1007000.log ... Executing dedicated server config file server1.cfg Using map cycle file 'cfg/mapcycle1.txt'. Set motd from file 'cfg/motd1.html' Set motd_text from file 'cfg/motd1.txt' Connection to game coordinator established. tf_server_identity_account_id not set; not logging into registered account *** ~/cfg/server1.cfg logaddress_delall: no addresses in the list logaddress_add: 192.0.2.0:27500 'cp_granary.cfg' not present; not executing. Connection to Steam servers successful. ...
, , . . , L1007000.log, l1007000.log. β Linux ! , β . . β .
, , .
... *** ~/cfg/autoexec2.cfg ... [TF Workshop] Waiting for steam connection [TF Workshop] Preparing map ID 454299390 [TF Workshop] Map ID 454299390 isn't tracked, adding ... [TF Workshop] New version available for map, download queued [ workshop/cp_orange_x3.ugc454299390 ] ... [TF Workshop] Installed subscribed map [ workshop/cp_orange_x3.ugc454299390 ] [TF Workshop] Successfully prepared client map from workshop [ workshop/cp_orange_x3.ugc454299390 ] ... 'workshop/cp_orange_x3.ugc454299390.cfg' not present; not executing. ...
, . Steam Workshop ~/tf2/steamapps/workshop2, ~/tf2/steamapps/workshop2/content/440/454299390/cp_orange_x3.bsp. , "[ workshop/cp_orange_x3.ugc454299390 ]" β , . , autoexec2.cfg
Team Fortress 2, "Find a game" β "Community servers" β "" β "" β ip "192.0.2.0" β " " β . :-). .
, - Valve Web API, ip http://api.steampowered.com/ISteamApps/GetServersAtAddress/v0001?addr=192.0.2.0 β source , Team Fortress 2
(quit, Ctrl+C), .
, srcds_run, , quit
, "Sat Jun 18 10:28:33 VOST 2016: Server restart in 10 seconds", Ctrl+C. , β 8 . - .
, , , , .
Valve , , :
β , β () . β Valve https://list.valvesoftware.com/cgi-bin/mailman/listinfo/hlds_linux . , "Optional TF2 update released" β . "Mandatory Team Fortress 2 update released" β . . , , β hlds_linux.
.
β :
CMDLINE="... -autoupdate -steam_dir /home/game/Steam -steamcmd_script /home/game/cfg/tf2_update \ ...
-autoupdate
.
-steam_dir
steam.sh steamcmd.sh
-steamcmd_script
, "-steam_dir",
, () ./srcds_run +runscript ~/cfg/tf2_update
~/cfg tf2_update β . , .
@ShutdownOnFailedCommand 0 @NoPromptForPassword 1 login anonymous force_install_dir /home/game/tf2/ app_update 232250 quit
:
@ShutdownOnFailedCommand
Valve "0" .
@NoPromptForPassword
, "1", Steam , login. , .
login <username> [<password>] [<Steam guard ode>]
Steam. , "ERROR! Failed to request AppInfo update, not online or not logged in to Steam." "anonymous" β . , , . Dedicated Servers List . , , steam guard, , set_steam_guard_code.
set_steam_guard_code <ode>
steam guard. .
force_install_dir
./SteamApps/common/< >. , . app_update.
app_update <appid> [-validate] [-language <lang>] [-beta <betaname>] [-betapassword <pwd>]
( ), . appid. validate β , , . , " ..." Steam, , . , , , , .
app_set_config <appid> <key> <value>
.
Steam , steamcmd.sh . help
, find <>
.
- Steam , .
:
^CMasterRequestRestart Your server will be restarted on map change. Your server will be restarted on map change. Your server needs to be restarted in order to receive the latest update. Your server needs to be restarted in order to receive the latest update.
:
L 07/08/2016 - 05:07:17: Your server will be restarted on map change. L 07/08/2016 - 05:07:17: Your server needs to be restarted in order to receive the latest update.
, ~/cfg/tf2_update , , . .
, , .
. , , . , ( mp_maxrounds, = 0), (mp_winlimit = 0), (mp_fraglimit = 0), (mp_timelimit = 0), , , , . , - , .
.
β cron steamcmd.sh (, "-"), .
, ~/Steam/steamcmd.sh +runscript ~/cfg/tf2_update
, steamcmd.sh :
... Connecting anonymously to Steam Public...Logged in OK Waiting for license info...OK Success! App '232250' already up to date.
, :
... Update state (0x61) downloading, progress: 99.63 (3616706682 / 3630011517) Update state (0x81) committing, progress: 100.00 (606937472 / 606937472) Success! App '232250' fully installed.
"fully installed" . . ~/update.sh:
#!/bin/sh ~/Steam/steamcmd.sh +login anonymous +force_install_dir /home/game/tf2/ +app_update 232250 +quit > ~/steamcmd.log if grep --quiet "fully installed" ~/steamcmd.log; then # kill `cat /home/game/tf2/tf/srcds1.pid` # ~/start1.sh & # kill `cat /home/game/tf2/tf/srcds2.pid` # ~/start2.sh & fi rm -f ~/steamcmd.log
, , steamcmd.sh β "+login anonymous +force_install_dir ~/tf2/ +app_update 232250 +quit", tf2_update β "+runscript ~/cfg/tf2_update"
, . , " ", tmux sudo, , . :
#!/bin/sh ~/Steam/steamcmd.sh +login anonymous +force_install_dir /home/game/tf2/ +app_update 232250 +quit > ~/steamcmd.log if grep --quiet "fully installed" ~/steamcmd.log; then echo "Update installed" tmux -L socket1 send-keys "say New update installed. Server will be restarted in 10 seconds. Please join us after a minute" Enter tmux -L socket2 send-keys "say New update installed. Server will be restarted in 10 seconds. Please join us after a minute" Enter sleep 10s sudo /usr/bin/systemctl reload srcds1.service sudo /usr/bin/systemctl reload srcds2.service else echo "Update not found" fi rm -f ~/steamcmd.log
crontab , :
$ chmod 744 ~/update.sh $ crontab -e
:
*/30 * * * * ~/update.sh
cron , game ""
, .
Valve Steam Web API . ISteamApps/UpToDateCheck, , Team Fortress 2 β http://api.steampowered.com/ISteamApps/UpToDateCheck/v1?appid=440&version=3528598 , version ( - ). appid = 232250 (, , ), "Couldn't get app info for the app specified.". Alas.
, , Team Fortress 2 dedicated server β https://api.steampowered.com/IGCVersion_440/GetServerVersion/v1?format=json . - :
{ "result": { "success": true, "deploy_version": 3531256, "active_version": 3531256, "min_allowed_version": 3528598 } }
β json, xml, vdf. β Valve Data Format , Valve, json . β items_game.txt, , .acf, .vdf .
, deploy_version active_version Valve , , . , , api.
version
, ~/tf2/tf/steam.inf
, , Web API, , . - :
#!/bin/sh wget -q --no-check-certificate "https://api.steampowered.com/IGCVersion_440/GetServerVersion/v1?format=json" -O=~/GameVersion.json VERSION_DEPLOYED=`grep deploy_version ~/GameVersion.json | sed -s 's/[^[:digit:]]//g'` VERSION_INSTALLED=`grep ServerVersion ~/tf2/tf/steam.inf | sed -s 's/[^[:digit:]]//g'` if [[ $VERSION_DEPLOYED -gt $VERSION_INSTALLED ]]; then echo "New update is ready, $VERSION_DEPLOYED vs $VERSION_INSTALLED" # - fi
, crontab.
, . , Steam Web API, ~/tf2/steamapps/appmanifest_232250.acf, "buildid". β steamcmd.sh +login anonymous +app_info_update 1 +app_info_print 232250 +quit
, "buildid" depots -> branches -> public ( app_info_print , , app_info_update 1. rm -f ~/Steam/appcache/appinfo.vdf). grep, cut, tr , , json ( sed + tr) .
" ".
Source: https://habr.com/ru/post/312922/
All Articles