找了非常多Linux安装饥荒的方法,都需要先安装steamcmd的依赖,再安装steamcmd,非常容易出错。官方推出steamcmd docker,非常方便。所以做个笔记。
steamcmd

第一步,开放端口

不加赘述。

第二步,安装docker

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

运行steamcmd docker

docker run -it \
-v "/home/steam:/home/steam/Steam" \
-v "/home/steamcmd:/home/steam/steamcmd" \
cm2network/steamcmd bash
#默认steamcmd.sh路径/home/steam/steamcmd

查看容器:docker ps -a
查看运行的容器:docker ps
停止容器:docker stop
删除容器:docker rm
1)查看host中的镜像
docker images
2)删除指定id的镜像
docker rmi
重启容器:docker restart 容器ID
重启容器后进入交互式:docker start -i 5c6ce895b979
进入容器:docker attach 容器ID
         docker exec -it 容器ID /bin/bash 

or 第二步:安装依赖

64位:

sudo apt-get install -y libstdc++6:i386 libgcc1:i386 libcurl4-gnutls-dev:i386

32位:

sudo apt-get install -y libstdc++6 libgcc1 libcurl4-gnutls-dev

or centos

sudo yum -y install glibc.i686 libstdc++.i686 libcurl4-gnutls-dev.i686 libcurl.i686 screen

Debian

sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install -y lib32gcc1
sudo apt-get install -y libcurl4-gnutls-dev:i386
sudo apt-get install -y screen

第三步,运行steamcmd并安装饥荒

cd /home/steam/steamcmd
./steamcmd.sh

出现“steam>”之后

login anonymous
force_install_dir /home/dstserver
app_update 343050 validate

等待下载完成。
linux下饥荒的服务器似乎需要的组件跟现在的组件产生了名字上的差错导致启动服务器会显示缺少关键的组件libcurl-gnutls.so.4,因此需要执行下面的命令来解决

ln -s /usr/lib/libcurl.so.4 /home/dstserver/bin/lib32/libcurl-gnutls.so.4

然后接着执行:

cd /home/dstserver/bin
echo "./dontstarve_dedicated_server_nullrenderer -console -persistent_storage_root /home/dstsave -conf_dir dst -cluster World1 -shard Master" > master_start.sh
echo "./dontstarve_dedicated_server_nullrenderer -console -persistent_storage_root /home/dstsave -conf_dir dst -cluster World1 -shard Caves" > cave_start.sh
chmod +x master_start.sh cave_start.sh

输入./master_start.sh启动主世界服务器
输入 ./cave_start.sh 启动洞穴服务器

第四步,创建房间

本地创建完成,返回服务器搜索页面,点击左下角的“游戏数据”,就会打开本地房间的文件目录,或者打开路径C:UsersxxxDocumentsKleiDoNotStarveTogether

这里面Cluster_1至Cluster_5就代表联机版的5个房间,按顺序一一对应

将Cluster_5里面的所有文件全部复制到Linux服务器下的/home/dstsave/dst/World1/目录下

第五步,获取服务器token

首先在刚刚看本地文件目录的那里点击“账户信息”
跳转至Klei页面,点击查看我的游戏
再点击右上角Don’t Strave Together Servers
然后拉倒最下面,输入“友好的名字(就是你这个token的名字,仅仅作为一个标识用)”,并点击“添加新的服务器”,这个时候就可以看到生成的token了
复制这个token,然后粘贴到服务器上面的cluster_token.txt文件里(你可以在Linux里面使用vim编辑,如果你不懂vim命令,可以在自己电脑上创建一个名叫“cluster_token.txt”的空文本,然后将token粘贴进去

第六步,配置mod

回到我们之前服务器的目录,下面有一个mods文件夹,进入这个文件夹

cd /home/dstserver/mods

这个时候你会在里面发现有一个dedicated_server_mods_setup.lua文件,里面一堆英文而且全都注释的,我们之所以没有mod是因为这个文件没有引入并下载mod,所以我们编辑这个文件,同样你可以在Linux里面使用vim编辑,如果你不懂vim命令,可以在自己电脑上创建一个名叫“dedicated_server_mods_setup.lua”的空文本

--There are two functions that will install mods, ServerModSetup and ServerModCollectionSetup. Put the calls to the functions in this file and they will be executed on boot.

--ServerModSetup takes a string of a specific mod's Workshop id. It will download and install the mod to your mod directory on boot.
    --The Workshop id can be found at the end of the url to the mod's Workshop page.
    --Example: http://steamcommunity.com/sharedfiles/filedetails/?id=350811795
    --ServerModSetup("350811795")

--ServerModCollectionSetup takes a string of a specific mod's Workshop id. It will download all the mods in the collection and install them to the mod directory on boot.
    --The Workshop id can be found at the end of the url to the collection's Workshop page.
    --Example: http://steamcommunity.com/sharedfiles/filedetails/?id=379114180
    --ServerModCollectionSetup("379114180")

ServerModSetup("786556008")
ServerModSetup("1530801499")
ServerModSetup("378160973")
ServerModSetup("375850593")
ServerModSetup("666155465")
ServerModSetup("1207269058")
ServerModSetup("1981709850")
ServerModSetup("1185229307")
ServerModSetup("2675609101")

--ServerModCollectionSetup("id")

其中ServerModSetup(“1216718131”)就是引入mod,括号里面的数字就是mod的id

第七步,配置管理员

首先准备好要做管理员的好友的KLEI用户ID,怎么看好友的KLEI用户ID?往下看
打开游戏,点击账户信息

然后进入之前的/home/dstsave/dst/World1目录,也就是第三步最后面cluster_token.txt存放的目录,使用vim命令(没有vim的可以用vi命令)创建一个名叫“adminlist.txt”的文件,并添加,一行一个

饥荒更新后,需要从steamcmd更新游戏来匹配相同的饥荒版本。

第三步,运行steamcmd并安装饥荒

 cd /home/steam/steamcmd
./steamcmd.sh

出现“steam>”之后

login anonymous
force_install_dir /home/dstserver
app_update 343050 validate
Last modification:March 15, 2022
如果觉得我的文章对你有用,请随意赞赏