diff --git a/DontStarveTogether/dstserver b/DontStarveTogether/dstserver index 28a104219..643026c1a 100644 --- a/DontStarveTogether/dstserver +++ b/DontStarveTogether/dstserver @@ -22,16 +22,20 @@ version="161118" #### Server Settings #### -## Server Start Settings | https://github.com/GameServerManagers/LinuxGSM/wiki/Start-Parameters -ip="0.0.0.0" +## Installation Variables | https://github.com/GameServerManagers/LinuxGSM/wiki/Don't-Starve-Together +sharding="false" +master="true" +shard="Master" +cluster="Cluster_1" +cave="false" + +# 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" -# -console -cluster MyDediServer -shard Master +parms="-persistent_storage_root ${persistentstorageroot} -conf_dir ${confdir} -cluster ${cluster} -shard ${shard}" } #### LinuxGSM Settings #### @@ -83,7 +87,7 @@ gamename="Don't Starve Together" engine="dontstarve" ## Service Name | https://github.com/GameServerManagers/LinuxGSM/wiki/Multiple-Servers -servicename="dst-server" +servicename="dst-server-${shard}" #### Directories #### # Edit with care @@ -102,11 +106,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="cluster.ini" +servercfg="server.ini" +servercfgdir="${clustercfgdir}/${shard}" servercfgfullpath="${servercfgdir}/${servercfg}" -servercfgdefault="${servercfgdir}/lgsm-default.ini" +servercfgdefault="server.ini" ## Backup Directory backupdir="${rootdir}/backups" @@ -197,4 +204,4 @@ fi core_dl.sh core_functions.sh getopt=$1 -core_getopt.sh \ No newline at end of file +core_getopt.sh diff --git a/lgsm/functions/command_details.sh b/lgsm/functions/command_details.sh index 2f26501e0..5ab856ed0 100644 --- a/lgsm/functions/command_details.sh +++ b/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 @@ -382,7 +392,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 } diff --git a/lgsm/functions/command_install.sh b/lgsm/functions/command_install.sh index 4624a5fed..d7c3cbc54 100644 --- a/lgsm/functions/command_install.sh +++ b/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 diff --git a/lgsm/functions/core_functions.sh b/lgsm/functions/core_functions.sh index b70cdeaee..ae1b436ea 100644 --- a/lgsm/functions/core_functions.sh +++ b/lgsm/functions/core_functions.sh @@ -480,6 +480,11 @@ functionfile="${FUNCNAME}" fn_fetch_function } +install_dst_token.sh(){ +functionfile="${FUNCNAME}" +fn_fetch_function +} + install_gsquery.sh(){ functionfile="${FUNCNAME}" fn_fetch_function diff --git a/lgsm/functions/core_getopt.sh b/lgsm/functions/core_getopt.sh index 4044ade33..8434f4454 100644 --- a/lgsm/functions/core_getopt.sh +++ b/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 diff --git a/lgsm/functions/info_config.sh b/lgsm/functions/info_config.sh index 8cdb42b09..09cd8900d 100644 --- a/lgsm/functions/info_config.sh +++ b/lgsm/functions/info_config.sh @@ -109,20 +109,24 @@ fn_info_config_codwaw(){ } fn_info_config_dontstarve(){ - if [ ! -f "${servercfgfullpath}" ]; then + if [ ! -f "${clustercfgfullpath}" ]; then servername="${unavailable}" serverpassword="${unavailable}" maxplayers="${zero}" gamemode="${unavailable}" tickrate="${zero}" - port="${zero}" + masterport="${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]*$//') - maxplayers=$(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]*$//') + maxplayers=$(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:]') + masterport=$(grep "master_port" "${clustercfgfullpath}" | grep -v "#" | tr -cd '[:digit:]') + + ip=$(grep "bind_ip" "${clustercfgfullpath}" | sed -e 's/^[ \t]*//g' -e '/^#/d' -e 's/bind_ip//g' | tr -d '=\";,:' | sed -e 's/^[ \t]*//' -e 's/[ \t]*$//') + ipsetinconfig=1 + ipinconfigvar="bind_ip" # Not Set servername=${servername:-"NOT SET"} @@ -130,7 +134,22 @@ fn_info_config_dontstarve(){ maxplayers=${maxplayers:-"0"} gamemode=${gamemode:-"NOT SET"} tickrate=${tickrate:-"0"} + masterport=${masterport:-"0"} + fi + + if [ ! -f "${servercfgfullpath}" ]; then + port="${zero}" + steamauthenticationport="${zero}" + steammasterserverport="${zero}" + else + port=$(grep "server_port" "${servercfgfullpath}" | grep "^server_port" | grep -v "#" | tr -cd '[:digit:]') + steamauthenticationport=$(grep "authentication_port" "${servercfgfullpath}" | grep -v "#" | tr -cd '[:digit:]') + steammasterserverport=$(grep "master_server_port" "${servercfgfullpath}" | grep -v "#" | tr -cd '[:digit:]') + + # Not Set port=${port:-"0"} + steamauthenticationport=${steamauthenticationport:-"0"} + steammasterserverport=${steammasterserverport:-"0"} fi } diff --git a/lgsm/functions/install_complete.sh b/lgsm/functions/install_complete.sh index af522d2ee..4a38d79b4 100644 --- a/lgsm/functions/install_complete.sh +++ b/lgsm/functions/install_complete.sh @@ -8,12 +8,6 @@ local commandname="INSTALL" local commandaction="Install" local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))" -if [ "${gamename}" == "Don't Starve Together" ]; then - echo "" - echo "An Authentication 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" -fi echo "=================================" echo "Install Complete!" fn_script_log_info "Install Complete!" diff --git a/lgsm/functions/install_config.sh b/lgsm/functions/install_config.sh index d38028bae..b5f7a1148 100644 --- a/lgsm/functions/install_config.sh +++ b/lgsm/functions/install_config.sh @@ -51,13 +51,14 @@ fn_default_config_remote(){ for config in "${array_configs[@]}" do # every config is copied - echo "copying ${servercfg} config file." + echo "copying ${config} config file." fn_script_log_info "copying ${servercfg} config file." if [ "${config}" == "${servercfgdefault}" ]; then cp -v "${lgsmdir}/default-configs/${config}" "${servercfgfullpath}" - elif [ "${config}" == "${networkcfgdefault}" ]; then - # ARMA 3 + elif [ "${gamename}" == "ARMA 3" ]&&[ "${config}" == "${networkcfgdefault}" ]; then cp -v "${lgsmdir}/default-configs/${config}" "${networkcfgfullpath}" + elif [ "${gamename}" == "Don't Starve Together" ]&&[ "${config}" == "${clustercfgdefault}" ]; then + cp -nv "${lgsmdir}/default-configs/${clustercfgdefault}" "${clustercfgfullpath}" else cp -v "${lgsmdir}/default-configs/${config}" "${servercfgdir}/${config}" fi @@ -65,6 +66,56 @@ fn_default_config_remote(){ sleep 1 } +# Changes some variables within the default Don't Starve Together configs +fn_set_dst_config_vars(){ + ## cluster.ini + if grep -Fq "SERVERNAME" "${clustercfgfullpath}"; then + 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} is already configured." + fn_script_log_info "${clustercfg} is already configured." + fi + + ## server.ini + # removing unnecessary options (dependent on sharding & shard type) + if [ "${sharding}" == "false" ]; then + sed -i "s/ISMASTER//g" "${servercfgfullpath}" + sed -i "/SHARDNAME/d" "${servercfgfullpath}" + elif [ "${master}" == "true" ]; then + sed -i "/SHARDNAME/d" "${servercfgfullpath}" + fi + + 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 "=================================" @@ -193,10 +244,11 @@ elif [ "${gamename}" == "Deathmatch Classic" ]; then fn_set_config_vars elif [ "${gamename}" == "Don't Starve Together" ]; then gamedirname="DontStarveTogether" - array_configs+=( Settings.ini ) + fn_check_cfgdir + array_configs+=( cluster.ini server.ini ) fn_fetch_default_config fn_default_config_remote - fn_set_config_vars + fn_set_dst_config_vars elif [ "${gamename}" == "Double Action: Boogaloo" ]; then gamedirname="DoubleActionBoogaloo" array_configs+=( server.cfg ) diff --git a/lgsm/functions/install_dst_token.sh b/lgsm/functions/install_dst_token.sh new file mode 100644 index 000000000..2e9713e71 --- /dev/null +++ b/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 ""