搭建饥荒独立服务器

使用是的Ubuntu16.04,64位。

安装SteamCMD

准备目录及下载文件

1
2
# 安装依赖
sudo apt-get install lib32gcc1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 创建用户
useradd -m steam
# 设置密码
sudo passwd steam
# 切换用户
su steam

# 创建目录
mkdir ~/steamcmd
cd ~/steamcmd
# 下载安装
curl -sqL "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | tar zxvf -
# 运行命令
./steamcmd.sh

配置服务器

安装依赖

1
2
3
4
5
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install lib32gcc1
sudo apt-get install lib32stdc++6
sudo apt-get install libcurl4-gnutls-dev:i386

创建目录

1
2
mkdir -p ~/.klei/DoNotStarveTogether/MyDediServer/Master
mkdir -p ~/.klei/DoNotStarveTogether/MyDediServer/Caves

生成token

  • 从steam上运行饥荒 点击play
  • 点击Acct Info按钮
  • 点击”Generate Server Token“ 按钮并复制token粘贴到一下文件中
    ~/.klei/DoNotStarveTogether/MyDediServer/cluster_token.txt

创建cluster.ini 文件

拷贝以下内容到~/.klei/DoNotStarveTogether/MyDediServer/cluster.ini

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[GAMEPLAY]
game_mode = survival
max_players = 6
pvp = false
pause_when_empty = true


[NETWORK]
cluster_description = This server is super duper!
cluster_name = Super Server
cluster_intention = cooperative
cluster_password =


[MISC]
console_enabled = true


[SHARD]
shard_enabled = true
bind_ip = 127.0.0.1
master_ip = 127.0.0.1
master_port = 10889
cluster_key = supersecretkey

其中NETWORK部分,按自己需要配置

创建你主机的server.ini

将下面内容保存到~/.klei/DoNotStarveTogether/MyDediServer/Master/server.ini

1
2
3
4
5
6
7
[NETWORK]
server_port = 11000
[SHARD]
is_master = true
[STEAM]
master_server_port = 27018
authentication_port = 8768

建Caves server.ini文件

将下面内容保存到~/.klei/DoNotStarveTogether/MyDediServer/Caves/server.ini

1
2
3
4
5
6
7
8
[NETWORK]
server_port = 11001
[SHARD]
is_master = false
name = Caves
[STEAM]
master_server_port = 27019
authentication_port = 8769

创建 Caves worldgenoverride.lua 文件

将下面内容保存到~/.klei/DoNotStarveTogether/MyDediServer/Caves/worldgenoverride.lua

1
2
3
4
return {
override_enabled = true,
preset = "DST_CAVE",
}

创建将运行服务的脚本

将下列的内容保存到~/run_dedicated_servers.sh文件中

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash

steamcmd_dir="$HOME/steamcmd"
install_dir="$HOME/steamapps/DST"
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/bin"

cd "$install_dir/bin" || fail

run_shared=(./dontstarve_dedicated_server_nullrenderer)
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: /'

运行专有服务器的启动脚本

1
bash ~/run_dedicated_servers.sh

安装模组

先是安装模组
进入游戏安装目录中mod目录下,编辑dedicated_server_mods_setup.lua 文件,添加如下内容:

1
ServerModSetup("758532836")

id就是模组id。

再是启用模组
编辑Master配置文件目录下的 modoverrides.lua

1
2
3
return {
["workshop-758532836"]={ configuration_options={ }, enabled=true },
}

返回这样的配置,表示启用模组

附录

Steam cmd的相关操作

因为那个运行脚本中已经包含下载游戏的动作了,这些就可以不用了。

1
2
3
# 登录
Steam>login <用户名>

这个页面可以看到有哪些可以做为独立服务的游戏,也有游戏ID。
比如Don't Starve Together Dedicated Server的ID为343050

1
2
# 设置游戏下载目录
Steam>force_install_dir /home/steam/steamapps/DST
1
2
# 下载游戏
Steam>app_update 343050 validate
1
2
# 退出
Steam>quit

防火墙规则

参考


搭建饥荒独立服务器
https://blog.fengcl.com/2018/08/02/dont-starve-together-dedicated-servers/
作者
frank
发布于
2018年8月2日
许可协议