系列文章

  1. 饥荒服务器配置
  2. Linux基本操作

CentOS饥荒服务器

准备部分

  1. sudo yum -y install glibc.i686 libstdc++.i686安装SteamCMD的运行环境,这里有可能会出一个小bug,如果运行饥荒时发现

    error while loading shared libraries: libcurl-gnutls.so.4: cannot open shared object file: No such file or directory

    即没有libcurl4-gnutls-dev,按照饥荒联机版独立服务器搭建踩坑记录,可以直接安装libcurl然后做软连接

    cd /usr/lib/
    ln -s libcurl.so.4 libcurl-gnutls.so.4
  2. 使用非root用户登录,但该用户可能会需要sudo权限

    useradd -m steam
    su - steam

安装SteamCMD和饥荒本体

  1. 在用户文件中创建安装目录并进入该目录

    mkdir ~/steamcmd && cd ~/steamcmd
  2. 下载并解压SteamCMD客户端

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

    然后./steamcmd.sh运行

  3. 匿名登录SteamCMD

    # 匿名登录,没必要用用户名密码登录
    login anonymous
    # 这里我们强制要 Steam 把饥荒服务端安装到此目录下
    # 最好用绝对路径,否则可能会安装到奇怪的地方去
    force_install_dir /home/steamcmd/dst
    app_update 343050 validate
    quit

注意:如果上面 SteamCMD 里没有用 force_install_dir 强制指定安装目录的话,服务端默认是安装到 ~/Steam/steamapps/common/Don't Starve Together Dedicated Server 目录下的

此外:升级Steam的命令是./steamcmd.sh +login anonymous +force_install_dir ~/dst +app_update 343050 validate +quit,即重复一遍命令

饥荒配置

存档迁移

  1. 打开你的本地存档(默认在我的电脑\文档\KleiDoNotStarveTogether\一串数字\*Cluster_1),修改服务器Cluster_1文件夹里创建cluster_token.txt,其中的内容为Server Token
  2. 在xshell下使用lrzz,将游戏存档文件夹复制到~/.klei/DoNotStarveTogether/中.klei是隐藏文件夹,如果要查看,需要在上级文件夹中使用ls -la命令

Mods

  1. 下载Mod是在steam的全局行为,在~/steamcmd/dst/mods/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("458940297")
    ServerModSetup("375859599")
    ServerModSetup("375850593")
    ServerModSetup("343762271")
    ServerModSetup("347079953")
    ServerModSetup("556027744")
    ServerModSetup("444438334")
    ServerModSetup("378160973")

  2. Mod是否启用及配置则是modoverrides.lua文件,这个文件需要在Master(地面)和Caves(洞穴)需要各有一份,位于~/.klei/DoNotStarveTogether/Servername/ 中,语法举例如下

    ["workshop-362175979"]={ configuration_options={ ["Draw over FoW"]="disabled"
    }, enabled=true },
    ["workshop-363459814"]={ configuration_options={ }, enabled=true },
    ["workshop-375859599"]={
    configuration_options={
    divider=5,
    random_health_value=0,
    random_range=0,
    send_unknwon_prefabs=false,
    show_type=0,
    unknwon_prefabs=1,
    use_blacklist=true
    },
    enabled=true
    },
    ["workshop-378160973"]={
    configuration_options={
    ENABLEPINGS=true,
    FIREOPTIONS=2,
    OVERRIDEMODE=false,
    SHAREMINIMAPPROGRESS=true,
    SHOWFIREICONS=true,
    SHOWPLAYERICONS=true,
    SHOWPLAYERSOPTIONS=2
    },
    enabled=true
    },
  3. 饥荒本身文件配置,虽然最好在windows上面配置好,但是也可以参考这篇文章

启动脚本

分别建立地上世界和caves的启动脚本

cd ~/dst/bin/
echo ./dontstarve_dedicated_server_nullrenderer -console -cluster MyDediServer -shard Master > dst_overworld.sh //出现Your Server Will Not Start后,按Ctrl+C终止进程
echo ./dontstarve_dedicated_server_nullrenderer -console -cluster MyDediServer -shard Caves > dst_caves.sh

启动游戏

cd ~/dst/bin
screen sh ./dst_overworld.sh
screen sh ./dst_caves.sh

总之就是在两个screen中分别运行地上和地下世界,不玩的时候用c_shutdown()关闭

最后

文件树

/home/username/.klei/DoNotStarveTogether\Servername
|
| adminlist.txt(/adminlist.txt)
| blocklist.txt(/blocklist.txt)
| cluster.ini(/cluster.ini)
| cluster_token.txt(/cluster_token.txt)
| whitelist.txt(/whitelist.txt)
|
|---Master
| | modoverrides.lua(/Master/modoverrides.lua)
| | server.ini(/Master/server.ini)
| | worldgenoverride.lua(/Master/worldgenoverride.lua)
| | 其他文件
| |
| |---其他文件夹
|
|---Caves
| modoverrides.lua(/Caves/modoverrides.lua)
| server.ini(/Caves/server.ini)
| worldgenoverride.lua(/Caves/worldgenoverride.lua)
| 其他文件
|
|---其他文件夹

mods下载配置

/home/username/steamcmd/dst/mods
|
| dedicated_server_mods_setup.lua(/dedicated_server_mods_setup.lua)