Zh/SteamCMD

From Valve Developer Community
< Zh
Revision as of 09:16, 17 August 2016 by 872517414 (talk | contribs) (translation 4)
Jump to navigation Jump to search

Template:Otherlang2 Steam命令行客户端SteamCMD)是一个命令行版本的Steam客户端。它的主要用途是在一个命令行界面的Steam客户端上安装和更新各种可用的专用服务端。它适用于使用SteamPipe内容分发系统的游戏。所有游戏已经从旧的HLDSUpdateTool迁移到了SteamCMD。

下载 SteamCMD

Windows系统

1. 创建一个为SteamCMD准备的文件夹。

“例如”

C:\steamcmd

2. 下载Windows系统专用的SteamCMD:https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip

3. 解压Zip文件中的文件到文件夹。

Linux系统

1. 首先安装运行环境用以运行SteamCMD。

Ubuntu/Debian 64位

sudo apt-get -y install lib32gcc1

RedHat/CentOS 32位

sudo yum -y install glibc libstdc++

RedHat/CentOS 64位

sudo yum -y install glibc.i686 libstdc++.i686

2. 建议创建一个SteamCMD专用的用户。在任何情况下,请 不要root 身份下运行SteamCMD,这可能会导致严重的安全隐患! 运行以下命令以root身份创建“Steam”用户,并登录它:

useradd -m steam
su - steam

如果你喜欢使用 sudo,更换第二行代码为以下命令:

sudo -iu steam

3. 创建一个为SteamCMD准备的目录,并切换到它

mkdir ~/steamcmd
cd ~/steamcmd

3. 下载Linux系统专用的SteamCMD

wget https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz

4. 解压文件到目录。

tar -xf steamcmd_linux.tar.gz

macOS系统

1.打开终端并创建一个为SteamCMD准备的目录。

mkdir ~/steamcmd
cd ~/steamcmd

2. 下载macOS系统专用的SteamCMD。

curl -O https://steamcdn-a.akamaihd.net/client/installer/steamcmd_osx.tar.gz

3. 解压文件到目录。

tar -xvzf steamcmd_osx.tar.gz

运行 SteamCMD

在第一次运行SteamCMD时将自动更新并显示一个 Steam> 的输入提示。输入 help 来获取更多信息。

Windows系统

打开一个命令行窗口并启动SteamCMD。

cd C:\steamcmd
steamcmd

Linux/macOS系统

打开一个终端并启动SteamCMD。

cd ~/steamcmd
./steamcmd.sh

登录 SteamCMD

匿名登录

下载大多数游戏服务端,你可以选择匿名登录。

login anonymous

Steam帐户登录

一些服务端需要你使用一个Steam帐户来登录。

Note.png注意:为了安全起见建议您创建一个服务端专用的Steam帐户。
Note.png注意:一个用户同时只能在一处登录(无论是在图形界面客户端还是在SteamCMD登录)。
login <用户名>

下一步请输入您的密码。

如果Steam 令牌已经在用户帐户上激活,查看你电子邮箱中的Steam 令牌验证码并输入它。这仅仅只是第一次登录时需要(以及当你删除了SteamCMD用于存储登录信息文件的时候)。

如果你已经成功登录了你的帐户,你应该会看到一条消息。

下载一个应用

1. 打开SteamCMD并登录它。

2. 设置你的应用安装目录(注意:在Linux/macOS系统下使用正斜杠/,在Windows系统下使用反斜杠\)。

force_install_dir <路径>

例如 一个名叫cs_go的在当前目录下的目录:

force_install_dir ./cs_go/

在Windows系统: force_install_dir .\cs_go\

3. 安装或更新应用使用app_update命令(在这里提供Steam应用ID)。 要同时校验应用的话,需添加validate到命令里。要下载测试分支的话,使用-beta <测试名称>选项 – 例如,HLDS的测试分支名为beta以及SrcDS的测试分支名为prerelease。一些测试分支设置了密码;如果要从它那里下载,需同时添加-betapassword <密码>选项。

app_update <app_id> [-beta <测试名称>] [-betapassword <密码>] [validate]

HLDS is a special case: the App ID is always 90 and a mod must be chosen first. This is done by setting the app config option mod to the requested value.

app_set_config <app_id> <option_name> <option_value>
Example: Install and validate the Counter Strike: Global Offensive dedicated server:
app_update 740 validate
Example: Install and validate HLDS with Team Fortress Classic:
app_set_config 90 mod tfc
app_update 90 validate
Icon-Bug.png错误:HLDS (appid 90) currently requires multiple runs of the app_update command before all the required files are successfully installed. Simply run app_update 90 validate multiple times until no more updates take place.  [todo tested in ?]
Example: Install and validate beta version of HLDS (Half-Life):
app_update 90 -beta beta validate
Example: install and validate beta version of the Counter Strike: Source dedicated server:
app_update 232330 -beta prerelease validate
Example: install and validate a private beta version of the Natural Selection 2 dedicated server (name alpha, password natsel):
[beta name] is the name of the private beta branch
[beta code] is the password for the private beta branch
app_update 4940 -beta alpha -betapassword natsel validate

3. Once finished, type quit to properly log off of the Steam servers.

quit

Validate

validate

Validate is a command that will check all the server files to make sure they match the SteamCMD files. This command is useful if you think that files may be missing or corrupted.

Note.png注意:Validation will overwrite any files that have been changed. This may cause issues with customized servers. For example, if you customize mapcycle.txt, this file will be overwritten to the server default. Any files that are not part of the default installation will not be affected.

It is recommended you use this command only on initial installation and if there are server issues.

Supported Servers

A list of known servers that use SteamCMD to install is available on the Dedicated Servers List page. Note that any extra commands listed need to be executed before the app_update line.

Automating SteamCMD

There are two ways to automate SteamCMD. (Replace steamcmd with ./steamcmd.sh on Linux/OS X.)

Command line

Note.png注意:When using the -beta option on the command line, it must be quoted in a special way, such as +app_update "90 -beta beta".
Note.png注意:If this does not work, try putting it like "+app_update 90 -beta beta" instead.

Append the commands to the command line prefixed with plus characters, e.g.:

steamcmd +login anonymous +force_install_dir ../csgo_ds +app_update 740 +quit

To install a specific game mod for HL1, such as Counter-Strike: Condition Zero:

steamcmd +login anonymous +force_install_dir ../czero +app_set_config 90 mod czero +app_update 90 +quit

For a game that requires logins, like Killing Floor:

steamcmd +login <username> <password> +force_install_dir c:\KFServer\ +app_update 215350 +quit

Creating a script

1. Put your SteamCMD commands in a text file. (You may add comments which start with //.) Example:

// update_csgo_ds.txt
//
@ShutdownOnFailedCommand 1 //set to 0 if updating multiple servers at once
@NoPromptForPassword 1
login <username> <password>
//for servers which don't need a login
//login anonymous 
force_install_dir ../csgo_ds
app_update 740 validate
quit

2. Run SteamCMD with the +runscript option, referring to the file you created previously. Example:

steamcmd +runscript csgo_ds.txt

Cross-Platform Installation

It is possible to choose the platform for which SteamCMD should download files, even if it isn't the platform it is currently running on. This is done using the @sSteamCmdForcePlatformType variable. (Yes, those are two "s"es at the beginning of the variable name.) For example, to download the Windows CSGO dedicated server on Linux, you can run the following command:

./steamcmd.sh +@sSteamCmdForcePlatformType windows +login anonymous +force_install_dir ../csgo_ds +app_update 740 validate +quit

or use the following script:

@ShutdownOnFailedCommand 1
@NoPromptForPassword 1
@sSteamCmdForcePlatformType windows
login anonymous
force_install_dir ../csgo_ds
app_update 740 validate
quit

The supported values are windows, macos and linux.

Windows Software/Scripts

condenser

condenser is a bootstrapper for installing, configuring, & launching Steam dedicated server apps.

SteamCMD AutoUpdater

Install and automaticly update any game server

GitHub Repo: https://github.com/C0nw0nk/SteamCMD-AutoUpdate-Any-Gameserver

SteamCMD GUI

This tool allows the user to use SteamCMD on Windows without command lines and/or batch files.

GitHub Repo: https://github.com/DioJoestar/SteamCMD-GUI

SteamCMD Guardian 1.2

View and download here: http://pastebin.com/BRUbsGQh

Linux Scripts

Linux Game Server Managers

Linux Game Server Manager

The Linux Game Server Managers are command line tools for quick, simple deployment and management of various dedicated game servers using SteamCMD.

Features

  • Server installer (SteamCMD)
  • Start/Stop/Restart server
  • Server update (SteamCMD)
  • Server monitor (including email notification)
  • Server details
  • Server backup
  • Server console

Supported Servers

There are now 40+ different game servers supported and rising. For a full list visit the website.

Links

Website: http://gameservermanagers.com

GitHub Repo: https://github.com/dgibbs64/linuxgsm

Steam-cmd-installer

This script will automate the process of installing SteamCMD with the optional choice of installing a game. This script is currently tested on Ubuntu but confirmed working on Ubuntu,Mint,centos,ZorinOS and debian

How to Install

  1. Firstly create a user for SteamCMD “adduser steam”.
  2. Create a new file using nano or vi called “steamcmdinstaller.sh ".
  3. Find most recent version of steamcmdinstaller.sh from https://github.com/Gousaid67/steam-cmd-installer and paste it in to the newly created file.
  4. Make the script executable with chmod +x steamcmdinstaller.sh .
  5. Run the script ./steamcmdinstaller.sh . You will be prompted to enter various settings.
  6. The script will now automatically download and install SteamCMD. You will also have the option to install a game server of your choice b giving it an appid.

Optional: define a custom path

The script can use custom path outside of /home/user/ but it require editing the script. Thanks to dvdvideo1234 for his help on that feature

  1. do the 4 first step indicated up there.
  2. then do ./"scriptname".sh "custom path" and follow the usual instruction. the script will not work if you set path on restricted directories such as /etc

SteamCMD Guardian 1.2

The following script was tested on Debian Wheezy.

View and download here: http://pastebin.com/hcpMpmaZ


Installation

To make this script work, we need a location. Preferrably you created a user (e.g. steam) with it's own home directory (/home/steam) and are logged in as it via SSH, tty or using su.

  1. Make the file.
    nano updateserver.sh
  2. Paste in the code
  3. Modify the code, add at least 1 game to the DL_SV*= rows.
  4. Close the file with Ctrl+O, followed by Enter and concluding with Ctrl+X.
  5. Give the file execute rights for the user
    chmod u+x ./updateserver.sh
  6. Run the file
    ./updateserver.sh

The file will auto-download SteamCMD, update it and install all chosen games (up to 4). Run the file again to update the games.

Known issues

ERROR! Failed to install app 'xxxxxx' (No subscription)

If you get the 'No subscription' error, the game/server you are trying to download either requires a login or that you have purchased the game. You will therefore have to log in with a Steam username and password – if that doesn't help, you may need to purchase a copy of the game on Steam first. See Dedicated Servers List.

Note.png注意:For security reasons it is recommended that you create a new Steam account just for your dedicated servers.

For example

steamcmd +login <username> <password>

32-bit libraries on 64-bit Linux systems

Since SteamCMD is a 32-bit binary, 32-bit libraries are required.

The following error may occur:

steamcmd: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory

The resolution depends on your distro:

Debian based distributions (Ubuntu, Mint, etc.)

sudo apt-get install lib32stdc++6
Note.png注意:ia32-libs are not required to install SteamCMD; lib32gcc1 is enough.

With Debian 7 "Wheezy" you may encounter this error:

The following packages have unmet dependencies: ia32-libs : Depends: ia32-libs-multiarch but it is not installable
E: Unable to correct problems, you have held broken packages.

To fix this, do the following:

 dpkg --add-architecture i386
 apt-get update
 apt-get install lib32gcc1

Red Hat based distributions (RHEL, Fedora, CentOS, etc.)

yum install glibc.i686 libstdc++.i686

Arch Linux

Don't forget to first enable the multilib repository.

pacman -S lib32-gcc-libs

Login Failure: No Connection

On linux servers, you may experience a "Login Failure: No Connection" error. This is related to missing iptables rules. You will want something along these lines:

iptables -A INPUT -p udp -m udp --sport 27000:27030 --dport 1025:65355 -j ACCEPT
iptables -A INPUT -p udp -m udp --sport 4380 --dport 1025:65355 -j ACCEPT

The port list is found here: https://support.steampowered.com/kb_article.php?ref=8571-GLVN-8711&l=english

On Windows servers, you may experience "SteamUpdater: Error: Download failed: http error 0" and "SteamUpdater: Error: Steam needs to be online to update. Please confirm your network connection and try again.". This is usually fixed by checking "Automatically detect settings" in IE (Internet Explorer) through the lan settings in the Internet option menu.

  1. Open Internet Explorer (IE).
  2. Click on ToolsInternet Options
  3. Click on the Connections tab
  4. At the bottom, you should see Local Area Network (LAN) Settings.
  5. Check the first box (Automatically detect settings)
  6. Hit OK, and Apply. Try running the SteamCMD again; if it still doesn't work. try lowering your Internet Security level zone to medium or lower. You can find that in the Security tab in Internet Options.

SteamCMD startup errors

Unable to locate a running instance of Steam

You may get the following error when starting a server with Linux:

[S_API FAIL] SteamAPI_Init() failed; unable to locate a running instance of Steam, or a local steamclient.dll.

Resolve the issue by linking steamclient.so to the ~/.steam/sdk32/steamclient.so directory:

ln -s steamcmd/linux32/steamclient.so ~/.steam/sdk32/steamclient.so

ulimit Linux startup error

Some users may get a ulimit error (no permission/cannot open file) while script is starting up. This error caused by a low setting of the -n parameter (number of file descriptors) of ulimit. SteamCMD uses standard commands inside of the initialization shell script to change the ulimit automatically, but some servers may forbid increasing ulimit values after startup (or beyond a limit set by root).

This can be fixed by changing the file descriptor number ulimit:

ulimit -n 2048

If an error appears (no permission), you will have to log in as root to change the parameter. To check the current setting, type ulimit -a; the system will reply with many rows, you need to find one:

open files                      (-n) 1024

In this case, 1024 is the current value.

root can also modify the limits in the /etc/security/limits.conf file.

In most instances you will simply get a warning message however it will not stop SteamCMD from running.

Only the HLDS engine is downloaded

When trying to download a HL1 mod like TFC, initially it only downloads the engine files of the HLDS, but not the mod. This happens with both the regular version and the beta. You may have to try multiple times until all the required files are downloaded, but once this is done, the files should update correctly next time.

Work-around for this issue here: http://danielgibbs.co.uk/2013/11/hlds-steamcmd-workaround-appid-90/

Just deleting the appmanifest files, without downloading replacements from a third party, may work as well! You will get an error at first though, complaining that something went wrong, which is due to the deleted files.

On a side note, for some reason CS is always installed as well.

See Also