<h1>安装</h1>
<p>本教程以 debian11 x64 系统安装
<p>linux专服指steam,因为wegame专服只能在windows上运行
<h2>安装依赖</h2>
添加apt源,把下面内容添加到<code>/etc/apt/sources.list</code>文件里
<pre>deb http://mirrors.huaweicloud.com/debian/ buster main</pre>
添加好之后更新系统
<pre>
apt update
apt upgrade
</pre>
安装依赖
<pre>apt install lib32gcc1 libcurl4-gnutls-dev</pre>
添加一个用户名为dst的用户,并切换
<pre>
useradd -m dst
su - dst
</pre>
<h2>下载安装</h2>
下载安装steamcmd
<pre>mkdir ~/steamcmd
cd steamcmd
wget https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz
tar -xvzf steamcmd_linux.tar.gz
</pre>
下载游戏,查看依赖并尝试首次运行
<pre>
./steamcmd.sh +login anonymous +force_install_dir ~/dst_server +app_update 343050 validate +quit
cd ~/dst_server/bin64
ldd dontstarve_dedicated_server_nullrenderer_x64
./dontstarve_dedicated_server_nullrenderer_x64
</pre>
如无意外你会看到Your Server Will Not Start说明安装成功,按ctrl+c结束进程
<p><img src="https://wiki.flapi.cn/lib/exe/fetch.php?media=02%E8%81%94%E6%9C%BAmod%E5%8C%BA:%E5%BC%80%E6%9C%8D%E6%95%99%E7%A8%8B:not_start.png" width="400">
<p>下载启动脚本,添加执行权限,放到/home/dst,重命名为run_dst.sh</p>
<pre>wget https://accounts.klei.com/assets/gamesetup/linux/run_dedicated_servers.sh</pre>
脚本内容:
<pre>
#!/bin/bash
steamcmd_dir="$HOME/steamcmd"
install_dir="$HOME/dontstarvetogether_dedicated_server"
cluster_name="MyDediServer"
dontstarve_dir="$HOME/.klei/DoNotStarveTogether"
function fail()
{
echo Error: "$@" >&2
exit 1
}
function check_for_file()
{
if [ ! -e "$1" ]; then
fail "Missing file: $1"
fi
}
cd "$steamcmd_dir" || fail "Missing $steamcmd_dir directory!"
check_for_file "steamcmd.sh"
check_for_file "$dontstarve_dir/$cluster_name/cluster.ini"
check_for_file "$dontstarve_dir/$cluster_name/cluster_token.txt"
check_for_file "$dontstarve_dir/$cluster_name/Master/server.ini"
check_for_file "$dontstarve_dir/$cluster_name/Caves/server.ini"
./steamcmd.sh +force_install_dir "$install_dir" +login anonymous +app_update 343050 validate +quit
check_for_file "$install_dir/bin64"
cd "$install_dir/bin64" || fail
run_shared=(./dontstarve_dedicated_server_nullrenderer_x64)
run_shared+=(-console)
run_shared+=(-cluster "$cluster_name")
run_shared+=(-monitor_parent_process $$)
"${run_shared[@]}" -shard Caves | sed 's/^/Caves: /' &
"${run_shared[@]}" -shard Master | sed 's/^/Master: /'
</pre>
<p>里面的"$HOME"是绝对路径"/home/dst"
<p>"steamcmd_dir"是steamcmd安装目录
<p>"install_dir"是游戏安装目录,本教程为"$HOME/dst_server"
<p>"cluster_name"为存档名,默认为Cluster_1,这里设置为"MyDediServer"
<p>"dontstarve_dir"为存档路径
<p>上面4项根据自己实际情况改,如果跟本教程一样,只需改动下"install_dir"就行
<p>另外第29行,去掉validate(验证),改为./steamcmd.sh +force_install_dir "$install_dir" +login anonymous +app_update 343050 +quit
<p>如不去掉,则会重置mod设置文件
<p>删掉"/home/dst/.klei/DoNotStarveTogether"目录下默认存档Cluster_*
<h1>配置</h1>
<p>打开网站https://accounts.klei.com/ 并登录,点击“游戏”——“《饥荒:联机版》的游戏服务器”
<p><img src="https://wiki.flapi.cn/lib/exe/fetch.php?media=02%E8%81%94%E6%9C%BAmod%E5%8C%BA:%E5%BC%80%E6%9C%8D%E6%95%99%E7%A8%8B:%E7%BE%A4%E9%9B%86%E5%90%8D.png">
<p>群集名随便写,然后添加
<p>添加好之后,点击“配置服务器”,根据自己需求填写,填好之后点击“下载设置”
<p><img src="https://wiki.flapi.cn/lib/exe/fetch.php?media=02%E8%81%94%E6%9C%BAmod%E5%8C%BA:%E5%BC%80%E6%9C%8D%E6%95%99%E7%A8%8B:%E9%85%8D%E7%BD%AE.png">
<p><img src="https://wiki.flapi.cn/lib/exe/fetch.php?media=02%E8%81%94%E6%9C%BAmod%E5%8C%BA:%E5%BC%80%E6%9C%8D%E6%95%99%E7%A8%8B:%E9%85%8D%E7%BD%AE2.png">
<p>解压之后打开 “cluster.ini”文件,记录“master_port = ”后面的端口号,然后再记录下Master和Caves目录下“server.ini”文件里"server_port =" 后面的端口号
<p>3个端口一起添加到云服务器的防火墙,只添加udp协议就行,多个端口一般逗号隔开
<p>“cluster.ini”文件里可加上以下内容
<pre>
[NETWORK]
whitelist_slots = 2
cluster_language = zh
[MISC]
max_snapshots = 6
</pre>
<p>“whitelist_slots = 2”白名单保留通道2
<p>“cluster_language = zh”中文
<p>“max_snapshots = 6”最大快照6
<p>然后把MyDediServer文件夹上传到服务器“/home/dst/.klei/DoNotStarveTogether”
<h1>mod添加</h1>
<p>打开游戏目录"/home/dst/dst_server/mods"
<p><img src="https://wiki.flapi.cn/lib/exe/fetch.php?media=02%E8%81%94%E6%9C%BAmod%E5%8C%BA:%E5%BC%80%E6%9C%8D%E6%95%99%E7%A8%8B:mods%E7%9B%AE%E5%BD%95.png">
<p>编辑“dedicated_server_mods_setup.lua”
<p>去创意工坊找到mod id
<p>按格式填写:
<p>这是添加Mod id
<pre>ServerModSetup("1699194522")</pre>
<p>这是添加合集id
<pre>ServerModCollectionSetup("1699194522")</pre>
<p><img src="https://wiki.flapi.cn/lib/exe/fetch.php?media=02%E8%81%94%E6%9C%BAmod%E5%8C%BA:%E5%BC%80%E6%9C%8D%E6%95%99%E7%A8%8B:%E5%90%88%E9%9B%86.png">
<p>关于Mod配置,可以在本地创建游戏,配置好之后生成存档,然后找到存档目录"Cluster_*\Master"下"modoverrides.lua"文件
<p>上传到服务器"/home/dst/.klei/DoNotStarveTogether/MyDediServer/Master"目录
<p>世界生成文件为leveldataoverride.lua可一并上传
<p>洞穴为Caves,操作同上
<p><img src="https://wiki.flapi.cn/lib/exe/fetch.php?media=02%E8%81%94%E6%9C%BAmod%E5%8C%BA:%E5%BC%80%E6%9C%8D%E6%95%99%E7%A8%8B:mod%E8%AE%BE%E7%BD%AE.png">
<p>最后添加管理员和黑白名单
<p>在"/home/dst/.klei/DoNotStarveTogether/MyDediServer" 目录下新建adminlist.txt(管理员名单),blocklist.txt(黑名单),whitelist.txt(白名单)
<p>adminlist.txt里面填写“Klei用户ID”,一行一个;可以在官方网站查看,或服务端日志("/home/dst/.klei/DoNotStarveTogether/MyDediServer/Master/server_log.txt")里查看
<p>黑白名单填写Steam ID,server_log里可以查看
<p><img src="https://wiki.flapi.cn/lib/exe/fetch.php?media=02%E8%81%94%E6%9C%BAmod%E5%8C%BA:%E5%BC%80%E6%9C%8D%E6%95%99%E7%A8%8B:%E9%BB%91%E7%99%BD%E5%90%8D%E5%8D%95.png">
<p>最后输入“exit”切换回root用户
<p>设置下存档目录权限 <pre>chown -R dst /home/dst/.klei</pre>
<h1>添加服务</h1>
<p>在/etc/systemd/system下新建dst.service,权限644
<p>内容如下:
<pre>
[Unit]
Description=DST Service
Documentation=dst.service
After=network.target nss-lookup.target
[Service]
User=dst
ExecStart=/home/dst/run_dst.sh
GuessMainPID=no
WorkingDirectory=/home/dst/dst_server/bin64
Restart=always
RestartSec=10s
[Install]
WantedBy=multi-user.target
</pre>
<p>刷新系统服务配置
<pre>systemctl daemon-reload</pre>
查看服务状态
<pre>systemctl status dst</pre>
设置开机启动
<pre>systemctl enable dst</pre>
启动服务
<pre>systemctl start dst</pre>
停止服务
<pre>systemctl stop dst</pre>
重启服务
<pre>systemctl restart dst</pre>
设置计划任务,定时重启,输入命令
<pre>crontab -e</pre>
最下面输入
<pre>01 06 * * * systemctl restart dst</pre>
每天6点01分重启服务
<p>如果大厅界面延迟是3个问号,等一会就好了