Jump to content

[2022 UPDATED] Dedicated Server Quick Setup Guide - Linux


Recommended Posts

Linux (Debian) - PopOS, Ubuntu & Ubuntu Server tested; should work for other debian based distro's as well
This guide contains options for running server at terminal console or setting up as a Linux service

[Step 1 - For security, create a separate user that will run as the server and used with steamcmd]

sudo adduser steam #create username and password
sudo passwd steam #set steam user password *IF* not already prompted, depending on distro
sudo usermod -aG sudo steam #Add user to Sudo Group

[Step 1.a - Ensure you change to Steam user context. Not doing so means you'll execute commands as your current user which can create permissions issues for steamcmd installs/updates]

sudo -u steam -s  #after switching to steam user context, if you ever want to go back to your main user, just type exit.
cd /home/steam #move from your user home directory to steam user home directory

## Everything from this point on should be as the steam user ##

[Step 2 - If running 64 bit OS, which you should be, Add Repository]

sudo dpkg --add-architecture i386
sudo apt-get update

[Step 2.a - Install SteamCMD - Use distro package manager - Learn more about SteamCMD here: https://developer.valvesoftware.com/wiki/SteamCMD]

sudo apt install steamcmd #install steamcmd, be sure to agree to terms and conditions.  It will suggest services to restart, keep default settings and confirm.

[Step 2.b - Set /usr/games Environment Variable for steam User to run Steamcmd from any folder location]

sudo visudo /etc/sudoers  #In this file add "/usr/games" to the end of the "secure_path" variable and save.
exit #need to exit steam user context and re-enter to have environment variable changes take effect
sudo -u steam -s #re-enter steam user context

[Step 3 - Run SteamCMD && Install Don't Starve Together Dedicated Server binaries]

steamcmd #first run will have updates.  It will be ready for next steps when you see the "Steam>" console
force_install_dir /home/steam/steamapps/DST #or whatever absolute path is wanted
login anonymous
app_update 343050 validate # ID 343050 is the steamapp ID for Dont Starve Dedicated Server
quit #Binaries are now installed

[Step 4 - Pre-make Server Folders (You should be in steam user home directory i.e. /home/steam)- ATTENTION THIS FOLDER STRUCTURE IS HARDCODED INTO THEIR PROGRAM FOR SOME REASON.  Do NOT deviate.]

#You can also choose to start the server manually once as well and this will make those folders.

mkdir .klei #Following examples setup by Klei, create the Server directory where clusters will be contained
mkdir .klei/DoNotStarveTogether
mkdir .klei/DoNotStarveTogether/MyDediServer #Cluster Name as Folder Name - SHOULD be changeable but I have not tested this.  Possible it's Hardcoded as well.

[Step 5 - REQUIRED - Obtain Config files from Developer] - https://forums.kleientertainment.com/forums/topic/64212-dedicated-server-quick-setup-guide-windows/

1. Visit the Klei Accounts site and log in to your account. (Please note, Dedicated Servers are not supported for the Xbox and PlayStation versions of the game.)
2. On the accounts page, visit the “GAMES” tab, then scroll down to Don’t Starve Together and click on the “Game Servers” button.
3. If you don’t have any server yet, please click the “ADD NEW SERVER” button. If you have a valid server, click the green “CONFIGURE” button. Expired servers are colored in red and should be deleted.
4. In the “Configure Server” page you will find a form with some options that you can edit to customize your server. Once you are ready, click the “Download Settings” button.
5. Download the Zip archive, extract the contents, and place in the folder “MyDediServer” (default cluser name) inside ~/.klei/DoNotStarveTogether folder.

[Step 5.a - Edit Server Settings]

nano ~/.klei/DoNotStarveTogether/MyDediServer/Cluster.ini #change settings relevant to your server, if needed.  This will already be configured based on details you used on their website.

###FOLDER STRUCTURE CONTEXT FOR ABOVE####
#The ~/.klei/DoNotStarveTogether folder contains your "Cluster" Server name. Within that folder:
#    Files
#        Cluster.ini #This contains the server information you chose within the Klei Account/Games pages (i.e. servername, etc.)
#            OPTIONAL STEP: To setup as a lan server. Create [ACCOUNT] section, anywhere within Cluster.ini, following structure demonstrated in file and add a line beneath it with the following option, dedicated_lan_server = true
#        Cluster_token.txt #REQUIRED TO RUN SERVER EVEN ON LAN - Do not touch contents
#    Folders
#        Master
#            server.ini
#        Caves
#            server.ini
#
### END FOLDER STRUCTURE CONTEXT FOR ABOVE####

[Step 6 - Create Server Start Script]

cd /home/steam/steamapps/DST #or whatever location you chose for the force_install_dir location earlier
nano run_dedicated_server.sh
##COPY EVERYTHING IN BETWEEN [FC1] SECTION BELOW INTO THAT FILE AND SAVE IT
##EDIT THE steamcmd_dir, install_dir & cluster_name if needed.  DO NOT EDIT dontstarve_dir value.  Something is hardcoaded elsewhere with this specific value.
chmod u+x run_dedicated_server.sh #may need to sudo, try without first

#### [FC1] FILE CONTENTS BELOW FOR run_dedicated_server.sh SCRIPT #####

Spoiler

 

#!/bin/bash

#steamcmd_dir="$HOME/steamcmd"  #This is unnecessary if you set the environment variables for the steam user correctly as outlined earlier
install_dir="$HOME/steamapps/DST"
cluster_name="MyDediServer" #SHOULD be changeable but I have not tested this.  Possible it's Hardcoded as well.
dontstarve_dir="$HOME/.klei/DoNotStarveTogether" #This folder structure [/.klei/DoNotStarveTogether] is HARD CODED into their program, do not change

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" #This is unecessary if you set the environment variables for the steam user correctly as outlined earlier
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 +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: /'

 

#### FILE CONTENTS ABOVE FOR run_dedicated_server.sh SCRIPT #####


[STEP 7 OPTION 1 - START SERVER Manually]

./run_dedicated_server.sh

[STEP 7 OPTION 2 - SETUP DSTServer as a Service]

sudo nano /etc/systemd/system/dstserver.service  # Enter contents shown below into this file, save and exit.  Change ExecStart= path to your configured install path

### SERVICE FILE CONTENTS ####

Spoiler

 

[Unit]
Description=Dont Starve Together Server
After=networking.service

[Service]
Type=simple
User=steam
Group=steam
TimeoutStartSec=0
Restart=on-failure
RestartSec=30s

#ExecStartPre=/usr/games/steamcmd +force_install_dir "/home/steam/steamapps/DST" +login anonymous +app_update 343050 validate +quit #You can enable the steamapp update from here if you like, but remember to comment out the update in run_dedicated_server.sh if you do.
ExecStart=/home/steam/steamapps/DST/run_dedicated_server.sh
SyslogIdentifier=dstserver

[Install]
WantedBy=multi-user.target

 

### END SERVICE FILE CONTENTS ####

sudo systemctl daemon-reload
sudo systemctl enable dstserver.service
sudo systemctl start dstserver.service #Service should be available. To check you can run "systemctl status dstserver.service"

 

Link to comment
Share on other sites

[IF YOU WANT TO RUN MODS]

[Step 1 - Remove Validation from run_dedicated_server.sh script]

#We're doing the following steps so that when the server script is run, steam does not OVERWRITE the files we need to edit for enabling mod downloads.  Having the "validate" command within the update command will overwrite the dedicated_server_mods_setup.lua 

#Within your Dont Starve Install Directory (i.e. /home/steam/steamapps/DST)

nano run_dedicated_server.sh #remove the word "validate" from this line: steamcmd +force_install_dir "$install_dir" +login anonymous +app_update 343050 validate +quit

Exit and save the file.

[Step 2 - Follow the instructions on this post for enabling linux server mods]

[GUIDE] How to install,configure and update mods on Dedicated Server - [Don't Starve Together] Dedicated Server Discussion - Klei Entertainment Forums

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...