快速搭建饥荒游戏服务器

2020-10-23 16:05:07 浏览数 (1)

# 环境

  • 系统:Ubuntu18.04
  • 配置:1 CPU 4G RAM 2M 带宽 50G 硬盘

# 安装依赖

代码语言:javascript复制
$ sudo apt-get install libstdc  6:i386 libgcc1:i386 libcurl4-gnutls-dev:i386

1

# 添加用户

代码语言:javascript复制
# 添加用户 steam
$ sudo useradd -m steam

# 设置用户密码
$ sudo passwd steam

# 切换到用户
$ su - steam

1 2 3 4 5 6 7 8

# 安装 steamcmd

代码语言:javascript复制
# 新建目录 steamcmd
$ mkdir ~/steamcmd

# 进入目录
$ cd ~/steamcmd

# 下载 steamcmd
$ wget https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz

# 解压
$ tar -xvzf steamcmd_linux.tar.gz

1 2 3 4 5 6 7 8 9 10 11

# 安装饥荒

代码语言:javascript复制
# 执行安装脚本
$ ./steamcmd.sh

# 匿名登录
$ login anonymous

# 设置安装路径(绝对路径)
force_install_dir /home/steam/steamapps/dst

# 安装饥荒
app_update 343050 validate

# 成功后退出脚本
quit

1 2 3 4 5 6 7 8 9 10 11 12 13 14

# 新建一个存档

代码语言:javascript复制
# 进入存档目录
$ cd ~/.klei/DoNotStarveTogether

# 新建存档
$ mkdir Cluster_1

1 2 3 4 5

一个存档应该有的基础目录与文件:

代码语言:javascript复制
- Cluster_1
    |- cluster.ini              # 存档配置
    |- cluster_token.txt        # 服务器授权码
    |- adminlist.txt            # 管理员配置,一行一个用户 ID
    |- Master                   # 地面
        |- server.ini           # 服务配置
        |- worldgenoverride.lua # 世界配置
        |- modoverrides.lua     # Mod 配置
    |- Caves                    # 洞穴
        |- server.ini           # 服务配置
        |- worldgenoverride.lua # 世界配置
        |- modoverrides.lua     # Mod 配置

1 2 3 4 5 6 7 8 9 10 11 12

# cluster.ini

代码语言:javascript复制
[GAMEPLAY]
game_mode = endless
max_players = 6
pvp = false
pause_when_empty = true

[NETWORK]
cluster_name = ?小鸽鸽?的休闲养生之旅
cluster_description = 642779596
cluster_intention = social
cluster_password = 123456
offline_cluster = false
cluster_language = zh

[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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23

# cluster_token.txt

获取

代码语言:javascript复制
pds-g^KU_*****************=

1

# adminlist.txt

获取

代码语言:javascript复制
KU_***_****

1

# Master - server.ini

代码语言:javascript复制
[NETWORK]
server_port = 10999

[SHARD]
is_master = true

[STEAM]
master_server_port = 27018
authentication_port = 8768

[ACCOUNT]
encode_user_path = true

1 2 3 4 5 6 7 8 9 10 11 12

# Caves - server.ini

代码语言:javascript复制
[NETWORK]
server_port = 10998

[SHARD]
is_master = false
name = Caves
id = 2281682938

[STEAM]
master_server_port = 27019
authentication_port = 8769

[ACCOUNT]
encode_user_path = true

1 2 3 4 5 6 7 8 9 10 11 12 13 14

# Master - leveldataoverride.lua

代码语言:javascript复制
return {
  desc="你的地盘,你做主",
  hideminimap=false,
  id="CUSTOM_PRESET_1",
  location="forest",
  max_playlist_position=999,
  min_playlist_position=0,
  name="自定义预设 1",
  numrandom_set_pieces=4,
  override_level_string=false,
  overrides={
    alternatehunt="default",
    angrybees="default",
    antliontribute="default",
    autumn="default",
    bearger="default",
    beefalo="default",
    beefaloheat="default",
    bees="default",
    berrybush="default",
    birds="default",
    boons="often",
    branching="most",
    butterfly="default",
    buzzard="default",
    cactus="default",
    carrot="default",
    catcoon="default",
    chess="default",
    day="default",
    deciduousmonster="default",
    deerclops="default",
    disease_delay="none",
    dragonfly="default",
    flint="default",
    flowers="default",
    frograin="default",
    goosemoose="default",
    grass="default",
    has_ocean=true,
    houndmound="default",
    hounds="default",
    hunt="default",
    keep_disconnected_tiles=true,
    krampus="default",
    layout_mode="LinkNodesByKeys",
    liefs="default",
    lightning="default",
    lightninggoat="default",
    loop="default",
    lureplants="default",
    marshbush="default",
    merm="default",
    meteorshowers="default",
    meteorspawner="default",
    moles="default",
    mushroom="default",
    no_joining_islands=true,
    no_wormholes_to_disconnected_tiles=true,
    penguins="default",
    perd="default",
    petrification="few",
    pigs="default",
    ponds="default",
    prefabswaps_start="classic",
    rabbits="default",
    reeds="default",
    regrowth="veryfast",
    roads="default",
    rock="default",
    rock_ice="default",
    sapling="default",
    season_start="default",
    specialevent="year_of_the_gobbler",
    spiders="default",
    spring="default",
    start_location="plus",
    summer="default",
    tallbirds="default",
    task_set="default",
    tentacles="default",
    touchstone="default",
    trees="default",
    tumbleweed="default",
    walrus="default",
    weather="default",
    wildfires="default",
    winter="default",
    world_size="huge",
    wormhole_prefab="wormhole"  
  },
  random_set_pieces={
    "Sculptures_2",
    "Sculptures_3",
    "Sculptures_4",
    "Sculptures_5",
    "Chessy_1",
    "Chessy_2",
    "Chessy_3",
    "Chessy_4",
    "Chessy_5",
    "Chessy_6",
    "Maxwell1",
    "Maxwell2",
    "Maxwell3",
    "Maxwell4",
    "Maxwell6",
    "Maxwell7",
    "Warzone_1",
    "Warzone_2",
    "Warzone_3" 
  },
  required_prefabs={ "multiplayer_portal" },
  required_setpieces={ "Sculptures_1", "Maxwell5" },
  substitutes={  },
  version=4 
}

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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117

# Caves - leveldataoverride.lua

代码语言:javascript复制
return {
  background_node_range={ 0, 1 },
  desc="你的洞穴,你做主",
  hideminimap=false,
  id="CUSTOM_PRESET_2",
  location="cave",
  max_playlist_position=999,
  min_playlist_position=0,
  name="自定义预设 2",
  numrandom_set_pieces=0,
  override_level_string=false,
  overrides={
    banana="default",
    bats="default",
    berrybush="default",
    boons="often",
    branching="most",
    bunnymen="default",
    carrot="rare",
    cave_ponds="default",
    cave_spiders="default",
    cavelight="veryfast",
    chess="default",
    disease_delay="none",
    earthquakes="often",
    fern="default",
    fissure="default",
    flint="default",
    flower_cave="default",
    grass="default",
    layout_mode="RestrictNodesByKey",
    lichen="default",
    liefs="default",
    loop="default",
    marshbush="default",
    monkey="default",
    mushroom="default",
    mushtree="default",
    prefabswaps_start="classic",
    rabbits="rare",
    reeds="default",
    regrowth="veryfast",
    roads="never",
    rock="default",
    rocky="default",
    sapling="default",
    season_start="default",
    slurper="default",
    slurtles="default",
    specialevent="year_of_the_gobbler",
    start_location="caves",
    task_set="cave_default",
    tentacles="default",
    touchstone="default",
    trees="default",
    weather="default",
    world_size="huge",
    wormattacks="default",
    wormhole_prefab="tentacle_pillar",
    wormlights="default",
    worms="default" 
  },
  required_prefabs={ "multiplayer_portal" },
  substitutes={  },
  version=4 
}

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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66

# Master 和 Caves 的 modoverrides.lua

代码语言:javascript复制
return {
  ["workshop-1111658995"]={
    configuration_options={ ShowOnActive=false, ShowOnPoint=true, UIoffset=150 },
    enabled=true 
  },
  ["workshop-1207269058"]={ configuration_options={  }, enabled=true },
  ["workshop-1226903961"]={
    configuration_options={ bossstrengthen=false, checkcoin=false, checkstart=true },
    enabled=true 
  },
  ["workshop-1458450094"]={
    configuration_options={
      [""]=0,
      houndstooth=false,
      livinglog=false,
      log=false,
      mode="fix",
      retrapfix=3,
      retraprandomx=10,
      retraprandomy=120,
      rope=false,
      stinger=false 
    },
    enabled=true 
  },
  ["workshop-1898292532"]={
    configuration_options={
      antlion=true,
      atrium_gate=true,
      bearger=true,
      beequeenhive=true,
      crabking=true,
      deerclops=true,
      dragonfly=true,
      hound=true,
      klaus_sack=true,
      malbatross=true,
      tips_method=1,
      toadstool=true 
    },
    enabled=true 
  },
  ["workshop-1992091838"]={
    configuration_options={
      backpack_ice=false,
      cage_frige=true,
      cook_pot=true,
      icebox_freeze="0.5",
      krampus_sack_ice=true,
      mushroom_frige=0,
      piggyback_ice=false,
      saltlicker=0.25 
    },
    enabled=true 
  },
  ["workshop-1998081438"]={ configuration_options={ StackRange=50 }, enabled=true },
  ["workshop-2078243581"]={
    configuration_options={ Blue=0, Display="target", Green=0, Projectile=true, Red=1, Type="hit" },
    enabled=true 
  },
  ["workshop-2112123428"]={ configuration_options={  }, enabled=true },
  ["workshop-2119742489"]={
    configuration_options={ Hunger_Cost=0, Ownership=false, Sanity_Cost=0 },
    enabled=true 
  },
  ["workshop-362175979"]={ configuration_options={ ["Draw over FoW"]="disabled" }, enabled=true },
  ["workshop-374550642"]={ configuration_options={ MAXSTACKSIZE=250 }, enabled=true },
  ["workshop-375850593"]={ configuration_options={  }, enabled=true },
  ["workshop-378160973"]={
    configuration_options={
      ENABLEPINGS=true,
      FIREOPTIONS=2,
      OVERRIDEMODE=false,
      SHAREMINIMAPPROGRESS=true,
      SHOWFIREICONS=true,
      SHOWPLAYERICONS=true,
      SHOWPLAYERSOPTIONS=2 
    },
    enabled=true 
  },
  ["workshop-462434129"]={
    configuration_options={
      MOD_RESTART_ALLOW_KILL=true,
      MOD_RESTART_ALLOW_RESTART=true,
      MOD_RESTART_ALLOW_RESURRECT=true,
      MOD_RESTART_CD_BONUS=0,
      MOD_RESTART_CD_KILL=0,
      MOD_RESTART_CD_MAX=0,
      MOD_RESTART_CD_RESTART=0,
      MOD_RESTART_CD_RESURRECT=0,
      MOD_RESTART_FORCE_DROP_MODE=0,
      MOD_RESTART_IGNORING_ADMIN=true,
      MOD_RESTART_MAP_SAVE=1,
      MOD_RESTART_RESURRECT_HEALTH=100,
      MOD_RESTART_TRIGGER_MODE=1,
      MOD_RESTART_WELCOME_TIPS=true,
      MOD_RESTART_WELCOME_TIPS_TIME=6 
    },
    enabled=true 
  },
  ["workshop-466732225"]={ configuration_options={  }, enabled=true },
  ["workshop-661253977"]={
    configuration_options={ amudiao=true, baodiao=1, kong=0, rendiao=2, zbdiao=true },
    enabled=true 
  },
  ["workshop-666155465"]={
    configuration_options={
      chestB=-1,
      chestG=-1,
      chestR=-1,
      food_estimation=-1,
      food_order=0,
      food_style=1,
      lang="chs",
      show_food_units=-1,
      show_uses=-1 
    },
    enabled=true 
  },
  ["workshop-737932010"]={
    configuration_options={
      amount_of_numbers="default",
      display_mode="waving",
      dmg_only="on",
      show_decimal_points="no" 
    },
    enabled=true 
  },
  ["workshop-797304209"]={ configuration_options={  }, enabled=true },
  ["workshop-812713308"]={ configuration_options={ fireflies_fear=222, language=0 }, enabled=true } 
}

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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131

# 开启 Mod

进入 Mod 文件目录

代码语言:javascript复制
$ cd /home/steam/steamapps/dst/mods

1

修改 dedicated_server_mods_setup.lua

代码语言:javascript复制
--[DST]显示包裹内容
ServerModSetup("1111658995")

--简易血条DST
ServerModSetup("1207269058")

--DST A3.4.005
ServerModSetup("1226903961")

--Auto Trap Reset
ServerModSetup("1458450094")

--[Tips]提示猎狗和BOSS的攻击时间
ServerModSetup("1898292532")

--阿乐冰箱
ServerModSetup("1992091838")

--掉落堆叠(Drop stack)
ServerModSetup("1998081438")

--Display Attack Range
ServerModSetup("2078243581")

--展示用餐桌
ServerModSetup("2112123428")

--Wormhole Marks [DST]
ServerModSetup("362175979")

--Extra Equip Slots
ServerModSetup("375850593")

--Global Positions
ServerModSetup("378160973")

--Restart(重生)
ServerModSetup("462434129")

--No Thermal Stone Durability
ServerModSetup("466732225")

--灵魂携带物品 - Don't Drop Everything
ServerModSetup("661253977")

--Show Me (Origin)
ServerModSetup("666155465")

--Damage Indicators
ServerModSetup("737932010")

--no grassgekko 禁用草蜥蜴
ServerModSetup("797304209")

--Colorful Fireflies
ServerModSetup("812713308")

--Increased Stack size
ServerModSetup("374550642")

--木牌传送 (GUI)
ServerModSetup("2119742489")

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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62

更新饥荒会清空这个文件,所以注意备份一份 dedicated_server_mods_setup.bak.lua

# 启动饥荒

代码语言:javascript复制
# 进入程序目录
$ cd /home/steam/steamapps/dst/bin

# 运行程序
# 启动 Cluster_1 存档的地面服务
$ ./dontstarve_dedicated_server_nullrenderer -console -cluster Cluster_1 -shard Master

# 启动 Cluster_1 存档的洞穴服务
$ ./dontstarve_dedicated_server_nullrenderer -console -cluster Cluster_1 -shard Caves

1 2 3 4 5 6 7 8 9

见到 Registering master server in Sing lobby 时,表明成功,这时候可以去搜索房间了

# 一键脚本

为方便操作,封装一份脚本

代码语言:javascript复制
$ /home/steam/steamapps/dst

# 新建一个目录存放脚本
$ mkdir script

# 进入脚本目录
$ cd script

1 2 3 4 5 6 7

# 安装 screen

代码语言:javascript复制
$ sudo apt-get install screen

1

# 升级脚本

dst_update.sh

代码语言:javascript复制
#!/bin/bash
cd /home/steam/steamcmd
./steamcmd.sh  login anonymous  force_install_dir /home/steam/steamapps/dst  app_update 343050 validate  quit

1 2 3

# 启动脚本

dst_start_Cluster_1.sh

代码语言:javascript复制
#!/bin/bash
cd /home/steam/steamapps/dst/bin
screen -dmS dst_Cluster_1_master  ./dontstarve_dedicated_server_nullrenderer -console -cluster Cluster_1 -shard Master
screen -dmS dst_Cluster_1_caves  ./dontstarve_dedicated_server_nullrenderer -console -cluster Cluster_1 -shard Caves

1 2 3 4

# 添加执行权限

代码语言:javascript复制
$ chmod  x ./dst_update.sh ./dst_start_Cluster_1.sh

1

# 使用

代码语言:javascript复制
# 启动
$ ./dst_start_Cluster_1.sh

# 查看所有后台服务
$ screen -ls

# 进入后台
$ screen -r dst_Cluster_1_master

# 同时按住 Ctrl c 停止运行
# 同时按住 Ctrl a d 继续后台运行
# 更多操作请阅读 screen 用法

1 2 3 4 5 6 7 8 9 10 11 12

# 附录

  • 食谱

# 五雪球机布局

# 三雪球机布局

# 两雪球机布局

# 单雪球机布局

我的博客即将同步至腾讯云 社区,邀请大家一同入驻:https://cloud.tencent.com/developer/support-plan?invite_code=2x0f65hhc52c8

0 人点赞