From a04db10f525f9f81159e34ec201e66b7ab5be3f4 Mon Sep 17 00:00:00 2001
From: Bryce Van Dyk <bryce@vandyk.net.nz>
Date: Mon, 7 Sep 2015 21:19:05 +1200
Subject: [PATCH] Update functions to play nice with terraria

---
 functions/fn_details      | 44 ++++++++++++++++++++++++++++++++++-----
 functions/fn_install_logs |  6 +++---
 2 files changed, 42 insertions(+), 8 deletions(-)

diff --git a/functions/fn_details b/functions/fn_details
index 055142ee7..3463272a2 100644
--- a/functions/fn_details
+++ b/functions/fn_details
@@ -2,7 +2,7 @@
 # LGSM fn_details function
 # Author: Daniel Gibbs
 # Website: http://gameservermanagers.com
-# Version: 280715
+# Version: 070915
 
 # Description: Displays server infomation.
 
@@ -19,7 +19,7 @@ printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
 	echo -e "\e[34mKernel:\t\e[0m${kernel}"
 	echo -e "\e[34mHostname:\t\e[0m$HOSTNAME"
 	echo -e "\e[34mtmux:\t\e[0m${tmuxv}"
-	echo -e "\e[34mGLIBC:\t\e[0m${glibcv}" 
+	echo -e "\e[34mGLIBC:\t\e[0m${glibcv}"
 } >> .fn_details_distro
 column -s $'\t' -t .fn_details_distro
 rm -f .fn_details_distro
@@ -31,7 +31,7 @@ echo -e "\e[93mPerformance\e[0m"
 printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
 {
 	echo -e "\e[34mUptime:\t\e[0m${days}d, ${hours}h, ${minutes}m"
-	echo -e "\e[34mAvg Load:\t\e[0m${load}" 
+	echo -e "\e[34mAvg Load:\t\e[0m${load}"
 } >> .fn_details_performance
 column -s $'\t' -t .fn_details_performance
 rm -f .fn_details_performance
@@ -39,7 +39,7 @@ echo -e ""
 {
 	echo -e "\e[34mMem:\t\e[34mtotal\t used\t free\e[0m"
 	echo -e "\e[34mPhysical:\t\e[0m${physmemtotal}\t${physmemused}\t${physmemfree}\e[0m"
-	echo -e "\e[34mSwap:\t\e[0m${swaptotal}\t${swapused}\t${swapfree}\e[0m" 
+	echo -e "\e[34mSwap:\t\e[0m${swaptotal}\t${swapused}\t${swapfree}\e[0m"
 } >> .fn_details_performance
 column -s $'\t' -t .fn_details_performance
 rm -f .fn_details_performance
@@ -497,6 +497,38 @@ fn_details_statusbottom
 
 }
 
+fn_details_terraria(){
+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 command-line"
+echo -e "parameters in ${selfname}."
+echo -e ""
+echo -e "Useful port diagnostic command:"
+echo -e "netstat -atunp | grep terraia"
+echo -e ""
+{
+	echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
+	echo -e "> Game\tINBOUND\t${port}\ttcp"
+	echo -e "> Query\tINBOUND\t${queryport}\ttcp"
+	echo -e "> Rcon\tINBOUND\t${rconport}\ttcp"
+} >> .fn_details_ports
+column -s $'\t' -t .fn_details_ports
+rm -f .fn_details_ports
+fn_details_statusbottom
+
+}
+
 fn_details_teamspeak3(){
 fn_details_config
 fn_details_distro
@@ -703,6 +735,8 @@ elif [ "${engine}" == "spark" ]; then
 	fn_details_spark
 elif [ "${engine}" == "starbound" ]; then
 	fn_details_starbound
+elif [ "${engine}" == "terraria" ]; then
+	fn_details_terraria
 elif [ "${engine}" == "unity3d" ]; then
 	fn_details_unity3d
 elif [ "${engine}" == "unreal" ] || [ "${engine}" == "unreal2" ]; then
@@ -713,4 +747,4 @@ elif [ "${gamename}" == "Teamspeak 3" ]; then
 	fn_details_teamspeak3
 else
 	fn_printerrornl "Unable to detect server engine."
-fi
\ No newline at end of file
+fi
diff --git a/functions/fn_install_logs b/functions/fn_install_logs
index ee1a47287..bde30a09f 100644
--- a/functions/fn_install_logs
+++ b/functions/fn_install_logs
@@ -2,7 +2,7 @@
 # LGSM fn_install_logs function
 # Author: Daniel Gibbs
 # Website: http://gameservermanagers.com
-# Version: 240415
+# Version: 070915
 
 if [ "${checklogs}" != "1" ]; then
 	echo ""
@@ -20,7 +20,7 @@ if [ -n "${consolelogdir}" ]; then
 fi
 
 # If a server is source or goldsource, Teamspeak 3, Starbound, Project Zomhoid create a symbolic link to the game server logs.
-if [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]||[ "${gamename}" == "Teamspeak 3" ]||[ "${engine}" == "starbound" ]||[ "${engine}" == "projectzomboid" ]; then
+if [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]||[ "${gamename}" == "Teamspeak 3" ]||[ "${engine}" == "starbound" ]||[ "${engine}" == "projectzomboid" ][ "${engine}" == "terraia" ]; then
 	if [ ! -h "${rootdir}/log/server" ]; then
 		ln -nfsv "${gamelogdir}" "${rootdir}/log/server"
 	fi
@@ -44,4 +44,4 @@ if [ -d "${rootdir}/Steam/logs" ]; then
 		ln -nfsv "${rootdir}/Steam/logs" "${rootdir}/log/steamcmd"
 	fi
 fi
-sleep 1
\ No newline at end of file
+sleep 1