Browse Source

Overhauled Don't Starve Together server

WORK IN PROGRESS
- use ip parameter and/or ip from config
- standardize fn_dstconfig() ?
- ..
pull/1200/head
Marvin Lehmann 9 years ago
parent
commit
d5b7c3cba6
  1. 35
      DontStarveTogether/dstserver
  2. 15
      lgsm/functions/command_details.sh
  3. 2
      lgsm/functions/command_install.sh
  4. 5
      lgsm/functions/core_functions.sh
  5. 79
      lgsm/functions/core_getopt.sh
  6. 14
      lgsm/functions/info_config.sh
  7. 67
      lgsm/functions/install_config.sh
  8. 49
      lgsm/functions/install_dst_token.sh

35
DontStarveTogether/dstserver

@ -14,7 +14,7 @@ if [ -f ".dev-debug" ]; then
set -x
fi
version="161030"
version="161111"
##########################
######## Settings ########
@ -22,15 +22,29 @@ version="161030"
#### Server Settings ####
## Installation Variables
# Visit the following link for more information:
# https://github.com/GameServerManagers/LinuxGSM/wiki/Don't-Starve-Together
sharding="false"
master="true"
shard="Master"
cluster="Cluster_1"
cave="false"
## Server Start Settings | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters
ip="0.0.0.0"
port="11000"
steamauthenticationport="8768"
steammasterserverport="27018"
tickrate="15"
# Edit with care
persistentstorageroot="${HOME}/.klei"
confdir="DoNotStarveTogether"
## Server Start Command | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters#additional-parameters
# Edit with care | http://dont-starve-game.wikia.com/wiki/Guides/Don%E2%80%99t_Starve_Together_Dedicated_Servers
# Overworld: -conf_dir DST_Overworld
# Cave: -conf_dir DST_Cave
fn_parms(){
parms="-console -cluster MyDediServer -shard Master"
parms="-bind_ip ${ip} -port ${port} -steam_master_server_port ${steammasterserverport} -steam_authentication_port ${steamauthenticationport} -tick ${tickrate} -persistent_storage_root ${persistentstorageroot} -conf_dir ${confdir} -cluster ${cluster} -shard ${shard}"
# -console -cluster MyDediServer -shard Master
}
@ -100,11 +114,14 @@ filesdir="${rootdir}/serverfiles"
systemdir="${filesdir}"
executabledir="${filesdir}/bin"
executable="./dontstarve_dedicated_server_nullrenderer"
servercfg="settings.ini"
servercfgdefault="settings.ini"
servercfgdir="${HOME}/.klei/DoNotStarveTogether"
clustercfg="cluster.ini"
clustercfgdir="${persistentstorageroot}/${confdir}/${cluster}"
clustercfgfullpath="${clustercfgdir}/${clustercfg}"
clustercfgdefault="${clustercfgdir}/cluster.ini"
servercfg="server.ini"
servercfgdir="${clustercfgdir}/${shard}"
servercfgfullpath="${servercfgdir}/${servercfg}"
servercfgdefault="${servercfgdir}/lgsm-default.ini"
servercfgdefault="server.ini"
## Backup Directory
backupdir="${rootdir}/backups"

15
lgsm/functions/command_details.sh

@ -152,6 +152,16 @@ fn_details_gameserver(){
if [ -n "${tickrate}" ]; then
echo -e "${blue}Tick rate:\t${default}${tickrate}"
fi
# Cluster (Don't Starve Together)
if [ -n "${cluster}" ]; then
echo -e "${blue}Cluster:\t${default}${cluster}"
fi
# Shard (Don't Starve Together)
if [ -n "${shard}" ]; then
echo -e "${blue}Shard:\t${default}${shard}"
fi
# TeamSpeak dbplugin
if [ -n "${dbplugin}" ]; then
@ -355,7 +365,10 @@ fn_details_dontstarve(){
echo -e ""
{
echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
echo -e "> Game\tINBOUND\t${port}\tudp"
echo -e "> Game: Server\tINBOUND\t${port}\tudp"
echo -e "> Game: Master\tINBOUND\t${masterport}\tudp"
echo -e "> Steam: Auth\tINBOUND\t${steamauthenticationport}\tudp"
echo -e "> Steam: Master\tINBOUND\t${steammasterserverport}\tudp"
} | column -s $'\t' -t
}

2
lgsm/functions/command_install.sh

@ -30,6 +30,8 @@ fi
install_config.sh
if [ "${gamename}" == "Counter-Strike: Global Offensive" ]||[ "${gamename}" == "Team Fortress 2" ]||[ "${gamename}" == "BrainBread 2" ]; then
install_gslt.sh
elif [ "${gamename}" == "Don't Starve Together" ]; then
install_dst_token.sh
elif [ "${gamename}" == "TeamSpeak 3" ]; then
install_ts3db.sh
fi

5
lgsm/functions/core_functions.sh

@ -475,6 +475,11 @@ functionfile="${FUNCNAME}"
fn_fetch_function
}
install_dst_token.sh(){
functionfile="${FUNCNAME}"
fn_fetch_function
}
install_gsquery.sh(){
functionfile="${FUNCNAME}"
fn_fetch_function

79
lgsm/functions/core_getopt.sh

@ -337,6 +337,83 @@ case "${getopt}" in
esac
}
fn_getopt_dstserver(){
case "${getopt}" in
st|start)
command_start.sh;;
sp|stop)
command_stop.sh;;
r|restart)
command_restart.sh;;
u|update)
command_update.sh;;
fu|force-update|update-restart)
forceupdate=1;
command_update.sh;;
uf|update-functions)
command_update_functions.sh;;
v|validate)
command_validate.sh;;
m|monitor)
command_monitor.sh;;
ta|test-alert)
command_test_alert.sh;;
dt|details)
command_details.sh;;
pd|postdetails)
command_postdetails.sh;;
b|backup)
command_backup.sh;;
c|console)
command_console.sh;;
d|debug)
command_debug.sh;;
dev|dev-debug)
command_dev_debug.sh;;
i|install)
command_install.sh;;
ai|auto-install)
fn_autoinstall;;
ct|cluster-token)
install_dst_token.sh;;
dd|detect-deps)
command_dev_detect_deps.sh;;
dg|detect-glibc)
command_dev_detect_glibc.sh;;
dl|detect-ldd)
command_dev_detect_ldd.sh;;
*)
if [ -n "${getopt}" ]; then
echo -e "${red}Unknown command${default}: $0 ${getopt}"
exitcode=2
fi
echo "Usage: $0 [option]"
echo "${gamename} - Linux Game Server Manager - Version ${version}"
echo "https://gameservermanagers.com/${selfname}"
echo -e ""
echo -e "${lightyellow}Commands${default}"
{
echo -e "${blue}start\t${default}st |Start the server."
echo -e "${blue}stop\t${default}sp |Stop the server."
echo -e "${blue}restart\t${default}r |Restart the server."
echo -e "${blue}update\t${default}u |Checks and applies updates from SteamCMD."
echo -e "${blue}force-update\t${default}fu |Bypasses the check and applies updates from SteamCMD."
echo -e "${blue}update-functions\t${default}uf |Removes all functions so latest can be downloaded."
echo -e "${blue}validate\t${default}v |Validate server files with SteamCMD."
echo -e "${blue}monitor\t${default}m |Checks that the server is running."
echo -e "${blue}test-alert\t${default}ta |Sends test alert."
echo -e "${blue}details\t${default}dt |Displays useful information about the server."
echo -e "${blue}postdetails\t${default}pd |Post stripped details to pastebin (for support)"
echo -e "${blue}backup\t${default}b |Create archive of the server."
echo -e "${blue}console\t${default}c |Console allows you to access the live view of a server."
echo -e "${blue}debug\t${default}d |See the output of the server directly to your terminal."
echo -e "${blue}install\t${default}i |Install the server."
echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts."
echo -e "${blue}cluster-token\t${default}ct |Configure cluster token."
} | column -s $'\t' -t
esac
}
fn_getopt_gmodserver(){
case "${getopt}" in
st|start)
@ -628,6 +705,8 @@ elif [ "${engine}" == "lwjgl2" ]; then
fn_getopt_minecraft
elif [ "${gamename}" == "TeamSpeak 3" ]; then
fn_getopt_teamspeak3
elif [ "${gamename}" == "Don't Starve Together" ]; then
fn_getopt_dstserver
elif [ "${gamename}" == "Garry's Mod" ]; then
fn_getopt_gmodserver
elif [ "${engine}" == "unreal2" ]; then

14
lgsm/functions/info_config.sh

@ -81,7 +81,7 @@ fn_info_config_cod(){
}
fn_info_config_dontstarve(){
if [ ! -f "${servercfgfullpath}" ]; then
if [ ! -f "${clustercfgfullpath}" ]; then
servername="${unavailable}"
serverpassword="${unavailable}"
slots="${zero}"
@ -89,12 +89,12 @@ fn_info_config_dontstarve(){
tickrate="${zero}"
port="${zero}"
else
servername=$(grep "default_server_name" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^#/d' -e 's/default_server_name//g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')
serverpassword=$(grep "server_password" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^#/d' -e 's/server_password//g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')
slots=$(grep "max_players" "${servercfgfullpath}" | grep -v "#" | tr -cd '[:digit:]')
gamemode=$(grep "game_mode" "${servercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^#/d' -e 's/game_mode//g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')
tickrate=$(grep "tick_rate" "${servercfgfullpath}" | grep -v "#" | tr -cd '[:digit:]')
port=$(grep "server_port" "${servercfgfullpath}" | grep -v "#" | tr -cd '[:digit:]')
servername=$(grep "cluster_name" "${clustercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^#/d' -e 's/cluster_name//g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')
serverpassword=$(grep "cluster_password" "${clustercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^#/d' -e 's/cluster_password//g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')
slots=$(grep "max_players" "${clustercfgfullpath}" | grep -v "#" | tr -cd '[:digit:]')
gamemode=$(grep "game_mode" "${clustercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^#/d' -e 's/game_mode//g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//')
tickrate=$(grep "tick_rate" "${clustercfgfullpath}" | grep -v "#" | tr -cd '[:digit:]')
port=$(grep "master_port" "${clustercfgfullpath}" | grep -v "#" | tr -cd '[:digit:]')
# Not Set
servername=${servername:-"NOT SET"}

67
lgsm/functions/install_config.sh

@ -10,11 +10,11 @@ local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
fn_fetch_default_config(){
mkdir -pv "${lgsmdir}/default-configs"
githuburl="https://github.com/GameServerManagers/Game-Server-Configs/master"
githuburl="https://github.com/GameServerManagers/Game-Server-Configs/dstserver"
for config in "${array_configs[@]}"
do
fileurl="https://raw.githubusercontent.com/GameServerManagers/Game-Server-Configs/master/${gamedirname}/${config}"; filedir="${lgsmdir}/default-configs"; filename="${config}"; executecmd="noexecute" run="norun"; force="noforce"
fileurl="https://raw.githubusercontent.com/GameServerManagers/Game-Server-Configs/dstserver/${gamedirname}/${config}"; filedir="${lgsmdir}/default-configs"; filename="${config}"; executecmd="noexecute" run="norun"; force="noforce"
fn_fetch_file "${fileurl}" "${filedir}" "${filename}" "${executecmd}" "${run}" "${force}" "${md5}"
done
}
@ -65,6 +65,64 @@ fn_default_config_remote(){
sleep 1
}
fn_dstconfig(){
## cluster.ini
# this config shouldn't be overridden
if [ ! -s "${clustercfgfullpath}" ]; then
echo "copying ${clustercfg} config file."
fn_script_log_info "copying ${clustercfg} config file."
cp -v "${lgsmdir}/default-configs/${clustercfgdefault}" "${clustercfgfullpath}"
sleep 1
echo "changing server name."
fn_script_log_info "changing server name."
sed -i "s/SERVERNAME/LinuxGSM/g" "${clustercfgfullpath}"
sleep 1
echo "changing shard mode."
fn_script_log_info "changing shard mode."
sed -i "s/USESHARDING/${sharding}/g" "${clustercfgfullpath}"
sleep 1
echo "randomizing cluster key."
fn_script_log_info "randomizing cluster key."
randomkey=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
sed -i "s/CLUSTERKEY/${randomkey}/g" "${clustercfgfullpath}"
sleep 1
else
echo "${clustercfg} already exists."
fn_script_log_info "${clustercfg} already exists."
fi
## server.ini
echo "copying ${servercfg} config file."
fn_script_log_info "copying ${servercfg} config file."
cp -v "${lgsmdir}/default-configs/${servercfgdefault}" "${servercfgfullpath}"
sleep 1
# removing unnecessary options (dependent on sharding & shard type)
if [ "sharding" == "false" ]; then
sed -i "s/ISMASTER//g" "${servercfgfullpath}"
sed -d "/SHARDNAME/d" "${servercfgfullpath}"
elif [ "master" == "true" ];
sed -d "/SHARDNAME/d" "${servercfgfullpath}"
fi
# configure settings
echo "changing shard name."
fn_script_log_info "changing shard name."
sed -i "s/SHARDNAME/${shard}/g" "${servercfgfullpath}"
sleep 1
echo "changing master setting."
fn_script_log_info "changing master setting."
sed -i "s/ISMASTER/${master}/g" "${servercfgfullpath}"
sleep 1
## worldgenoverride.lua
if [ "${cave}" == "true" ]; then
echo "defining ${shard} as cave in ${servercfgdir}/worldgenoverride.lua."
fn_script_log_info "defining ${shard} as cave in ${servercfgdir}/worldgenoverride.lua."
echo 'return { override_enabled = true, preset = "DST_CAVE", }' > "${servercfgdir}/worldgenoverride.lua"
fi
sleep 1
echo ""
}
echo ""
echo "Downloading ${gamename} Config"
echo "================================="
@ -175,10 +233,9 @@ elif [ "${gamename}" == "Deathmatch Classic" ]; then
fn_set_config_vars
elif [ "${gamename}" == "Don't Starve Together" ]; then
gamedirname="DontStarveTogether"
array_configs+=( Settings.ini )
array_configs+=( cluster.ini server.ini )
fn_fetch_default_config
fn_default_config_remote
fn_set_config_vars
fn_dstconfig
elif [ "${gamename}" == "Double Action: Boogaloo" ]; then
gamedirname="DoubleActionBoogaloo"
array_configs+=( server.cfg )

49
lgsm/functions/install_dst_token.sh

@ -0,0 +1,49 @@
#!/bin/bash
# LGSM install_dst_token.sh function
# Author: Daniel Gibbs & Marvin Lehmann (marvinl97)
# Website: https://gameservermanagers.com
# Description: Configures Don't Starve Together cluster with given token.
local commandname="INSTALL"
local commandaction="Install"
local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
echo ""
echo "Enter ${gamename} Cluster Token"
echo "================================="
sleep 1
echo "A cluster token is required to run this server!"
echo "Follow the instructions in this link to obtain this key:"
echo "https://gameservermanagers.com/dst-auth-token"
echo ""
if [ -z "${autoinstall}" ]; then
overwritetoken="true"
if [ -s "${clustercfgdir}/cluster_token.txt" ]; then
echo "The cluster token is already set. Do you want to overwrite it?"
fn_script_log_info "Don't Starve Together cluster token is already set"
while true; do
read -e -i "n" -p "Continue? [Y/n]" yn
case $yn in
[Yy]* ) overwritetoken="true"; break;;
[Nn]* ) overwritetoken="false"; break;;
* ) echo "Please answer yes or no.";;
esac
done
fi
if [ "${overwritetoken}" == "true" ]; then
echo "Once you have the cluster token, enter it below"
echo -n "Cluster Token: "
read token
mkdir -pv "${clustercfgdir}"
echo "${token}" > "${clustercfgdir}/cluster_token.txt"
if [ -f "${clustercfgdir}/cluster_token.txt" ]; then
echo "Don't Starve Together cluster token created"
fn_script_log_info "Don't Starve Together cluster token created"
fi
unset overwritetoken
fi
else
echo "You can add your cluster token using the following command"
echo "./${selfname} cluster-token"
fi
echo ""
Loading…
Cancel
Save