diff --git a/Hurtworld/hwserver b/Hurtworld/hwserver new file mode 100644 index 000000000..e74f5648a --- /dev/null +++ b/Hurtworld/hwserver @@ -0,0 +1,152 @@ +#!/bin/bash +# Hurtworld +# Server Management Script +# Author: Daniel Gibbs, +# Contributor: UltimateByte +# Website: http://gameservermanagers.com +if [ -f ".dev-debug" ]; then + exec 5>dev-debug.log + BASH_XTRACEFD="5" + set -x +fi + +version="191215" + +#### Variables #### + +# Notification Email +# (on|off) +emailnotification="off" +email="email@example.com" + +# Steam login +steamuser="anonymous" +steampass="" + +# Server settings +servername="Hurtworld LGSM Server" +ip="0.0.0.0" +port="12871" +queryport="12881" +maxplayers="20" +map="" #Optional +creativemode="0" #Free Build +logfile="gamelog.txt" + +# Adding admins using STEAMID64 +# Example : addadmin 012345678901234567; addadmin 987654321098765432 +admins="" + +# Advanced +# Rollback server state (remove after start command) +loadsave="" +# Use unstable 64 bit server executable (O/1) +x64mode="0" + +# http://hurtworld.wikia.com/wiki/Hosting_A_Server +fn_parms(){ +parms="-batchmode -nographics -exec \"host ${port} ${map} ${loadsave};queryport ${queryport};maxplayers ${maxplayers};servername ${servername};creativemode ${creativemode};${admins}\" -logfile \"${logfile}\" " +} + +#### Advanced Variables #### + +# Github Branch Select +# Allows for the use of different function files +# from a different repo and/or branch. +githubuser="dgibbs64" +githubrepo="linuxgsm" +githubbranch="hurt-world" + +# Steam +appid="405100" + +# Server Details +servicename="hurtworld-server" +gamename="Hurtworld" +engine="unity3d" + +# Directories +rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))" +selfname=$(basename $(readlink -f "${BASH_SOURCE[0]}")) +lockselfname=".${servicename}.lock" +filesdir="${rootdir}/serverfiles" +systemdir="${filesdir}" +executabledir="${filesdir}" +if [ "${x64mode}" == "1" ]; then + executable="./Hurtworld.x86_64" +else + executable="./Hurtworld.x86" +fi +backupdir="${rootdir}/backups" + +# Logging +logdays="7" +gamelogdir="${rootdir}/log/server" +scriptlogdir="${rootdir}/log/script" +consolelogdir="${rootdir}/log/console" + +gamelog="${gamelogdir}/${servicename}-game.log" +scriptlog="${scriptlogdir}/${servicename}-script.log" +consolelog="${consolelogdir}/${servicename}-console.log" +emaillog="${scriptlogdir}/${servicename}-email.log" + +scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log" +consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log" + +##### Script ##### +# Do not edit + +fn_getgithubfile(){ +filename=$1 +exec=$2 +fileurl=${3:-$filename} +filepath="${rootdir}/${filename}" +filedir=$(dirname "${filepath}") +# If the function file is missing, then download +if [ ! -f "${filepath}" ]; then + if [ ! -d "${filedir}" ]; then + mkdir "${filedir}" + fi + githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}/${fileurl}" + echo -e " fetching ${filename}...\c" + if [ "$(command -v curl)" ]||[ "$(which curl >/dev/null 2>&1)" ]||[ -f "/usr/bin/curl" ]||[ -f "/bin/curl" ]; then + : + else + echo -e "\e[0;31mFAIL\e[0m\n" + echo "Curl is not installed!" + echo -e "" + exit + fi + curl=$(curl --fail -o "${filepath}" "${githuburl}" 2>&1) + if [ $? -ne 0 ]; then + echo -e "\e[0;31mFAIL\e[0m\n" + echo " ${curl}"|grep "curl:" + echo -e "${githuburl}\n" + exit + else + echo -e "\e[0;32mOK\e[0m" + fi + if [ "${exec}" ]; then + chmod +x "${filepath}" + fi +fi +if [ "${exec}" ]; then + source "${filepath}" +fi +} + +fn_runfunction(){ + fn_getgithubfile "functions/${functionfile}" 1 +} + +fn_functions(){ +# Functions are defined in fn_functions. +functionfile="${FUNCNAME}" +fn_runfunction +} + +fn_functions + +getopt=$1 +fn_getopt + diff --git a/functions/fn_details b/functions/fn_details index 40904b283..30313d4e4 100644 --- a/functions/fn_details +++ b/functions/fn_details @@ -554,7 +554,7 @@ echo -e "" fn_details_statusbottom } -fn_details_unity3d(){ +fn_details_sdtd(){ fn_check_ip fn_parms fn_details_config @@ -601,6 +601,37 @@ printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = fn_details_statusbottom } +fn_details_hurtworld(){ +fn_check_ip +fn_parms +fn_details_config +fn_details_distro +fn_details_os +fn_details_performance +fn_details_disk +fn_details_gameserver +fn_details_backup +fn_details_commandlineparms +echo -e "" +echo -e "\e[92mPorts\e[0m" +printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' = +echo -e "Change ports by editing the parameters in" +echo -e "hwserver script" +echo -e "" +echo -e "Useful port diagnostic command:" +echo -e "netstat -atunp | grep Hurtworld.x86" +echo -e "" +{ + echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL" + echo -e "> Game/RCON\tINBOUND\t${port}\tudp" + echo -e "> Query\tINBOUND\t${queryport}\tudp" + +} | column -s $'\t' -t +echo -e "" + +fn_details_statusbottom +} + fn_details_unreal(){ fn_check_ip fn_parms @@ -688,17 +719,19 @@ fn_details_statusbottom } if [ ! -e "${servercfgfullpath}" ]; then - echo "" - fn_printwarnnl "\e[0;31mCONFIGURATION FILE MISSING!\e[0m" - echo "${servercfgfullpath}" - echo "Some details cannot be displayed" - echo -en ".\r" - sleep 1 - echo -en "..\r" - sleep 1 - echo -en "...\r" - sleep 1 - echo -en " \r" + if [ "${gamename}" != "Hurtworld" ]; then + echo "" + fn_printwarnnl "\e[0;31mCONFIGURATION FILE MISSING!\e[0m" + echo "${servercfgfullpath}" + echo "Some details cannot be displayed" + echo -en ".\r" + sleep 1 + echo -en "..\r" + sleep 1 + echo -en "...\r" + sleep 1 + echo -en " \r" + fi fi fn_details_glibc @@ -723,12 +756,14 @@ elif [ "${engine}" == "teeworlds" ]; then fn_details_teeworlds elif [ "${engine}" == "terraria" ]; then fn_details_terraria -elif [ "${engine}" == "unity3d" ]; then - fn_details_unity3d elif [ "${engine}" == "unreal" ] || [ "${engine}" == "unreal2" ]; then fn_details_unreal elif [ "${gamename}" == "ARK: Survivial Evolved" ]; then fn_details_ark +elif [ "${gamename}" == "Hurtworld" ]; then + fn_details_hurtworld +elif [ "${gamename}" == "7 Days To Die" ]; then + fn_details_sdtd elif [ "${gamename}" == "Teamspeak 3" ]; then fn_details_teamspeak3 else diff --git a/functions/fn_details_config b/functions/fn_details_config index d24751f81..dfab6de64 100644 --- a/functions/fn_details_config +++ b/functions/fn_details_config @@ -235,6 +235,7 @@ elif [ "${engine}" == "realvirtuality" ]; then fn_servercfgfullpath +# Serious Sam elif [ "${engine}" == "seriousengine35" ]; then # server name @@ -295,6 +296,7 @@ elif [ "${engine}" == "seriousengine35" ]; then fn_servercfgfullpath +# Source Engine Games elif [ "${engine}" == "source" ] || [ "${engine}" == "goldsource" ]; then # server name @@ -329,6 +331,7 @@ elif [ "${engine}" == "source" ] || [ "${engine}" == "goldsource" ]; then fn_servercfgfullpath +# Spark (NS2: Combat) elif [ "${engine}" == "spark" ]; then # query port @@ -341,6 +344,7 @@ elif [ "${engine}" == "spark" ]; then fn_servercfgfullpath +# Teamspeak 3 elif [ "${gamename}" == "Teamspeak 3" ]; then # ip @@ -388,6 +392,7 @@ elif [ "${gamename}" == "Teamspeak 3" ]; then fn_servercfgfullpath +# Teeworlds elif [ "${engine}" == "teeworlds" ]; then # server name @@ -440,6 +445,7 @@ elif [ "${engine}" == "teeworlds" ]; then fn_servercfgfullpath +# Terraria elif [ "${engine}" == "terraria" ]; then # port @@ -450,7 +456,8 @@ elif [ "${engine}" == "terraria" ]; then port="0" fi -elif [ "${engine}" == "unity3d" ]; then +# 7 Day To Die (unity3d) +elif [ "${gamename}" == "7 Days To Die" ]; then # server name if [ -f "${servercfgfullpath}" ]; then @@ -586,6 +593,48 @@ elif [ "${engine}" == "unity3d" ]; then fn_servercfgfullpath +# Hurtworld (unity3d) +elif [ "${gamename}" == "Hurtworld" ]; then + + # server name + if [ -n "${servername}" ]; then + servername="${servername}" + else + servername="\e[0;31mUNAVAILABLE\e[0m" + fi + + # server password + # not available yet + + # slots + if [ -n "${maxplayers}" ]; then + slots="${maxplayers}" + else + slots="NOT SET" + fi + + # game world + if [ -n "${map}" ]; then + gameworld="${map}" + else + gameworld="NO MAP SET" + fi + + # port + if [ -n "${port}" ]; then + port="${port}" + else + port="0" + fi + + # query port + if [ -n "${queryport}" ]; then + queryport="${queryport}" + else + queryport="0" + fi + +# Unreal Tournament elif [ "${engine}" == "unreal" ] || [ "${engine}" == "unreal2" ]; then # server name @@ -716,6 +765,7 @@ elif [ "${engine}" == "unreal" ] || [ "${engine}" == "unreal2" ]; then fn_servercfgfullpath +# ARK: Survivaial Evolved elif [ "${gamename}" == "ARK: Survivial Evolved" ]; then # server name diff --git a/functions/fn_install b/functions/fn_install index 0cc9129c4..39fca9c8e 100644 --- a/functions/fn_install +++ b/functions/fn_install @@ -43,4 +43,4 @@ elif [ "${gamename}" == "Unreal Tournament 2004" ]; then elif [ "${gamename}" == "Unreal Tournament 99" ]; then fn_install_ut99fix fi -fn_install_complete \ No newline at end of file +fn_install_complete diff --git a/functions/fn_install_config b/functions/fn_install_config index 2a0311634..d91557360 100644 --- a/functions/fn_install_config +++ b/functions/fn_install_config @@ -5,9 +5,9 @@ lgsm_version="201215" fn_defaultconfig(){ -echo "creating ${servercfg} config file." -cp -v "${servercfgdefault}" "${servercfgfullpath}" -sleep 1 + echo "creating ${servercfg} config file." + cp -v "${servercfgdefault}" "${servercfgfullpath}" + sleep 1 } fn_userinputconfig(){ @@ -151,12 +151,15 @@ echo "" } echo "" +if [ "${gamename}" != "Hurtworld" ]; then echo "Creating Configs" echo "=================================" sleep 1 -mkdir -pv "${servercfgdir}" -cd "${servercfgdir}" -githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}" + mkdir -pv "${servercfgdir}" + cd "${servercfgdir}" + githuburl="https://raw.githubusercontent.com/${githubuser}/${githubrepo}/${githubbranch}" +fi + if [ "${gamename}" == "7 Days To Die" ]; then fn_defaultconfig elif [ "${gamename}" == "ARK: Survivial Evolved" ]; then diff --git a/functions/fn_install_gsquery b/functions/fn_install_gsquery index 3f5bfcebf..16b1534ee 100644 --- a/functions/fn_install_gsquery +++ b/functions/fn_install_gsquery @@ -2,7 +2,7 @@ # LGSM fn_install_gsquery function # Author: Daniel Gibbs # Website: http://gameservermanagers.com -lgsm_version="061115" +lgsm_version="221215" fn_dlgsquery(){ cd "${rootdir}" @@ -11,7 +11,7 @@ wget -N /dev/null "http://gameservermanagers.com/dl/gsquery.py" 2>&1 | grep -F " chmod +x gsquery.py } -if [ "${engine}" == "avalanche" ]||[ "${engine}" == "goldsource" ]||[ "${engine}" == "realvirtuality" ]||[ "${engine}" == "source" ]||[ "${engine}" == "spark" ]||[ "${engine}" == "unity3d" ]||[ "${engine}" == "unreal" ]||[ "${engine}" == "unreal2" ]; then +if [ "${engine}" == "avalanche" ]||[ "${engine}" == "goldsource" ]||[ "${engine}" == "realvirtuality" ]||[ "${engine}" == "source" ]||[ "${engine}" == "spark" ]||[ "${engine}" == "unity3d" ]||[ "${gamename}" == "Hurtworld" ]||[ "${engine}" == "unreal" ]||[ "${engine}" == "unreal2" ]; then echo "" echo "GameServerQuery" echo "============================" diff --git a/functions/fn_install_steamfix b/functions/fn_install_steamfix index e977b0f11..d94ce3e28 100644 --- a/functions/fn_install_steamfix +++ b/functions/fn_install_steamfix @@ -14,10 +14,10 @@ cp -v "${rootdir}/steamcmd/linux32/steamclient.so" "${HOME}/.steam/sdk32/steamcl sleep 1 } -# Gary's Mod Specific +# Server specific fn_libsteamfix(){ echo "" -echo "Applying libsteam.so fix" +echo "Applying libsteam.so and steamclient.so fixes" echo "=================================" sleep 1 if [ "${gamename}" == "Garry's Mod" ]; then @@ -26,11 +26,14 @@ if [ "${gamename}" == "Garry's Mod" ]; then elif [ "${gamename}" == "Serious Sam 3: BFE" ]; then mkdir -pv "${HOME}/.steam/bin32" cp -v "${filesdir}/Bin/libsteam.so" "${HOME}/.steam/bin32/libsteam.so" +elif [ "${gamename}" == "Hurtworld" ]; then + cp -v "${rootdir}/steamcmd/linux32/steamclient.so" "${filesdir}/Hurtworld_Data/Plugins/x86/steamclient.so" + cp -v "${rootdir}/steamcmd/linux32/steamclient.so" "${filesdir}/Hurtworld_Data/Plugins/x86_64/steamclient.so" fi sleep 1 } fn_steamclientfix -if [ "${gamename}" == "Garry's Mod" ]||[ "${gamename}" == "Serious Sam 3: BFE" ]; then +if [ "${gamename}" == "Garry's Mod" ]||[ "${gamename}" == "Serious Sam 3: BFE" ]||[ "${gamename}" == "Hurtworld" ]; then fn_libsteamfix fi diff --git a/functions/fn_monitor_query b/functions/fn_monitor_query index b75c6dba6..3bfb5077f 100644 --- a/functions/fn_monitor_query +++ b/functions/fn_monitor_query @@ -17,9 +17,12 @@ if [ -f "${rootdir}/gsquery.py" ]; then elif [ "${engine}" == "realvirtuality" ]; then queryport=$(grep -s steamqueryport= "${servercfgfullpath}"|grep -v //|tr -d '\r'|tr -cd '[:digit:]') port=${queryport} - elif [ "${engine}" == "unity3d" ]; then + elif [ "${gamename}" == "7 Days To Die" ]; then gameport=$(grep ServerPort "${servercfgfullpath}"|tr -cd '[:digit:]') port=$((${gameport} + 1)) + elif [ "${gamename}" == "Hurtworld" ]; then + gameport="${port}" + port="${queryport}" fi fn_printinfo "Detected gsquery.py" fn_scriptlog "Detected gsquery.py"