From 94149361e6fe13653f445b6d1c9e9ef9775e5f22 Mon Sep 17 00:00:00 2001
From: UltimateByte <robin.labadie@gmail.com>
Date: Tue, 5 Jan 2016 18:48:45 +0100
Subject: [PATCH 01/54] Added ts3_server_password

---
 functions/command_ts3_server_password.sh | 71 ++++++++++++++++++++++++
 1 file changed, 71 insertions(+)
 create mode 100644 functions/command_ts3_server_password.sh

diff --git a/functions/command_ts3_server_password.sh b/functions/command_ts3_server_password.sh
new file mode 100644
index 000000000..7aee7b9f1
--- /dev/null
+++ b/functions/command_ts3_server_password.sh
@@ -0,0 +1,71 @@
+#!/bin/bash
+# LGSM command_serveradmin_password.sh function
+# Author: Daniel Gibbs
+# Contributor : UltimateByte
+# Website: http://gameservermanagers.com
+lgsm_version="030116"
+
+# Description: Changes TS3 serveradmin password
+
+local modulename="TS3 Server Password"
+function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+
+
+fn_serveradmin_password_prompt(){
+fn_printwarn "Initiating TS3 serveradmin password change"
+sleep 2
+echo -en "\n"
+echo "Changing telnet ServerQuery password"
+while true; do
+	read -p "Continue ? [y/n]" yn
+	case $yn in
+	[Yy]* ) break;;
+	[Nn]* ) exit;;
+	* ) echo "Please answer yes or no.";;
+	esac
+done
+
+fn_scriptlog "Initiating serveradmin password change"
+echo -n "Enter the new password : " ; read newpassword
+fn_scriptlog "New serveradmin password chosen"
+}
+
+
+fn_serveradmin_password_set(){
+fn_printdots "Applying new password"
+sleep 1
+fn_scriptlog "Starting routine with new password start option"
+
+./ts3server_startscript.sh start serveradmin_password="${newpassword}" > /dev/null 2>&1
+
+info_ts3status.sh
+if [ "${ts3status}" = "Server seems to have died" ]||[ "${ts3status}"	= "No server running (ts3server.pid is missing)" ]; then
+	fn_printfailnl "Unable to start ${servername}"
+	fn_scriptlog "Unable to start ${servername}"
+	echo -e "	Check log files: ${rootdir}/log"
+	exit 1
+else
+	fn_printok "${servername} has set a new serveradmin password"
+	echo -en "\n"
+	fn_scriptlog "Started ${servername} with new password"
+fi
+sleep 1
+}
+
+# Running functions
+check.sh
+fn_serveradmin_password_prompt
+info_ts3status.sh
+
+if [ "${ts3status}" == "Server is running" ]; then
+	command_stop.sh
+	fn_serveradmin_password_set
+	echo "Server will now restart normally"
+	sleep 1
+	command_stop.sh
+	command_start.sh
+else
+	fn_serveradmin_password_set
+	echo -en "\n"
+	command_stop.sh
+fi

From 9386317a77bdc24a816aec5215bb2ad5a4a870c7 Mon Sep 17 00:00:00 2001
From: UltimateByte <robin.labadie@gmail.com>
Date: Tue, 5 Jan 2016 19:16:50 +0100
Subject: [PATCH 02/54] adding ts3 functions

---
 functions/command_ts3_server_password.sh | 4 ++--
 functions/core_functions.sh              | 6 +++++-
 functions/core_getopt.sh                 | 5 ++++-
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/functions/command_ts3_server_password.sh b/functions/command_ts3_server_password.sh
index 7aee7b9f1..bb3803015 100644
--- a/functions/command_ts3_server_password.sh
+++ b/functions/command_ts3_server_password.sh
@@ -3,7 +3,7 @@
 # Author: Daniel Gibbs
 # Contributor : UltimateByte
 # Website: http://gameservermanagers.com
-lgsm_version="030116"
+lgsm_version="050116"
 
 # Description: Changes TS3 serveradmin password
 
@@ -68,4 +68,4 @@ else
 	fn_serveradmin_password_set
 	echo -en "\n"
 	command_stop.sh
-fi
+fi
\ No newline at end of file
diff --git a/functions/core_functions.sh b/functions/core_functions.sh
index 698365058..2f8d41654 100644
--- a/functions/core_functions.sh
+++ b/functions/core_functions.sh
@@ -2,7 +2,6 @@
 # LGSM core_functions.sh function
 # Author: Daniel Gibbs
 # Website: http://gameservermanagers.com
-lgsm_version="030116"
 
 # Description: Defines all functions to allow download and execution of functions using fn_runfunction.
 # This function is called first before any other function. Without this file other functions would not load.
@@ -85,6 +84,11 @@ functionfile="${FUNCNAME}"
 fn_runfunction
 }
 
+command_ts3_server_password.sh(){
+functionfile="${FUNCNAME}"
+fn_runfunction
+}
+
 fn_restart(){
 local modulename="Restarting"
 info_config.sh
diff --git a/functions/core_getopt.sh b/functions/core_getopt.sh
index 2b90be321..38143b728 100644
--- a/functions/core_getopt.sh
+++ b/functions/core_getopt.sh
@@ -2,7 +2,7 @@
 # LGSM core_getopt.sh function
 # Author: Daniel Gibbs
 # Website: http://gameservermanagers.com
-lgsm_version="271215"
+lgsm_version="050116"
 
 # Description: getopt arguments.
 
@@ -90,6 +90,8 @@ case "$getopt" in
 		command_details.sh;;
 	b|backup)
 		command_backup.sh;;
+        pw|serveradmin-password)
+                command_ts3_server_password.sh;;
 	dev|dev-debug)
 		command_dev_debug.sh;;		
 	i|install)
@@ -113,6 +115,7 @@ case "$getopt" in
 		echo -e "\e[34mmonitor\t\e[0mChecks that the server is running."
 		echo -e "\e[34memail-test\t\e[0mSends test monitor email."
 		echo -e "\e[34mdetails\t\e[0mDisplays useful infomation about the server."
+		echo -e "\e[34mserveradmin-password\t\e[0mChanges TS3 server password."
 		echo -e "\e[34mbackup\t\e[0mCreate archive of the server."
 		echo -e "\e[34minstall\t\e[0mInstall the server."
 		echo -e "\e[34mauto-install\t\e[0mInstall the server, without prompts."

From f6abfb26c42f5d86b0bbbe068a63367ac8c24d73 Mon Sep 17 00:00:00 2001
From: UltimateByte <robin.labadie@gmail.com>
Date: Tue, 5 Jan 2016 19:19:06 +0100
Subject: [PATCH 03/54] readded ts3db, updated date

---
 functions/core_functions.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/functions/core_functions.sh b/functions/core_functions.sh
index 2f8d41654..60a3e4213 100644
--- a/functions/core_functions.sh
+++ b/functions/core_functions.sh
@@ -2,6 +2,7 @@
 # LGSM core_functions.sh function
 # Author: Daniel Gibbs
 # Website: http://gameservermanagers.com
+lgsm_version="050116"
 
 # Description: Defines all functions to allow download and execution of functions using fn_runfunction.
 # This function is called first before any other function. Without this file other functions would not load.

From f08f9a5477407e99491dd269be67f22e02d9369c Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Thu, 7 Jan 2016 21:15:26 +0000
Subject: [PATCH 04/54] Shortened the command name

Shortened form password to use pass
---
 ...nd_ts3_server_password.sh => command_ts3_server_pass.sh} | 0
 functions/core_functions.sh                                 | 2 +-
 functions/core_getopt.sh                                    | 6 +++---
 3 files changed, 4 insertions(+), 4 deletions(-)
 rename functions/{command_ts3_server_password.sh => command_ts3_server_pass.sh} (100%)

diff --git a/functions/command_ts3_server_password.sh b/functions/command_ts3_server_pass.sh
similarity index 100%
rename from functions/command_ts3_server_password.sh
rename to functions/command_ts3_server_pass.sh
diff --git a/functions/core_functions.sh b/functions/core_functions.sh
index 1c1458595..560a2ee26 100644
--- a/functions/core_functions.sh
+++ b/functions/core_functions.sh
@@ -85,7 +85,7 @@ functionfile="${FUNCNAME}"
 fn_runfunction
 }
 
-command_ts3_server_password.sh(){
+command_ts3_server_pass.sh(){
 functionfile="${FUNCNAME}"
 fn_runfunction
 }
diff --git a/functions/core_getopt.sh b/functions/core_getopt.sh
index 38143b728..30bb0bf69 100644
--- a/functions/core_getopt.sh
+++ b/functions/core_getopt.sh
@@ -90,8 +90,8 @@ case "$getopt" in
 		command_details.sh;;
 	b|backup)
 		command_backup.sh;;
-        pw|serveradmin-password)
-                command_ts3_server_password.sh;;
+	pw|serveradmin-password)
+		command_ts3_server_pass.sh;;
 	dev|dev-debug)
 		command_dev_debug.sh;;		
 	i|install)
@@ -115,7 +115,7 @@ case "$getopt" in
 		echo -e "\e[34mmonitor\t\e[0mChecks that the server is running."
 		echo -e "\e[34memail-test\t\e[0mSends test monitor email."
 		echo -e "\e[34mdetails\t\e[0mDisplays useful infomation about the server."
-		echo -e "\e[34mserveradmin-password\t\e[0mChanges TS3 server password."
+		echo -e "\e[34mserveradmin-password\t\e[0mChanges TS3 serveradmin password."
 		echo -e "\e[34mbackup\t\e[0mCreate archive of the server."
 		echo -e "\e[34minstall\t\e[0mInstall the server."
 		echo -e "\e[34mauto-install\t\e[0mInstall the server, without prompts."

From 63589ee53e27c28dccb0667543492e2f0073b7ee Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Thu, 7 Jan 2016 22:11:49 +0000
Subject: [PATCH 05/54] Streamlined the command

* Streamlined the command to use command_start
* made interface mor like command_console and command_backup
---
 functions/command_start.sh           |  8 +++-
 functions/command_ts3_server_pass.sh | 58 ++++++++++++----------------
 2 files changed, 30 insertions(+), 36 deletions(-)

diff --git a/functions/command_start.sh b/functions/command_start.sh
index a79302698..d71b99e5a 100644
--- a/functions/command_start.sh
+++ b/functions/command_start.sh
@@ -2,7 +2,7 @@
 # LGSM command_start.sh function
 # Author: Daniel Gibbs
 # Website: http://gameservermanagers.com
-lgsm_version="271215"
+lgsm_version="070116"
 
 # Description: Starts the server.
 
@@ -55,7 +55,11 @@ mv "${scriptlog}" "${scriptlogdate}"
 # Create lock file
 date > "${rootdir}/${lockselfname}"
 cd "${executabledir}"
-./ts3server_startscript.sh start inifile="${servercfgfullpath}" > /dev/null 2>&1
+if [ "${ts2serverpass}" == "1" ];then
+	./ts3server_startscript.sh start serveradmin_password="${newpassword}" 
+else
+	./ts3server_startscript.sh start inifile="${servercfgfullpath}" > /dev/null 2>&1
+fi
 sleep 1
 info_ts3status.sh
 if [ "${ts3status}" = "Server seems to have died" ]||[ "${ts3status}"	= "No server running (ts3server.pid is missing)" ]; then
diff --git a/functions/command_ts3_server_pass.sh b/functions/command_ts3_server_pass.sh
index bb3803015..e5f980832 100644
--- a/functions/command_ts3_server_pass.sh
+++ b/functions/command_ts3_server_pass.sh
@@ -3,7 +3,7 @@
 # Author: Daniel Gibbs
 # Contributor : UltimateByte
 # Website: http://gameservermanagers.com
-lgsm_version="050116"
+lgsm_version="070116"
 
 # Description: Changes TS3 serveradmin password
 
@@ -12,43 +12,39 @@ function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 
 fn_serveradmin_password_prompt(){
-fn_printwarn "Initiating TS3 serveradmin password change"
-sleep 2
-echo -en "\n"
-echo "Changing telnet ServerQuery password"
+echo ""
+echo "${gamename} ServerAdmin Password Change"
+echo "============================"
+echo ""
+echo "Press \"CTRL+b d\" to exit console."
+fn_printwarningnl "You are about to change the ${gamename} ServerAdmin password"
+echo ""
 while true; do
-	read -p "Continue ? [y/n]" yn
+	read -e -i "y" -p "Continue? [y/N]" yn
 	case $yn in
 	[Yy]* ) break;;
-	[Nn]* ) exit;;
+	[Nn]* ) echo Exiting; return;;
 	* ) echo "Please answer yes or no.";;
-	esac
+esac
 done
-
-fn_scriptlog "Initiating serveradmin password change"
-echo -n "Enter the new password : " ; read newpassword
-fn_scriptlog "New serveradmin password chosen"
+fn_scriptlog "Initiating ${gamename} ServerAdmin password change"
+read -p "Enter new password : " newpassword
 }
 
 
 fn_serveradmin_password_set(){
-fn_printdots "Applying new password"
+fn_printinfo "Applying new password"
+fn_scriptlog "Applying new password"
 sleep 1
-fn_scriptlog "Starting routine with new password start option"
-
-./ts3server_startscript.sh start serveradmin_password="${newpassword}" > /dev/null 2>&1
-
-info_ts3status.sh
-if [ "${ts3status}" = "Server seems to have died" ]||[ "${ts3status}"	= "No server running (ts3server.pid is missing)" ]; then
-	fn_printfailnl "Unable to start ${servername}"
-	fn_scriptlog "Unable to start ${servername}"
-	echo -e "	Check log files: ${rootdir}/log"
-	exit 1
-else
-	fn_printok "${servername} has set a new serveradmin password"
-	echo -en "\n"
-	fn_scriptlog "Started ${servername} with new password"
-fi
+# Stop any running server
+command_stop.sh
+# Start server in "new password mode"
+ts3serverpass="1"
+command_start.sh
+# Stop server in "new password mode"
+command_stop.sh
+fn_printok "Applying new password"
+fn_scriptlog "New ServerAdmin password has been applyed"
 sleep 1
 }
 
@@ -58,14 +54,8 @@ fn_serveradmin_password_prompt
 info_ts3status.sh
 
 if [ "${ts3status}" == "Server is running" ]; then
-	command_stop.sh
 	fn_serveradmin_password_set
-	echo "Server will now restart normally"
-	sleep 1
-	command_stop.sh
 	command_start.sh
 else
 	fn_serveradmin_password_set
-	echo -en "\n"
-	command_stop.sh
 fi
\ No newline at end of file

From 56a7f1826da8a0fe5c5ffd78c072dff79d9e2648 Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Thu, 7 Jan 2016 22:13:50 +0000
Subject: [PATCH 06/54] date

---
 functions/core_getopt.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/functions/core_getopt.sh b/functions/core_getopt.sh
index 30bb0bf69..913801801 100644
--- a/functions/core_getopt.sh
+++ b/functions/core_getopt.sh
@@ -2,7 +2,7 @@
 # LGSM core_getopt.sh function
 # Author: Daniel Gibbs
 # Website: http://gameservermanagers.com
-lgsm_version="050116"
+lgsm_version="070116"
 
 # Description: getopt arguments.
 

From 1c60dc3b6a9895fe8914fcdc928255b5b3269d66 Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Thu, 7 Jan 2016 22:17:06 +0000
Subject: [PATCH 07/54] updated warning message

---
 functions/command_ts3_server_pass.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/functions/command_ts3_server_pass.sh b/functions/command_ts3_server_pass.sh
index e5f980832..556f9e6ff 100644
--- a/functions/command_ts3_server_pass.sh
+++ b/functions/command_ts3_server_pass.sh
@@ -17,7 +17,8 @@ echo "${gamename} ServerAdmin Password Change"
 echo "============================"
 echo ""
 echo "Press \"CTRL+b d\" to exit console."
-fn_printwarningnl "You are about to change the ${gamename} ServerAdmin password"
+fn_printinfonl "You are about to change the ${gamename} ServerAdmin password"
+fn_printwarningnl "${gamename} will restart during this process"
 echo ""
 while true; do
 	read -e -i "y" -p "Continue? [y/N]" yn

From a4a6d16953896f776d8c11ff3e4e966f57ed78ce Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Thu, 7 Jan 2016 22:20:20 +0000
Subject: [PATCH 08/54] corrected messages

---
 functions/command_ts3_server_pass.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/functions/command_ts3_server_pass.sh b/functions/command_ts3_server_pass.sh
index 556f9e6ff..231486215 100644
--- a/functions/command_ts3_server_pass.sh
+++ b/functions/command_ts3_server_pass.sh
@@ -17,7 +17,7 @@ echo "${gamename} ServerAdmin Password Change"
 echo "============================"
 echo ""
 echo "Press \"CTRL+b d\" to exit console."
-fn_printinfonl "You are about to change the ${gamename} ServerAdmin password"
+fn_printinfomationnl "You are about to change the ${gamename} ServerAdmin password"
 fn_printwarningnl "${gamename} will restart during this process"
 echo ""
 while true; do
@@ -34,7 +34,7 @@ read -p "Enter new password : " newpassword
 
 
 fn_serveradmin_password_set(){
-fn_printinfo "Applying new password"
+fn_printinfonl "Applying new password"
 fn_scriptlog "Applying new password"
 sleep 1
 # Stop any running server

From e056fc2b31a88c1d2cd20a078d2c1316060f69a7 Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Thu, 7 Jan 2016 22:21:26 +0000
Subject: [PATCH 09/54] added nl

---
 functions/command_ts3_server_pass.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/functions/command_ts3_server_pass.sh b/functions/command_ts3_server_pass.sh
index 231486215..c92581ec7 100644
--- a/functions/command_ts3_server_pass.sh
+++ b/functions/command_ts3_server_pass.sh
@@ -44,7 +44,7 @@ ts3serverpass="1"
 command_start.sh
 # Stop server in "new password mode"
 command_stop.sh
-fn_printok "Applying new password"
+fn_printoknl "Applying new password"
 fn_scriptlog "New ServerAdmin password has been applyed"
 sleep 1
 }

From 656746f2cdd833687f951eccba9dcce2b4262a5f Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Thu, 7 Jan 2016 22:35:01 +0000
Subject: [PATCH 10/54] More interface changes

---
 functions/command_ts3_server_pass.sh | 11 ++++++-----
 functions/core_getopt.sh             |  2 +-
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/functions/command_ts3_server_pass.sh b/functions/command_ts3_server_pass.sh
index c92581ec7..f8563f3d2 100644
--- a/functions/command_ts3_server_pass.sh
+++ b/functions/command_ts3_server_pass.sh
@@ -7,7 +7,7 @@ lgsm_version="070116"
 
 # Description: Changes TS3 serveradmin password
 
-local modulename="TS3 Server Password"
+local modulename="Change password"
 function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 
@@ -17,8 +17,8 @@ echo "${gamename} ServerAdmin Password Change"
 echo "============================"
 echo ""
 echo "Press \"CTRL+b d\" to exit console."
-fn_printinfomationnl "You are about to change the ${gamename} ServerAdmin password"
-fn_printwarningnl "${gamename} will restart during this process"
+fn_printinfomationnl "You are about to change the ${gamename} ServerAdmin password."
+fn_printwarningnl "${gamename} will restart during this process."
 echo ""
 while true; do
 	read -e -i "y" -p "Continue? [y/N]" yn
@@ -41,11 +41,12 @@ sleep 1
 command_stop.sh
 # Start server in "new password mode"
 ts3serverpass="1"
+fn_printinfonl "Starting with new password"
 command_start.sh
 # Stop server in "new password mode"
 command_stop.sh
-fn_printoknl "Applying new password"
-fn_scriptlog "New ServerAdmin password has been applyed"
+fn_printoknl "Password applied"
+fn_scriptlog "New ServerAdmin password applied"
 sleep 1
 }
 
diff --git a/functions/core_getopt.sh b/functions/core_getopt.sh
index 913801801..9c848b5fd 100644
--- a/functions/core_getopt.sh
+++ b/functions/core_getopt.sh
@@ -90,7 +90,7 @@ case "$getopt" in
 		command_details.sh;;
 	b|backup)
 		command_backup.sh;;
-	pw|serveradmin-password)
+	pw|change-password)
 		command_ts3_server_pass.sh;;
 	dev|dev-debug)
 		command_dev_debug.sh;;		

From a50e2dc8c786df9a350b975b72dba3b251e6c5ce Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Thu, 7 Jan 2016 22:37:58 +0000
Subject: [PATCH 11/54] corrected  message

---
 functions/core_getopt.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/functions/core_getopt.sh b/functions/core_getopt.sh
index 9c848b5fd..95196d0ef 100644
--- a/functions/core_getopt.sh
+++ b/functions/core_getopt.sh
@@ -115,7 +115,7 @@ case "$getopt" in
 		echo -e "\e[34mmonitor\t\e[0mChecks that the server is running."
 		echo -e "\e[34memail-test\t\e[0mSends test monitor email."
 		echo -e "\e[34mdetails\t\e[0mDisplays useful infomation about the server."
-		echo -e "\e[34mserveradmin-password\t\e[0mChanges TS3 serveradmin password."
+		echo -e "\e[34mchange-password\t\e[0mChanges TS3 serveradmin password."
 		echo -e "\e[34mbackup\t\e[0mCreate archive of the server."
 		echo -e "\e[34minstall\t\e[0mInstall the server."
 		echo -e "\e[34mauto-install\t\e[0mInstall the server, without prompts."

From 2ce3389e31a2ca31f527291b06bf0d4505a8009b Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Thu, 7 Jan 2016 22:39:53 +0000
Subject: [PATCH 12/54] word server

---
 functions/command_ts3_server_pass.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/functions/command_ts3_server_pass.sh b/functions/command_ts3_server_pass.sh
index f8563f3d2..424d3ed1f 100644
--- a/functions/command_ts3_server_pass.sh
+++ b/functions/command_ts3_server_pass.sh
@@ -41,7 +41,7 @@ sleep 1
 command_stop.sh
 # Start server in "new password mode"
 ts3serverpass="1"
-fn_printinfonl "Starting with new password"
+fn_printinfonl "Starting server with new password"
 command_start.sh
 # Stop server in "new password mode"
 command_stop.sh

From 9dd1b0c83e1f04e19245de1e5d7b167c1dde2791 Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Thu, 7 Jan 2016 22:45:06 +0000
Subject: [PATCH 13/54] minor fix

---
 functions/command_start.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/functions/command_start.sh b/functions/command_start.sh
index d71b99e5a..309a8078f 100644
--- a/functions/command_start.sh
+++ b/functions/command_start.sh
@@ -55,7 +55,7 @@ mv "${scriptlog}" "${scriptlogdate}"
 # Create lock file
 date > "${rootdir}/${lockselfname}"
 cd "${executabledir}"
-if [ "${ts2serverpass}" == "1" ];then
+if [ "${ts3serverpass}" == "1" ];then
 	./ts3server_startscript.sh start serveradmin_password="${newpassword}" 
 else
 	./ts3server_startscript.sh start inifile="${servercfgfullpath}" > /dev/null 2>&1

From cfa3ffa409be7f756b68900fb098c54ebab5b04b Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Fri, 8 Jan 2016 20:20:37 +0000
Subject: [PATCH 14/54] date

---
 functions/command_ts3_server_pass.sh | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/functions/command_ts3_server_pass.sh b/functions/command_ts3_server_pass.sh
index 424d3ed1f..3cd0f0b1f 100644
--- a/functions/command_ts3_server_pass.sh
+++ b/functions/command_ts3_server_pass.sh
@@ -3,7 +3,7 @@
 # Author: Daniel Gibbs
 # Contributor : UltimateByte
 # Website: http://gameservermanagers.com
-lgsm_version="070116"
+lgsm_version="080116"
 
 # Description: Changes TS3 serveradmin password
 
@@ -54,7 +54,6 @@ sleep 1
 check.sh
 fn_serveradmin_password_prompt
 info_ts3status.sh
-
 if [ "${ts3status}" == "Server is running" ]; then
 	fn_serveradmin_password_set
 	command_start.sh

From 020a153c79007e558e4384885c33eff4c14418f0 Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Sun, 10 Jan 2016 00:45:55 +0000
Subject: [PATCH 15/54] Added BB2 to GSLT

---
 functions/command_install.sh | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/functions/command_install.sh b/functions/command_install.sh
index 75e6c0060..b654410a2 100644
--- a/functions/command_install.sh
+++ b/functions/command_install.sh
@@ -30,11 +30,9 @@ fix.sh
 install_logs.sh
 install_gsquery.sh
 install_config.sh
-if [ "${gamename}" == "Counter Strike: Global Offensive" ]; then
+if [ "${gamename}" == "Counter Strike: Global Offensive" ]||[ "${gamename}" == "Team Fortress 2" ]||[ "${gamename}" == "Brain Bread 2" ]; then
 	install_gslt.sh
 elif [ "${gamename}" == "Teamspeak 3" ]; then
 	install_ts3db.sh
-elif [ "${gamename}" == "Team Fortress 2" ]; then
-	install_gslt.sh
 fi
 install_complete.sh

From 516a0af30e994c8430155e5ee5b4320b55bded1b Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Sun, 10 Jan 2016 00:49:50 +0000
Subject: [PATCH 16/54] Added bb2server

---
 BrainBread2/bb2server | 138 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 138 insertions(+)
 create mode 100644 BrainBread2/bb2server

diff --git a/BrainBread2/bb2server b/BrainBread2/bb2server
new file mode 100644
index 000000000..fc93b31b5
--- /dev/null
+++ b/BrainBread2/bb2server
@@ -0,0 +1,138 @@
+#!/bin/bash
+# BrainBread 2
+# Server Management Script
+# Author: Daniel Gibbs
+# Website: http://gameservermanagers.com
+if [ -f ".dev-debug" ]; then
+	exec 5>dev-debug.log
+	BASH_XTRACEFD="5"
+	set -x
+fi
+
+version="090116"
+
+#### Variables ####
+
+# Notification Email
+# (on|off)
+emailnotification="off"
+email="email@example.com"
+
+# Steam login
+steamuser="username"
+steampass="password"
+
+# Start Variables
+defaultmap="bba_barracks"
+maxplayers="20"
+port="27015"
+sourcetvport="27020"
+clientport="27005"
+ip="0.0.0.0"
+updateonstart="off"
+
+# https://developer.valvesoftware.com/wiki/Command_Line_Options#Source_Dedicated_Server
+fn_parms(){
+parms="-game brainbread2 -strictportbind -ip ${ip} -port ${port} +clientport ${clientport} +tv_port ${sourcetvport} +map ${defaultmap} +servercfgfile ${servercfg} -maxplayers ${maxplayers}"
+}
+
+#### 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="master"
+
+# Steam
+appid="346330"
+
+# Server Details
+servicename="bb2-server"
+gamename="BrainBread 2"
+engine="source"
+
+# Directories
+rootdir="$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
+selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+lockselfname=".${servicename}.lock"
+filesdir="${rootdir}/serverfiles"
+systemdir="${filesdir}/brainbread2"
+executabledir="${filesdir}"
+executable="./srcds_run"
+servercfg="${servicename}.cfg"
+servercfgdir="${systemdir}/cfg"
+servercfgfullpath="${servercfgdir}/${servercfg}"
+servercfgdefault="${servercfgdir}/lgsm-default.cfg"
+backupdir="${rootdir}/backups"
+
+# Logging
+logdays="7"
+gamelogdir="${systemdir}/logs"
+scriptlogdir="${rootdir}/log/script"
+consolelogdir="${rootdir}/log/console"
+
+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}"
+		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
+}
+
+core_functions.sh(){
+# Functions are defined in core_functions.sh.
+functionfile="${FUNCNAME}"
+fn_runfunction
+}
+
+core_functions.sh
+
+getopt=$1
+core_getopt.sh

From b9f130e5edb70569a540e89ad5f633455ec8739f Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Sun, 10 Jan 2016 09:39:57 +0000
Subject: [PATCH 17/54] Changed Server to Game

---
 FistfulOfFrags/cfg/lgsm-default.cfg            | 4 ++--
 NoMoreRoomInHell/cfg/lgsm-default.cfg          | 4 ++--
 PiratesVikingandKnightsII/cfg/lgsm-default.cfg | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/FistfulOfFrags/cfg/lgsm-default.cfg b/FistfulOfFrags/cfg/lgsm-default.cfg
index d7e1d9aa9..81d9929fc 100644
--- a/FistfulOfFrags/cfg/lgsm-default.cfg
+++ b/FistfulOfFrags/cfg/lgsm-default.cfg
@@ -1,7 +1,7 @@
 // ****************************************************************************
 //                                                                            *
 //     Fistful of Frags - server.cfg                                          *
-//     Version 271015                                                         *
+//     Version 100116                                                         *
 //                                                                            *
 // ****************************************************************************
 
@@ -40,7 +40,7 @@ mapcyclefile "mapcycle.txt"
 // Default: mp_timelimit 0
 mp_timelimit 15
 
-// ........................ Server Specific Commands ........................ //
+// ........................ Game Specific Commands ........................ //
 // info: any commands that only apply to this game.
 
 // Game Modes
diff --git a/NoMoreRoomInHell/cfg/lgsm-default.cfg b/NoMoreRoomInHell/cfg/lgsm-default.cfg
index 83645c78c..ba48eab5b 100644
--- a/NoMoreRoomInHell/cfg/lgsm-default.cfg
+++ b/NoMoreRoomInHell/cfg/lgsm-default.cfg
@@ -1,7 +1,7 @@
 // ****************************************************************************
 //                                                                            *
 //     No More Room in Hell - server.cfg                                      *
-//     Version 150815                                                         *
+//     Version 100116                                                         *
 //                                                                            *
 // ****************************************************************************
 
@@ -43,7 +43,7 @@ mp_timelimit 45
 // Default: mp_maxrounds 2
 mp_maxrounds 2
 
-// ........................ Server Specific Commands ........................ //
+// ........................ Game Specific Commands ........................ //
 // info: any commands that only apply to this game.
 
 // Difficulty
diff --git a/PiratesVikingandKnightsII/cfg/lgsm-default.cfg b/PiratesVikingandKnightsII/cfg/lgsm-default.cfg
index 8469f1014..48ba5072a 100644
--- a/PiratesVikingandKnightsII/cfg/lgsm-default.cfg
+++ b/PiratesVikingandKnightsII/cfg/lgsm-default.cfg
@@ -1,7 +1,7 @@
 // ****************************************************************************
 //                                                                            *
 //     Pirates, Vikings, and Knights II                                       *
-//     Version 150815                                                         *
+//     Version 100116                                                         *
 //                                                                            *
 // ****************************************************************************
 
@@ -48,7 +48,7 @@ mp_roundtime 3
 // Default: mp_winlimit 0
 mp_winlimit 0
 
-// ........................ Server Specific Commands ........................ //
+// ........................ Game Specific Commands ........................ //
 
 // Server tags - Tags show up on the in-game server browser. This helps 
 // users filter servers.

From 8eedfbd01a9d7cede9a48149e0ab86a26dcbb2fa Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Sun, 10 Jan 2016 10:25:30 +0000
Subject: [PATCH 18/54] Changed Server to game

---
 FistfulOfFrags/cfg/lgsm-default.cfg            | 4 ++--
 NoMoreRoomInHell/cfg/lgsm-default.cfg          | 4 ++--
 PiratesVikingandKnightsII/cfg/lgsm-default.cfg | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/FistfulOfFrags/cfg/lgsm-default.cfg b/FistfulOfFrags/cfg/lgsm-default.cfg
index d7e1d9aa9..81d9929fc 100644
--- a/FistfulOfFrags/cfg/lgsm-default.cfg
+++ b/FistfulOfFrags/cfg/lgsm-default.cfg
@@ -1,7 +1,7 @@
 // ****************************************************************************
 //                                                                            *
 //     Fistful of Frags - server.cfg                                          *
-//     Version 271015                                                         *
+//     Version 100116                                                         *
 //                                                                            *
 // ****************************************************************************
 
@@ -40,7 +40,7 @@ mapcyclefile "mapcycle.txt"
 // Default: mp_timelimit 0
 mp_timelimit 15
 
-// ........................ Server Specific Commands ........................ //
+// ........................ Game Specific Commands ........................ //
 // info: any commands that only apply to this game.
 
 // Game Modes
diff --git a/NoMoreRoomInHell/cfg/lgsm-default.cfg b/NoMoreRoomInHell/cfg/lgsm-default.cfg
index 83645c78c..ba48eab5b 100644
--- a/NoMoreRoomInHell/cfg/lgsm-default.cfg
+++ b/NoMoreRoomInHell/cfg/lgsm-default.cfg
@@ -1,7 +1,7 @@
 // ****************************************************************************
 //                                                                            *
 //     No More Room in Hell - server.cfg                                      *
-//     Version 150815                                                         *
+//     Version 100116                                                         *
 //                                                                            *
 // ****************************************************************************
 
@@ -43,7 +43,7 @@ mp_timelimit 45
 // Default: mp_maxrounds 2
 mp_maxrounds 2
 
-// ........................ Server Specific Commands ........................ //
+// ........................ Game Specific Commands ........................ //
 // info: any commands that only apply to this game.
 
 // Difficulty
diff --git a/PiratesVikingandKnightsII/cfg/lgsm-default.cfg b/PiratesVikingandKnightsII/cfg/lgsm-default.cfg
index 8469f1014..48ba5072a 100644
--- a/PiratesVikingandKnightsII/cfg/lgsm-default.cfg
+++ b/PiratesVikingandKnightsII/cfg/lgsm-default.cfg
@@ -1,7 +1,7 @@
 // ****************************************************************************
 //                                                                            *
 //     Pirates, Vikings, and Knights II                                       *
-//     Version 150815                                                         *
+//     Version 100116                                                         *
 //                                                                            *
 // ****************************************************************************
 
@@ -48,7 +48,7 @@ mp_roundtime 3
 // Default: mp_winlimit 0
 mp_winlimit 0
 
-// ........................ Server Specific Commands ........................ //
+// ........................ Game Specific Commands ........................ //
 
 // Server tags - Tags show up on the in-game server browser. This helps 
 // users filter servers.

From e0ec06b91fea98f18a64a008b827464e9e70bcaa Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Sun, 10 Jan 2016 10:25:41 +0000
Subject: [PATCH 19/54] Added Brainbread 2 config

---
 BrainBread2/cfg/lgsm-default.cfg | 200 +++++++++++++++++++++++++++++++
 1 file changed, 200 insertions(+)
 create mode 100644 BrainBread2/cfg/lgsm-default.cfg

diff --git a/BrainBread2/cfg/lgsm-default.cfg b/BrainBread2/cfg/lgsm-default.cfg
new file mode 100644
index 000000000..4b4ac2513
--- /dev/null
+++ b/BrainBread2/cfg/lgsm-default.cfg
@@ -0,0 +1,200 @@
+// ****************************************************************************
+//                                                                            *
+//     BrainBread 2 - server.cfg                                             *
+//     Version 080116                                                         *
+//                                                                            *
+// ****************************************************************************
+
+// ............................. Basic Settings ............................. //
+
+// Hostname for server.
+hostname "<hostname>"
+
+// RCON - remote console password.
+rcon_password "<rconpassword>"
+
+// Server password - for private servers.
+sv_password ""
+
+// Contact email for server sysop.
+sv_contact "email@example.com"
+
+// LAN Mode - If set the server will not show on the internet.
+// Default: sv_lan 0
+sv_lan 0
+
+// Cheats - Allows cheats on the server. Steam achievements and stats are disabled.
+// Default: 0
+sv_cheats 0
+
+// Friendly Fire - Allows team members to injure other members of their team.
+// 0 = Friendly fire off.
+// 1 = Friendly fire on.
+// Default: 0
+mp_friendlyfire 0
+
+// ........................ Game Specific Commands ........................ //
+// info: any commands that only apply to this game.
+
+
+// Mercy Value - Sets how many deaths until the players become human once again.
+// Default: bb2_allow_mercy 0
+bb2_allow_mercy 3
+
+// Late Joining - Allows players to spawn late.
+// default bb2_allow_latejoin 0
+bb2_allow_latejoin 1
+
+// Player Spawn Protection - Time in seconds after Spawn.
+// default bb2_spawn_protection 1
+bb2_spawn_protection 15
+
+// Profile System - Allow players to save and load there skills.
+// 0 = Disabled, skills are not saved.
+// 1 = Global, players can load there global skills.
+// 2 = Server, players save there skills to the server. Steam achievements and stats are disabled.
+// Default 1
+bb2_allow_profile_system 1
+
+// Allow NPC to score - Allow friendly npcs to affect scoring. For example for quests.
+// Default 1
+bb2_allow_npc_to_score 0
+
+// Vote Settings
+
+// Voting: Passing Votes - Percentage of players that are required to pass a vote.
+// Minimum: 0
+// Maximum: 100
+// Default 50
+bb2_votes_required 50
+
+// Voting: Ban Time - Number of minutes a player be banned if a vaote ban passes.
+// minimum: 0 (permanent)
+// default 30
+bb2_ban_time 30
+
+
+// Arena Settings
+
+// Arena: Respawn Interval Time (Seconds).
+// Minimum: 20
+// Default 40
+bb2_arena_respawn_time 25
+
+// Arena: Number of Reinforcements.
+// Minimum: 0
+// Maximum: 100
+// Default 14
+bb2_arena_reinforcement_count 14
+
+
+// Classic Mode Settings
+
+// Classic: Zombie No Team Change.
+// 0 = Players can become zombies.
+// 1 = Players cannot become zombies.
+// Default 0
+bb2_classic_zombie_noteamchange 1
+
+
+// Elimination Settings
+
+// Elimination: Team Fraglimit - Number of frags for a team to win a game.
+// Minimum: 10
+// Default 200
+bb2_elimination_fraglimit 200
+
+// Elimination: Respawn Time (Seconds).
+// Minimum: 1
+// Maximum: 30
+// Default 4
+bb2_elimination_respawn_time 5
+
+// Elimination: Respawn Time Scale - Increase the respawn time by this many seconds for the teams.
+// Minimum: 0
+// Maximum: 10
+// Default 1
+bb2_elimination_respawn_time_scale 1
+
+// Elimination: Extermination Score - The score a team should be awarded for exterminating (kill everyone before respawn) the other team. 
+// Minimum: 0
+// Maximum: 50
+// Default 25
+bb2_elimination_score_from_extermination 25
+
+// Elimination: Zombie Score - Number of point a zombie gets for a kill.
+// Minimum: 2
+// Maximum: 10
+// Default 5
+bb2_elimination_score_zombies 5
+
+// Elimination: Team Perk Duration - Number of seconds a team perk lasts.
+// Minimum: 5
+// Maximum: 60
+// Default 30
+bb2_elimination_teamperk_duration 30
+
+// Elimination: Team Perk Required Kills - Number of kills a team need to get in order to activate a team perk.
+// Minimum: 25
+// Maximum: 500
+// Default 50
+bb2_elimination_teamperk_kills_required 50
+
+
+// Zombie Settings
+
+// Zombie Lifespan - Number of minutes a regular zombie will last before dying.
+// Minimum: 1
+// Default 5
+bb2_zombie_lifespan 2
+
+// Max Zombies - Maximum number of zombies allowed in the game.
+// Minimum: 1
+// Maximum: 128
+// Default 50
+bb2_zombie_max 45
+
+
+// M1A1 Abrams Settings
+
+// M1A1 Abrams: Main Cannon Damage.
+// Minimum: 100
+// Maximum: 10000
+// Default 3000
+bb2_m1a1_damage 200
+
+// M1A1 Abrams: Machinegun Damage.
+// Minimum: 25
+// Maximum: 1000
+// Default 30
+bb2_m1a1_damage_machinegun 25
+
+// M1A1 Abrams: Friendly Fire (Including NPC's).
+// Minimum: 0
+// Maximum: 1
+// Default 1
+bb2_m1a1_friendly 1
+
+// M1A1 Abrams: Machinegun Rate of Fire.
+// Minimum: 0.01
+// Maximum: 1
+// Default 0.08
+bb2_m1a1_machinegun_firerate 1
+
+// M1A1 Abrams: Explosion Radius.
+// Minimum: 200
+// Maximum: 10000
+// Default 500
+bb2_m1a1_radius 500
+
+// M1A1 Abrams: Max Sight Range.
+// Minimum: 500
+// Maximum: 10000
+// Default 2000
+bb2_m1a1_range_max 1000
+
+// M1A1 Abrams: Min Sight Range.
+// Minimum: 250
+// Maximum: 5000
+// Default 400
+bb2_m1a1_range_min 250
\ No newline at end of file

From a587cfc7d2bbf533b4687e64e87a892d75053b16 Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Sun, 10 Jan 2016 10:38:43 +0000
Subject: [PATCH 20/54] Install SteamCMD now uses the check instead

check_steamcmd has more functionality for installing SteamCMD. Install
now points to check
---
 functions/install_steamcmd.sh | 29 +----------------------------
 1 file changed, 1 insertion(+), 28 deletions(-)

diff --git a/functions/install_steamcmd.sh b/functions/install_steamcmd.sh
index fe944a253..1f744e7f6 100644
--- a/functions/install_steamcmd.sh
+++ b/functions/install_steamcmd.sh
@@ -10,31 +10,4 @@ echo ""
 echo "Installing SteamCMD"
 echo "================================="
 sleep 1
-steamcmddir="${rootdir}/steamcmd"
-if [ ! -f "${steamcmddir}/steamcmd.sh" ]; then
-	if [ ! -d "${steamcmddir}" ]; then
-		mkdir -v "${steamcmddir}"
-	fi
-	curl=$(curl --fail -o "${steamcmddir}/steamcmd_linux.tar.gz" "http://media.steampowered.com/client/steamcmd_linux.tar.gz" 2>&1)
-	exitcode=$?
-	echo -e "downloading steamcmd_linux.tar.gz...\c"
-	if [ $exitcode -eq 0 ]; then
-		fn_printokeol
-	else
-		fn_printfaileol
-		echo "${curl}"
-		echo -e "${githuburl}\n"
-		exit $exitcode
-	fi
-	tar --verbose -zxf "${steamcmddir}/steamcmd_linux.tar.gz" -C "${steamcmddir}"
-	rm -v "${steamcmddir}/steamcmd_linux.tar.gz"
-	chmod +x "${steamcmddir}/steamcmd.sh"
-else
-	echo "SteamCMD already installed!"
-fi
-	# Checks that steamcmd is working correctly and will prompt Steam Guard if required.
-	"${steamcmddir}"/steamcmd.sh +login "${steamuser}" "${steampass}" +quit
-	if [ $? -ne 0 ]; then
-		fn_printfailurenl "Error running SteamCMD"
-	fi	
-sleep 1
+check_steamcmd.sh

From 628a04583b9ff7509d2c5799c1b3e75a7c69188b Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Sun, 10 Jan 2016 10:39:02 +0000
Subject: [PATCH 21/54] Added BrainBread 2 Config

---
 functions/install_config.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/functions/install_config.sh b/functions/install_config.sh
index 142a680e2..f0d57ea14 100644
--- a/functions/install_config.sh
+++ b/functions/install_config.sh
@@ -2,7 +2,7 @@
 # LGSM install_config.sh function
 # Author: Daniel Gibbs
 # Website: http://gameservermanagers.com
-lgsm_version="271215"
+lgsm_version="100116"
 
 fn_defaultconfig(){
 	echo "creating ${servercfg} config file."
@@ -165,6 +165,11 @@ elif [ "${gamename}" == "ARMA 3" ]; then
 	wget -N /dev/null ${githuburl}/Arma3/cfg/lgsm-default.network.cfg 2>&1 | grep -F HTTP | cut -c45- | uniq
 	sleep 1
 	fn_arma3config
+elif [ "${gamename}" == "BrainBread 2" ]; then
+	echo -e "downloading lgsm-default.cfg...\c"
+	wget -N /dev/null ${githuburl}/BrainBread2/cfg/lgsm-default.cfg 2>&1 | grep -F HTTP | cut -c45- | uniq
+	sleep 1
+	fn_sourceconfig	
 elif [ "${gamename}" == "Black Mesa: Deathmatch" ]; then
 	echo -e "downloading lgsm-default.cfg...\c"
 	wget -N /dev/null ${githuburl}/BlackMesa/cfg/lgsm-default.cfg 2>&1 | grep -F HTTP | cut -c45- | uniq

From 8c9ac26c054a35f61ce4bc16c33084f9a2db0f75 Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Sun, 10 Jan 2016 11:01:54 +0000
Subject: [PATCH 22/54] Corrected Name BrainBread 2

---
 functions/command_install.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/functions/command_install.sh b/functions/command_install.sh
index b654410a2..f2021f071 100644
--- a/functions/command_install.sh
+++ b/functions/command_install.sh
@@ -30,7 +30,7 @@ fix.sh
 install_logs.sh
 install_gsquery.sh
 install_config.sh
-if [ "${gamename}" == "Counter Strike: Global Offensive" ]||[ "${gamename}" == "Team Fortress 2" ]||[ "${gamename}" == "Brain Bread 2" ]; then
+if [ "${gamename}" == "Counter Strike: Global Offensive" ]||[ "${gamename}" == "Team Fortress 2" ]||[ "${gamename}" == "BrainBread 2" ]; then
 	install_gslt.sh
 elif [ "${gamename}" == "Teamspeak 3" ]; then
 	install_ts3db.sh

From 469fd3deea1aa5834cb1cc3335c3f684525cf3be Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Sun, 10 Jan 2016 11:05:05 +0000
Subject: [PATCH 23/54] Added GSLT support

---
 BrainBread2/bb2server | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/BrainBread2/bb2server b/BrainBread2/bb2server
index fc93b31b5..4ae9489f5 100644
--- a/BrainBread2/bb2server
+++ b/BrainBread2/bb2server
@@ -31,9 +31,14 @@ clientport="27005"
 ip="0.0.0.0"
 updateonstart="off"
 
+# Required: Game Server Login Token
+# GSLT is required for running a public server.
+# More info: http://gameservermanagers.com/gslt
+gslt=""
+
 # https://developer.valvesoftware.com/wiki/Command_Line_Options#Source_Dedicated_Server
 fn_parms(){
-parms="-game brainbread2 -strictportbind -ip ${ip} -port ${port} +clientport ${clientport} +tv_port ${sourcetvport} +map ${defaultmap} +servercfgfile ${servercfg} -maxplayers ${maxplayers}"
+parms="-game brainbread2 -strictportbind -ip ${ip} -port ${port} +clientport ${clientport} +tv_port ${sourcetvport} +sv_setsteamaccount ${gslt} +map ${defaultmap} +servercfgfile ${servercfg} -maxplayers ${maxplayers}"
 }
 
 #### Advanced Variables ####

From 08a5ea1e03cb6d58bd5fe55cd90729f30fa4c787 Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Sun, 10 Jan 2016 11:13:30 +0000
Subject: [PATCH 24/54] Added -insecure to parms

---
 BrainBread2/bb2server | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BrainBread2/bb2server b/BrainBread2/bb2server
index 4ae9489f5..a78fdbc5a 100644
--- a/BrainBread2/bb2server
+++ b/BrainBread2/bb2server
@@ -38,7 +38,7 @@ gslt=""
 
 # https://developer.valvesoftware.com/wiki/Command_Line_Options#Source_Dedicated_Server
 fn_parms(){
-parms="-game brainbread2 -strictportbind -ip ${ip} -port ${port} +clientport ${clientport} +tv_port ${sourcetvport} +sv_setsteamaccount ${gslt} +map ${defaultmap} +servercfgfile ${servercfg} -maxplayers ${maxplayers}"
+parms="-game brainbread2 -insecure -strictportbind -ip ${ip} -port ${port} +clientport ${clientport} +tv_port ${sourcetvport} +sv_setsteamaccount ${gslt} +map ${defaultmap} +servercfgfile ${servercfg} -maxplayers ${maxplayers}"
 }
 
 #### Advanced Variables ####

From ba7e5e1ca595004b5aaac0a35004dc44a3e88c35 Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Sun, 10 Jan 2016 11:27:36 +0000
Subject: [PATCH 25/54] Updated Respawn Time Scale Description

---
 BrainBread2/cfg/lgsm-default.cfg | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/BrainBread2/cfg/lgsm-default.cfg b/BrainBread2/cfg/lgsm-default.cfg
index 4b4ac2513..1efd799d6 100644
--- a/BrainBread2/cfg/lgsm-default.cfg
+++ b/BrainBread2/cfg/lgsm-default.cfg
@@ -110,7 +110,8 @@ bb2_elimination_fraglimit 200
 // Default 4
 bb2_elimination_respawn_time 5
 
-// Elimination: Respawn Time Scale - Increase the respawn time by this many seconds for the teams.
+// Elimination: Respawn Time Scale - Increase the respawn timer in seconds when a player joins.  or 14 + (20 x 2) = 34).
+// Example: respawn_timer + (total_players x time_scale) = new_respawn_timer. 14 + (20 x 2) = 54).
 // Minimum: 0
 // Maximum: 10
 // Default 1

From 32bb0cb97392ab64b36dd85743f9333c0e576493 Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Sun, 10 Jan 2016 11:35:47 +0000
Subject: [PATCH 26/54] Corrected desc

---
 BrainBread2/cfg/lgsm-default.cfg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BrainBread2/cfg/lgsm-default.cfg b/BrainBread2/cfg/lgsm-default.cfg
index 1efd799d6..13b5184f5 100644
--- a/BrainBread2/cfg/lgsm-default.cfg
+++ b/BrainBread2/cfg/lgsm-default.cfg
@@ -110,7 +110,7 @@ bb2_elimination_fraglimit 200
 // Default 4
 bb2_elimination_respawn_time 5
 
-// Elimination: Respawn Time Scale - Increase the respawn timer in seconds when a player joins.  or 14 + (20 x 2) = 34).
+// Elimination: Respawn Time Scale - Increase the respawn timer in seconds when a player joins.
 // Example: respawn_timer + (total_players x time_scale) = new_respawn_timer. 14 + (20 x 2) = 54).
 // Minimum: 0
 // Maximum: 10

From 607e41749f12d3923d04159c37f27319226fc7ee Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Sun, 10 Jan 2016 11:38:35 +0000
Subject: [PATCH 27/54] more corrections

---
 BrainBread2/cfg/lgsm-default.cfg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BrainBread2/cfg/lgsm-default.cfg b/BrainBread2/cfg/lgsm-default.cfg
index 13b5184f5..e016e66fb 100644
--- a/BrainBread2/cfg/lgsm-default.cfg
+++ b/BrainBread2/cfg/lgsm-default.cfg
@@ -111,7 +111,7 @@ bb2_elimination_fraglimit 200
 bb2_elimination_respawn_time 5
 
 // Elimination: Respawn Time Scale - Increase the respawn timer in seconds when a player joins.
-// Example: respawn_timer + (total_players x time_scale) = new_respawn_timer. 14 + (20 x 2) = 54).
+// Example: respawn_timer + (joined_players x time_scale) = new_respawn_timer. 14 + (20 x 2) = 54.
 // Minimum: 0
 // Maximum: 10
 // Default 1

From e26126dfba9f3f3114a0cede31cf972ba2e0681d Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Sun, 10 Jan 2016 12:23:10 +0000
Subject: [PATCH 28/54] Removed SteamCMD check from start stop and debug

As this check cuases issue on dev when i pre-load the server files.
---
 functions/check.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/functions/check.sh b/functions/check.sh
index 86e141416..150a8e138 100644
--- a/functions/check.sh
+++ b/functions/check.sh
@@ -41,7 +41,7 @@ do
 	fi
 done
 
-local allowed_commands_array=( command_debug.sh command_start.sh command_stop.sh update_check.sh command_validate.sh )
+local allowed_commands_array=( update_check.sh command_validate.sh )
 for allowed_command in "${allowed_commands_array[@]}"
 do
 	if [ "${allowed_command}" == "${function_selfname}" ]; then

From 55d048079ab2e69d72b82848cf71092b6a7a0f9f Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Thu, 14 Jan 2016 20:06:20 +0000
Subject: [PATCH 29/54] Brain Bread 2 added  Glibc Requirements

---
 functions/info_glibc.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/functions/info_glibc.sh b/functions/info_glibc.sh
index d311cc4d5..4181d011d 100644
--- a/functions/info_glibc.sh
+++ b/functions/info_glibc.sh
@@ -2,7 +2,7 @@
 # LGSM info_glibc.sh function
 # Author: Daniel Gibbs
 # Website: http://gameservermanagers.com
-lgsm_version="271215"
+lgsm_version="100116"
 
 # Description: stores details on servers Glibc requirements.
 
@@ -10,6 +10,8 @@ lgsm_version="271215"
 if [ "${gamename}" == "Blade Symphony" ]; then
 	glibcrequired="2.15"
 	glibcfix="yes"
+elif [ "${gamename}" == "BrainBread 2" ]; then
+	glibcrequired="2.17"
 elif [ "${gamename}" == "Double Action: Boogaloo" ]; then
 	glibcrequired="2.15"
 	glibcfix="yes"

From 9198dc1ba4975551cb3e1b9601be2690106c51ac Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Sat, 16 Jan 2016 08:16:53 +0000
Subject: [PATCH 30/54] added error for readelf not existing

---
 functions/command_dev_detect_deps.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/functions/command_dev_detect_deps.sh b/functions/command_dev_detect_deps.sh
index 30f89157d..f6d1da766 100644
--- a/functions/command_dev_detect_deps.sh
+++ b/functions/command_dev_detect_deps.sh
@@ -35,10 +35,12 @@ elif [ "${executable}" ==  "./ts3server_startscript.sh" ]; then
 	executable=ts3server_linux_amd64	
 fi
 
-if [ -n "$(command -v eu-readelf)" ]; then
+if [ "$(command -v eu-readelf)" ]; then
 	readelf=eu-readelf
-else
+elif [ "$(command -v readelf)" ];
 	readelf=readelf
+else
+	echo "readelf/eu-readelf not installed"	
 fi
 
 ${readelf} -d ${executable} |grep NEEDED|awk '{ print $5 }'|sed 's/\[//g'|sed 's/\]//g' > "${rootdir}/.depdetect_readelf"

From 43cbe0197081bbc7b0e0d8b44ca4c6475d14a7cb Mon Sep 17 00:00:00 2001
From: Phil <phil@philphonic.de>
Date: Sun, 17 Jan 2016 20:59:15 +0100
Subject: [PATCH 31/54] fix

fix for issue #629
---
 functions/fix_ins.sh | 1 -
 1 file changed, 1 deletion(-)

diff --git a/functions/fix_ins.sh b/functions/fix_ins.sh
index 0e9c77089..210c702ce 100644
--- a/functions/fix_ins.sh
+++ b/functions/fix_ins.sh
@@ -17,4 +17,3 @@ if [ "${function_selfname}" == "command_debug.sh" ]; then
 else
         defaultmap="\\\"${defaultmap}\\\""
 fi
-fn_parms

From 10dbf68f17897b25d00846f796aee162c9d5bc70 Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Sun, 17 Jan 2016 21:03:37 +0000
Subject: [PATCH 32/54] Initial code to detect missing deps

This code is still broken
---
 functions/check.sh          | 10 ++++++-
 functions/check_deps.sh     | 55 +++++++++++++++++++++++++++++++++++++
 functions/core_functions.sh |  7 ++++-
 3 files changed, 70 insertions(+), 2 deletions(-)
 create mode 100644 functions/check_deps.sh

diff --git a/functions/check.sh b/functions/check.sh
index 150a8e138..ca50777cc 100644
--- a/functions/check.sh
+++ b/functions/check.sh
@@ -2,7 +2,7 @@
 # LGSM fn_check function
 # Author: Daniel Gibbs
 # Website: http://gameservermanagers.com
-lgsm_version="060116"
+lgsm_version="170116"
 
 # Description: Overall function for managing checks.
 # Runs checks that will either halt on or fix an issue.
@@ -33,6 +33,14 @@ do
 	fi
 done
 
+local allowed_commands_array=( command_debug.sh command_start.sh command_stop.sh )
+for allowed_command in "${allowed_commands_array[@]}"
+do
+	if [ "${allowed_command}" == "${function_selfname}" ]; then
+		check_deps.sh
+	fi
+done
+
 local allowed_commands_array=( command_debug.sh command_details.sh command_monitor.sh command_start.sh command_stop.sh )
 for allowed_command in "${allowed_commands_array[@]}"
 do
diff --git a/functions/check_deps.sh b/functions/check_deps.sh
new file mode 100644
index 000000000..f438f7240
--- /dev/null
+++ b/functions/check_deps.sh
@@ -0,0 +1,55 @@
+#!/bin/bash
+# LGSM check_deps.sh function
+# Author: Daniel Gibbs
+# Website: http://gameservermanagers.com
+
+# Description: Checks that the require dependencies are installed for LGSM
+
+
+fn_deps_detector(){
+if [ -n "$(command -v dpkg-query)" ]; then
+	dpkg-query -W -f='${Status}' ${deptocheck} | grep -q -P '^install ok installed$';
+	depstatus=$?
+elif [ -n "$(command -v rpm)" ]; then
+	rpm -qa ${deptocheck} |grep -q -P ${deptocheck}
+	depstatus=$?	
+else
+	echo "Unknown OS"
+fi
+
+}
+
+cd "${executabledir}"
+if [ "${executable}" == "./hlds_run" ]; then
+	local depslist=( lib32gcc1 libstdc++6 libstdc++6:i386 )
+	for deptocheck in "${depstocheck[@]}"
+	do
+		fn_deps_detector
+	done
+	# gold source lib32gcc1 libstdc++6 libstdc++6:i386 
+elif [ "${executable}" ==  "./srcds_run" ]||[ "${executable}" ==  "./dabds.sh" ]||[ "${executable}" ==  "./srcds_run.sh" ]; then
+	local depslist=( lib32gcc1 libstdc++6 libstdc++6:i386 )
+	for deptocheck in "${depstocheck[@]}"
+	do
+		fn_deps_detector
+	done
+	# source lib32gcc1 libstdc++6 libstdc++6:i386 
+elif [ "${executable}" ==  "./server_linux32" ]; then
+	# lib32gcc1 libstdc++6 libstdc++6:i386 speex:i386 libtbb2
+elif [ "${executable}" ==  "./runSam3_DedicatedServer.sh" ]; then
+	# spark lib32gcc1 libstdc++6 libstdc++6:i386 
+elif [ "${executable}" ==  "./7DaysToDie.sh" ]; then
+	# lib32gcc1 libstdc++6 libstdc++6:i386 telnet expect
+elif [ "${executable}" ==  "./ucc-bin" ]; then
+        
+	if [ -f "${executabledir}/ucc-bin-real" ]; then
+		executable=ucc-bin-real
+	elif [ -f "${executabledir}/ut2004-bin" ]; then
+		executable=ut2004-bin
+	else
+		executable=ut-bin
+	fi
+
+elif [ "${executable}" ==  "./ts3server_startscript.sh" ]; then
+	executable=ts3server_linux_amd64	
+fi
\ No newline at end of file
diff --git a/functions/core_functions.sh b/functions/core_functions.sh
index 560a2ee26..7b0f148cd 100644
--- a/functions/core_functions.sh
+++ b/functions/core_functions.sh
@@ -2,7 +2,7 @@
 # LGSM core_functions.sh function
 # Author: Daniel Gibbs
 # Website: http://gameservermanagers.com
-lgsm_version="060116"
+lgsm_version="170116"
 
 # Description: Defines all functions to allow download and execution of functions using fn_runfunction.
 # This function is called first before any other function. Without this file other functions would not load.
@@ -111,6 +111,11 @@ functionfile="${FUNCNAME}"
 fn_runfunction
 }
 
+check_deps.sh(){
+functionfile="${FUNCNAME}"
+fn_runfunction
+}
+
 check_ip.sh(){
 functionfile="${FUNCNAME}"
 fn_runfunction

From 708448b02064bc2869978b94cb12b5ba4b365d73 Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Sat, 23 Jan 2016 07:51:57 +0000
Subject: [PATCH 33/54] added jc2server

---
 functions/check_deps.sh | 97 +++++++++++++++++++++++++----------------
 1 file changed, 60 insertions(+), 37 deletions(-)

diff --git a/functions/check_deps.sh b/functions/check_deps.sh
index f438f7240..a92f67bf4 100644
--- a/functions/check_deps.sh
+++ b/functions/check_deps.sh
@@ -2,54 +2,77 @@
 # LGSM check_deps.sh function
 # Author: Daniel Gibbs
 # Website: http://gameservermanagers.com
+lgsm_version="170116"
 
 # Description: Checks that the require dependencies are installed for LGSM
 
 
 fn_deps_detector(){
+# Checks is dependency is missing
 if [ -n "$(command -v dpkg-query)" ]; then
-	dpkg-query -W -f='${Status}' ${deptocheck} | grep -q -P '^install ok installed$';
+	dpkg-query -W -f='${Status}' ${deptocheck} | grep -q -P '^install ok installed$'
 	depstatus=$?
-elif [ -n "$(command -v rpm)" ]; then
-	rpm -qa ${deptocheck} |grep -q -P ${deptocheck}
-	depstatus=$?	
-else
-	echo "Unknown OS"
+	if [ "${depstatus}" == "0" ]; then
+		missingdep=0
+		echo -en " \e[0;32m${deptocheck}\e[0m"
+	else
+		# if missing dependency is flagged
+		missingdep=1
+		echo -en " \e[0;31m${deptocheck}\e[0m"
+	fi
+	sleep 0.5
+fi
+
+# Add missing dependencies are added to array_deps_missing array
+if [ "${missingdep}" == "1" ]; then
+	array_deps_missing+=("${deptocheck}")
 fi
+}
 
+fn_deps_email(){
+# Adds postfix to required dependencies if email notification is enabled
+if [ "${emailnotification}" == "on" ]; then
+	array_deps_required+=("mailutils postfix")
+fi
 }
 
+
 cd "${executabledir}"
-if [ "${executable}" == "./hlds_run" ]; then
-	local depslist=( lib32gcc1 libstdc++6 libstdc++6:i386 )
-	for deptocheck in "${depstocheck[@]}"
-	do
-		fn_deps_detector
-	done
-	# gold source lib32gcc1 libstdc++6 libstdc++6:i386 
-elif [ "${executable}" ==  "./srcds_run" ]||[ "${executable}" ==  "./dabds.sh" ]||[ "${executable}" ==  "./srcds_run.sh" ]; then
-	local depslist=( lib32gcc1 libstdc++6 libstdc++6:i386 )
-	for deptocheck in "${depstocheck[@]}"
-	do
-		fn_deps_detector
-	done
-	# source lib32gcc1 libstdc++6 libstdc++6:i386 
-elif [ "${executable}" ==  "./server_linux32" ]; then
-	# lib32gcc1 libstdc++6 libstdc++6:i386 speex:i386 libtbb2
-elif [ "${executable}" ==  "./runSam3_DedicatedServer.sh" ]; then
-	# spark lib32gcc1 libstdc++6 libstdc++6:i386 
-elif [ "${executable}" ==  "./7DaysToDie.sh" ]; then
-	# lib32gcc1 libstdc++6 libstdc++6:i386 telnet expect
-elif [ "${executable}" ==  "./ucc-bin" ]; then
-        
-	if [ -f "${executabledir}/ucc-bin-real" ]; then
-		executable=ucc-bin-real
-	elif [ -f "${executabledir}/ut2004-bin" ]; then
-		executable=ut2004-bin
-	else
-		executable=ut-bin
-	fi
+# Generate array of missing deps
+array_deps_missing=()
+fn_printdots "Checking for missing dependencies:"
+if [ "${executable}" ==  "./srcds_run" ]||[ "${executable}" ==  "./dabds.sh" ]||[ "${executable}" ==  "./srcds_run.sh" ]||[ "${executable}" ==  "./Jcmp-Server" ] ; then
+	local array_deps_required=( tmux curl lib32gcc1 libstdc++6:i386 )
+	fn_deps_email
+elif 	
+else
+	fn_printfail "Unknown executable"
+	exit	
+fi
 
-elif [ "${executable}" ==  "./ts3server_startscript.sh" ]; then
-	executable=ts3server_linux_amd64	
+# Loop though required depenencies
+for deptocheck in "${array_deps_required[@]}"
+do
+	fn_deps_detector
+done
+
+if [ "${#array_deps_missing[@]}" != "0" ]; then
+	fn_printwarnnl "Dependency Missing: \e[0;31m${array_deps_missing[@]}\e[0m"
+	sleep 2
+	sudo -n true
+	if [ $? -eq 0 ]; then
+		fn_printinfonl "Attempting to install missing dependencies automatically"
+		echo -en ".\r"
+		sleep 1
+		echo -en "..\r"
+		sleep 1
+		echo -en "...\r"
+		sleep 1
+		echo -en "   \r"	
+		sudo apt-get install ${array_deps_missing[@]}
+	else
+		echo "sudo apt-get install ${array_deps_missing[@]}"
+	fi 
+else
+	fn_printoknl "Checking for missing dependencies"
 fi
\ No newline at end of file

From 9da2c79acf852c21045b1d2371052ac83aa710d1 Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Sat, 23 Jan 2016 07:52:44 +0000
Subject: [PATCH 34/54] removed elif

---
 functions/check_deps.sh | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/functions/check_deps.sh b/functions/check_deps.sh
index a92f67bf4..da297dc26 100644
--- a/functions/check_deps.sh
+++ b/functions/check_deps.sh
@@ -43,8 +43,7 @@ array_deps_missing=()
 fn_printdots "Checking for missing dependencies:"
 if [ "${executable}" ==  "./srcds_run" ]||[ "${executable}" ==  "./dabds.sh" ]||[ "${executable}" ==  "./srcds_run.sh" ]||[ "${executable}" ==  "./Jcmp-Server" ] ; then
 	local array_deps_required=( tmux curl lib32gcc1 libstdc++6:i386 )
-	fn_deps_email
-elif 	
+	fn_deps_email 	
 else
 	fn_printfail "Unknown executable"
 	exit	

From aaab05c2a6d0bc99a620e363951ef666881ac82d Mon Sep 17 00:00:00 2001
From: Phil <phil@philphonic.de>
Date: Sat, 23 Jan 2016 16:21:45 +0100
Subject: [PATCH 35/54] inssserver workshop support

steam workshop is working with insurgency on linux now
---
 Insurgency/insserver | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Insurgency/insserver b/Insurgency/insserver
index e43d5e752..66e511149 100644
--- a/Insurgency/insserver
+++ b/Insurgency/insserver
@@ -31,10 +31,11 @@ sourcetvport="27020"
 clientport="27005"
 ip="0.0.0.0"
 updateonstart="off"
+workshop="0"
 
 # https://developer.valvesoftware.com/wiki/Command_Line_Options#Source_Dedicated_Server
 fn_parms(){
-parms="-game insurgency -strictportbind -ip ${ip} -port ${port} +clientport ${clientport} +tv_port ${sourcetvport} -tickrate ${tickrate} +map ${defaultmap} +servercfgfile ${servercfg} -maxplayers ${maxplayers}"
+parms="-game insurgency -strictportbind -ip ${ip} -port ${port} +clientport ${clientport} +tv_port ${sourcetvport} -tickrate ${tickrate} +map ${defaultmap} +servercfgfile ${servercfg} -maxplayers ${maxplayers} +sv_workshop_enabled ${workshop}"
 }
 
 #### Advanced Variables ####

From bf3fda25b03c266488980a50b349403b139ab64b Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Sun, 31 Jan 2016 20:07:30 +0000
Subject: [PATCH 36/54] Altered script log messages slightly

---
 functions/check_deps.sh       | 106 ++++++++++++++++++++++++----------
 functions/fn_update_functions |   6 +-
 functions/update_check.sh     |   1 -
 functions/update_functions.sh |   6 +-
 4 files changed, 82 insertions(+), 37 deletions(-)

diff --git a/functions/check_deps.sh b/functions/check_deps.sh
index da297dc26..b279dc026 100644
--- a/functions/check_deps.sh
+++ b/functions/check_deps.sh
@@ -2,7 +2,7 @@
 # LGSM check_deps.sh function
 # Author: Daniel Gibbs
 # Website: http://gameservermanagers.com
-lgsm_version="170116"
+lgsm_version="310116"
 
 # Description: Checks that the require dependencies are installed for LGSM
 
@@ -10,17 +10,14 @@ lgsm_version="170116"
 fn_deps_detector(){
 # Checks is dependency is missing
 if [ -n "$(command -v dpkg-query)" ]; then
-	dpkg-query -W -f='${Status}' ${deptocheck} | grep -q -P '^install ok installed$'
+	dpkg-query -W -f='${Status}' ${deptocheck} 2>/dev/null| grep -q -P '^install ok installed$'
 	depstatus=$?
 	if [ "${depstatus}" == "0" ]; then
 		missingdep=0
-		echo -en " \e[0;32m${deptocheck}\e[0m"
 	else
 		# if missing dependency is flagged
 		missingdep=1
-		echo -en " \e[0;31m${deptocheck}\e[0m"
 	fi
-	sleep 0.5
 fi
 
 # Add missing dependencies are added to array_deps_missing array
@@ -32,33 +29,18 @@ fi
 fn_deps_email(){
 # Adds postfix to required dependencies if email notification is enabled
 if [ "${emailnotification}" == "on" ]; then
-	array_deps_required+=("mailutils postfix")
+	array_deps_required+=( mailutils postfix )
 fi
 }
 
-
-cd "${executabledir}"
-# Generate array of missing deps
-array_deps_missing=()
-fn_printdots "Checking for missing dependencies:"
-if [ "${executable}" ==  "./srcds_run" ]||[ "${executable}" ==  "./dabds.sh" ]||[ "${executable}" ==  "./srcds_run.sh" ]||[ "${executable}" ==  "./Jcmp-Server" ] ; then
-	local array_deps_required=( tmux curl lib32gcc1 libstdc++6:i386 )
-	fn_deps_email 	
-else
-	fn_printfail "Unknown executable"
-	exit	
-fi
-
-# Loop though required depenencies
-for deptocheck in "${array_deps_required[@]}"
-do
-	fn_deps_detector
-done
-
+fn_found_missing_deps(){
 if [ "${#array_deps_missing[@]}" != "0" ]; then
-	fn_printwarnnl "Dependency Missing: \e[0;31m${array_deps_missing[@]}\e[0m"
+	fn_printdots "Checking dependencies"
 	sleep 2
-	sudo -n true
+	fn_printwarn "Checking dependencies: Dependency missing: \e[0;31m${array_deps_missing[@]}\e[0m"
+	sleep 1
+	echo -e ""
+	sudo -n true > /dev/null 2>&1
 	if [ $? -eq 0 ]; then
 		fn_printinfonl "Attempting to install missing dependencies automatically"
 		echo -en ".\r"
@@ -69,9 +51,73 @@ if [ "${#array_deps_missing[@]}" != "0" ]; then
 		sleep 1
 		echo -en "   \r"	
 		sudo apt-get install ${array_deps_missing[@]}
+		exit 1
 	else
+		echo ""
+		fn_printinfomationnl "$(whoami) does not have sudo access. manually install dependencies"
+		echo ""
 		echo "sudo apt-get install ${array_deps_missing[@]}"
-	fi 
-else
-	fn_printoknl "Checking for missing dependencies"
+		echo ""
+		exit 1
+	fi
+fi	
+}
+
+
+
+# Check will only run if using apt-get or yum
+if [ -n "$(command -v dpkg-query)" ]; then
+	# Generate array of missing deps
+	array_deps_missing=()
+	fn_printdots "Checking dependencies"
+
+	# LGSM requirement for curl
+	local array_deps_required=( curl )
+
+	# All servers except ts3 require tmux
+	if [ "${executable}" != "./ts3server_startscript.sh" ]; then
+		local array_deps_required+=( tmux )
+	fi
+
+	# All servers excelts ts3 & mumble require libstdc++6,lib32gcc1
+	if [ "${executable}" != "./ts3server_startscript.sh" ]||[ "${executable}" != "./murmur.x86" ]; then
+		local array_deps_required+=( lib32gcc1 libstdc++6:i386 )
+	fi
+
+# Game Specific requirements
+
+	# Spark
+	if [ "${engine}" ==  "spark" ]; then
+		local array_deps_required+=( speex:i386 libtbb2 )
+	# 7 Days to Die	
+	elif [ "${executable}" ==  "./7DaysToDie.sh" ]; then
+		local array_deps_required+=( telnet expect )
+	# Brainbread 2 and Don't Starve Together
+	elif [ "${gamename}" == "Brainbread 2" ]||[ "${gamename}" == "Don't Starve Together" ]; then
+		local array_deps_required+=( libcurl4-gnutls-dev:i386 )
+	if [ "${engine}" ==  "projectzomboid" ]; then
+		local array_deps_required+=( openjdk-7-jre )
+	# Unreal engine
+	elif [ "${executable}" ==  "./ucc-bin" ]; then
+		#UT2K4
+		if [ -f "${executabledir}/ut2004-bin" ]; then
+			local array_deps_required+=( libsdl1.2debian libstdc++5:i386 bzip2 unzip )
+		#UT99
+		else
+			local array_deps_required+=( libsdl1.2debian bzip2 )
+		fi
+	else
+		fn_printfail "Unknown executable"
+		exit	
+	fi
+	fn_deps_email
+
+	# Loop though required depenencies
+	for deptocheck in "${array_deps_required[@]}"
+	do
+		fn_deps_detector
+	done
+
+	# user to be informaed of any missing dependecies 
+	fn_found_missing_deps
 fi
\ No newline at end of file
diff --git a/functions/fn_update_functions b/functions/fn_update_functions
index 185f44f5e..2de9afd6d 100644
--- a/functions/fn_update_functions
+++ b/functions/fn_update_functions
@@ -2,7 +2,7 @@
 # LGSM update_functions.sh function
 # Author: Daniel Gibbs
 # Website: http://gameservermanagers.com
-lgsm_version="271215"
+lgsm_version="230116"
 
 # Description: LEGACY FUNCTION Deletes the functions dir to allow re-downloading of functions from GitHub.
 
@@ -14,9 +14,9 @@ rm -rfv "${rootdir}/functions/"*
 exitcode=$?
 if [ "${exitcode}" == "0" ]; then
 	fn_printok "Updating functions"
-	fn_scriptlog "Successfull! Updating functions"
+	fn_scriptlog "Success! Updating functions"
 else
-	fn_printokfail "Updating functions"
+	fn_printfail "Updating functions"
 	fn_scriptlog "Failure! Updating functions"
 fi
 echo -ne "\n"
\ No newline at end of file
diff --git a/functions/update_check.sh b/functions/update_check.sh
index e0ba3ea96..38e786544 100644
--- a/functions/update_check.sh
+++ b/functions/update_check.sh
@@ -188,7 +188,6 @@ sleep 1
 # Checks currentbuild info is available, if fails a server restart will be forced to generate logs
 if [ -z "$(find ./* -name 'ts3server*_0.log')" ]; then
 	fn_printfail "Checking for update: teamspeak.com"
-	fn_scriptlog "Checking for update: teamspeak.com"
 	sleep 1
 	fn_printfailnl "Checking for update: teamspeak.com: No logs with server version found"
 	fn_scriptlog "Failure! Checking for update: teamspeak.com: No logs with server version found"
diff --git a/functions/update_functions.sh b/functions/update_functions.sh
index 350714ed0..196b90f75 100644
--- a/functions/update_functions.sh
+++ b/functions/update_functions.sh
@@ -2,7 +2,7 @@
 # LGSM update_functions.sh function
 # Author: Daniel Gibbs
 # Website: http://gameservermanagers.com
-lgsm_version="271215"
+lgsm_version="230116"
 
 # Description: Deletes the functions dir to allow re-downloading of functions from GitHub.
 
@@ -16,9 +16,9 @@ rm -rfv "${rootdir}/functions/"*
 exitcode=$?
 if [ "${exitcode}" == "0" ]; then
 	fn_printok "Updating functions"
-	fn_scriptlog "Successfull! Updating functions"
+	fn_scriptlog "Success! Updating functions"
 else
-	fn_printokfail "Updating functions"
+	fn_printfail "Updating functions"
 	fn_scriptlog "Failure! Updating functions"
 fi
 echo -ne "\n"
\ No newline at end of file

From 70a5b460d8c3f69c517b348819f216a4fbb82588 Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Sun, 31 Jan 2016 20:14:23 +0000
Subject: [PATCH 37/54] removed local

---
 functions/check_deps.sh | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/functions/check_deps.sh b/functions/check_deps.sh
index b279dc026..fabdf81b5 100644
--- a/functions/check_deps.sh
+++ b/functions/check_deps.sh
@@ -72,39 +72,39 @@ if [ -n "$(command -v dpkg-query)" ]; then
 	fn_printdots "Checking dependencies"
 
 	# LGSM requirement for curl
-	local array_deps_required=( curl )
+	array_deps_required=( curl )
 
 	# All servers except ts3 require tmux
 	if [ "${executable}" != "./ts3server_startscript.sh" ]; then
-		local array_deps_required+=( tmux )
+		array_deps_required+=( tmux )
 	fi
 
 	# All servers excelts ts3 & mumble require libstdc++6,lib32gcc1
 	if [ "${executable}" != "./ts3server_startscript.sh" ]||[ "${executable}" != "./murmur.x86" ]; then
-		local array_deps_required+=( lib32gcc1 libstdc++6:i386 )
+		array_deps_required+=( lib32gcc1 libstdc++6:i386 )
 	fi
 
 # Game Specific requirements
 
 	# Spark
 	if [ "${engine}" ==  "spark" ]; then
-		local array_deps_required+=( speex:i386 libtbb2 )
+		array_deps_required+=( speex:i386 libtbb2 )
 	# 7 Days to Die	
 	elif [ "${executable}" ==  "./7DaysToDie.sh" ]; then
-		local array_deps_required+=( telnet expect )
+		array_deps_required+=( telnet expect )
 	# Brainbread 2 and Don't Starve Together
 	elif [ "${gamename}" == "Brainbread 2" ]||[ "${gamename}" == "Don't Starve Together" ]; then
-		local array_deps_required+=( libcurl4-gnutls-dev:i386 )
-	if [ "${engine}" ==  "projectzomboid" ]; then
-		local array_deps_required+=( openjdk-7-jre )
+		array_deps_required+=( libcurl4-gnutls-dev:i386 )
+	elif [ "${engine}" ==  "projectzomboid" ]; then
+		array_deps_required+=( openjdk-7-jre )
 	# Unreal engine
 	elif [ "${executable}" ==  "./ucc-bin" ]; then
 		#UT2K4
 		if [ -f "${executabledir}/ut2004-bin" ]; then
-			local array_deps_required+=( libsdl1.2debian libstdc++5:i386 bzip2 unzip )
+			array_deps_required+=( libsdl1.2debian libstdc++5:i386 bzip2 unzip )
 		#UT99
 		else
-			local array_deps_required+=( libsdl1.2debian bzip2 )
+			array_deps_required+=( libsdl1.2debian bzip2 )
 		fi
 	else
 		fn_printfail "Unknown executable"

From 1e0c80fb1804f4997c789cbf3e286c02ff99ba6c Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Sun, 31 Jan 2016 20:20:03 +0000
Subject: [PATCH 38/54] Removed unknown exec if

---
 functions/check_deps.sh | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/functions/check_deps.sh b/functions/check_deps.sh
index fabdf81b5..6a48f7214 100644
--- a/functions/check_deps.sh
+++ b/functions/check_deps.sh
@@ -105,10 +105,7 @@ if [ -n "$(command -v dpkg-query)" ]; then
 		#UT99
 		else
 			array_deps_required+=( libsdl1.2debian bzip2 )
-		fi
-	else
-		fn_printfail "Unknown executable"
-		exit	
+		fi	
 	fi
 	fn_deps_email
 

From fa5dfc64b310d2275c47a128ec659fd220ab6336 Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Sun, 31 Jan 2016 21:35:45 +0000
Subject: [PATCH 39/54] Added CentOS Support

---
 functions/check_deps.sh | 93 ++++++++++++++++++++++++++++++++++-------
 1 file changed, 79 insertions(+), 14 deletions(-)

diff --git a/functions/check_deps.sh b/functions/check_deps.sh
index 6a48f7214..0e21baef8 100644
--- a/functions/check_deps.sh
+++ b/functions/check_deps.sh
@@ -12,6 +12,10 @@ fn_deps_detector(){
 if [ -n "$(command -v dpkg-query)" ]; then
 	dpkg-query -W -f='${Status}' ${deptocheck} 2>/dev/null| grep -q -P '^install ok installed$'
 	depstatus=$?
+elif [ -n "$(command -v yum)" ]; then
+	yum -q list installed ${deptocheck} 2>/dev/null
+	depstatus=$?
+fi	
 	if [ "${depstatus}" == "0" ]; then
 		missingdep=0
 	else
@@ -29,7 +33,11 @@ fi
 fn_deps_email(){
 # Adds postfix to required dependencies if email notification is enabled
 if [ "${emailnotification}" == "on" ]; then
-	array_deps_required+=( mailutils postfix )
+	if [ -n "$(command -v dpkg-query)" ]; then
+		array_deps_required+=( mailutils postfix )
+	elif [ -n "$(command -v yum)" ]; then
+		array_deps_required+=( mailx postfix )
+	fi	
 fi
 }
 
@@ -50,20 +58,35 @@ if [ "${#array_deps_missing[@]}" != "0" ]; then
 		echo -en "...\r"
 		sleep 1
 		echo -en "   \r"	
-		sudo apt-get install ${array_deps_missing[@]}
-		exit 1
+		if [ -n "$(command -v dpkg-query)" ]; then
+			echo "sudo apt-get install ${array_deps_missing[@]}"
+		elif [ -n "$(command -v yum)" ]; then
+			echo "yum install ${array_deps_missing[@]}"
+		fi	
 	else
 		echo ""
 		fn_printinfomationnl "$(whoami) does not have sudo access. manually install dependencies"
 		echo ""
-		echo "sudo apt-get install ${array_deps_missing[@]}"
+		if [ -n "$(command -v dpkg-query)" ]; then
+			echo "sudo apt-get install ${array_deps_missing[@]}"
+		elif [ -n "$(command -v yum)" ]; then
+			echo "yum install ${array_deps_missing[@]}"
+		fi	
 		echo ""
-		exit 1
 	fi
 fi	
 }
 
+fn_check_loop(){
+	# Loop though required depenencies
+	for deptocheck in "${array_deps_required[@]}"
+	do
+		fn_deps_detector
+	done
 
+	# user to be informaed of any missing dependecies 
+	fn_found_missing_deps
+}
 
 # Check will only run if using apt-get or yum
 if [ -n "$(command -v dpkg-query)" ]; then
@@ -72,7 +95,7 @@ if [ -n "$(command -v dpkg-query)" ]; then
 	fn_printdots "Checking dependencies"
 
 	# LGSM requirement for curl
-	array_deps_required=( curl )
+	array_deps_required=( curl ca-certificates )
 
 	# All servers except ts3 require tmux
 	if [ "${executable}" != "./ts3server_startscript.sh" ]; then
@@ -84,7 +107,7 @@ if [ -n "$(command -v dpkg-query)" ]; then
 		array_deps_required+=( lib32gcc1 libstdc++6:i386 )
 	fi
 
-# Game Specific requirements
+	# Game Specific requirements
 
 	# Spark
 	if [ "${engine}" ==  "spark" ]; then
@@ -92,6 +115,9 @@ if [ -n "$(command -v dpkg-query)" ]; then
 	# 7 Days to Die	
 	elif [ "${executable}" ==  "./7DaysToDie.sh" ]; then
 		array_deps_required+=( telnet expect )
+	# No More Room in Hell	
+	elif [ "${gamename}" == "No More Room in Hell" ]
+		array_deps_required+=( lib32tinfo5 )
 	# Brainbread 2 and Don't Starve Together
 	elif [ "${gamename}" == "Brainbread 2" ]||[ "${gamename}" == "Don't Starve Together" ]; then
 		array_deps_required+=( libcurl4-gnutls-dev:i386 )
@@ -108,13 +134,52 @@ if [ -n "$(command -v dpkg-query)" ]; then
 		fi	
 	fi
 	fn_deps_email
+	fn_check_loop
 
-	# Loop though required depenencies
-	for deptocheck in "${array_deps_required[@]}"
-	do
-		fn_deps_detector
-	done
+elif [ -n "$(command -v yum)" ]; then
+	# Generate array of missing deps
+	array_deps_missing=()
+	fn_printdots "Checking dependencies"
 
-	# user to be informaed of any missing dependecies 
-	fn_found_missing_deps
+	# LGSM requirement for curl
+	array_deps_required=( curl )
+
+	# All servers except ts3 require tmux
+	if [ "${executable}" != "./ts3server_startscript.sh" ]; then
+		array_deps_required+=( tmux )
+	fi
+
+	# All servers excelts ts3 & mumble require libstdc++6,lib32gcc1
+	if [ "${executable}" != "./ts3server_startscript.sh" ]||[ "${executable}" != "./murmur.x86" ]; then
+		array_deps_required+=( glibc.i686 libstdc++.i686 )
+	fi
+
+	# Game Specific requirements
+
+	# Spark
+	if [ "${engine}" ==  "spark" ]; then
+		array_deps_required+=( speex.i686 tbb.i686 )
+	# 7 Days to Die	
+	elif [ "${executable}" ==  "./7DaysToDie.sh" ]; then
+		array_deps_required+=( telnet expect )
+	# No More Room in Hell	
+	elif [ "${gamename}" == "No More Room in Hell" ]
+		array_deps_required+=( ncurses-libs.i686 )
+	# Brainbread 2 and Don't Starve Together
+	elif [ "${gamename}" == "Brainbread 2" ]||[ "${gamename}" == "Don't Starve Together" ]; then
+		array_deps_required+=( libcurl.i686 )
+	elif [ "${engine}" ==  "projectzomboid" ]; then
+		array_deps_required+=( java-1.7.0-openjdk )
+	# Unreal engine
+	elif [ "${executable}" ==  "./ucc-bin" ]; then
+		#UT2K4
+		if [ -f "${executabledir}/ut2004-bin" ]; then
+			array_deps_required+=( compat-libstdc++-33.i686 SDL.i686 bzip2 unzip )
+		#UT99
+		else
+			array_deps_required+=( SDL.i686 bzip2 )
+		fi	
+	fi
+	fn_deps_email
+	fn_check_loop
 fi
\ No newline at end of file

From 94af491dfe43011136b8e5ef06feded04842f722 Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Sun, 31 Jan 2016 21:53:43 +0000
Subject: [PATCH 40/54] removed stray fi

---
 functions/check_deps.sh | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/functions/check_deps.sh b/functions/check_deps.sh
index 0e21baef8..94899b20b 100644
--- a/functions/check_deps.sh
+++ b/functions/check_deps.sh
@@ -16,12 +16,11 @@ elif [ -n "$(command -v yum)" ]; then
 	yum -q list installed ${deptocheck} 2>/dev/null
 	depstatus=$?
 fi	
-	if [ "${depstatus}" == "0" ]; then
-		missingdep=0
-	else
-		# if missing dependency is flagged
-		missingdep=1
-	fi
+if [ "${depstatus}" == "0" ]; then
+	missingdep=0
+else
+	# if missing dependency is flagged
+	missingdep=1
 fi
 
 # Add missing dependencies are added to array_deps_missing array

From 288072bc866c6836e922158b07adda635d9612b8 Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Sun, 31 Jan 2016 22:04:51 +0000
Subject: [PATCH 41/54] added missing then

---
 functions/check_deps.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/functions/check_deps.sh b/functions/check_deps.sh
index 94899b20b..07f67d719 100644
--- a/functions/check_deps.sh
+++ b/functions/check_deps.sh
@@ -115,7 +115,7 @@ if [ -n "$(command -v dpkg-query)" ]; then
 	elif [ "${executable}" ==  "./7DaysToDie.sh" ]; then
 		array_deps_required+=( telnet expect )
 	# No More Room in Hell	
-	elif [ "${gamename}" == "No More Room in Hell" ]
+	elif [ "${gamename}" == "No More Room in Hell" ]; then
 		array_deps_required+=( lib32tinfo5 )
 	# Brainbread 2 and Don't Starve Together
 	elif [ "${gamename}" == "Brainbread 2" ]||[ "${gamename}" == "Don't Starve Together" ]; then
@@ -162,7 +162,7 @@ elif [ -n "$(command -v yum)" ]; then
 	elif [ "${executable}" ==  "./7DaysToDie.sh" ]; then
 		array_deps_required+=( telnet expect )
 	# No More Room in Hell	
-	elif [ "${gamename}" == "No More Room in Hell" ]
+	elif [ "${gamename}" == "No More Room in Hell" ]; then
 		array_deps_required+=( ncurses-libs.i686 )
 	# Brainbread 2 and Don't Starve Together
 	elif [ "${gamename}" == "Brainbread 2" ]||[ "${gamename}" == "Don't Starve Together" ]; then

From f77bfa5b1b623f26eedf0d3cb1710fa0579bfb6d Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Sun, 31 Jan 2016 22:13:17 +0000
Subject: [PATCH 42/54] dev/null

---
 functions/check_deps.sh | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/functions/check_deps.sh b/functions/check_deps.sh
index 07f67d719..14b1d71c3 100644
--- a/functions/check_deps.sh
+++ b/functions/check_deps.sh
@@ -13,7 +13,7 @@ if [ -n "$(command -v dpkg-query)" ]; then
 	dpkg-query -W -f='${Status}' ${deptocheck} 2>/dev/null| grep -q -P '^install ok installed$'
 	depstatus=$?
 elif [ -n "$(command -v yum)" ]; then
-	yum -q list installed ${deptocheck} 2>/dev/null
+	yum -q list installed ${deptocheck} > /dev/null 2>&1
 	depstatus=$?
 fi	
 if [ "${depstatus}" == "0" ]; then
@@ -91,7 +91,6 @@ fn_check_loop(){
 if [ -n "$(command -v dpkg-query)" ]; then
 	# Generate array of missing deps
 	array_deps_missing=()
-	fn_printdots "Checking dependencies"
 
 	# LGSM requirement for curl
 	array_deps_required=( curl ca-certificates )
@@ -138,7 +137,6 @@ if [ -n "$(command -v dpkg-query)" ]; then
 elif [ -n "$(command -v yum)" ]; then
 	# Generate array of missing deps
 	array_deps_missing=()
-	fn_printdots "Checking dependencies"
 
 	# LGSM requirement for curl
 	array_deps_required=( curl )

From 6af31e04375bb93229f5ff61e6ba1d9aec1f3425 Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Sun, 31 Jan 2016 22:16:32 +0000
Subject: [PATCH 43/54] added add arch

---
 functions/check_deps.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/functions/check_deps.sh b/functions/check_deps.sh
index 14b1d71c3..11a76d54b 100644
--- a/functions/check_deps.sh
+++ b/functions/check_deps.sh
@@ -58,7 +58,7 @@ if [ "${#array_deps_missing[@]}" != "0" ]; then
 		sleep 1
 		echo -en "   \r"	
 		if [ -n "$(command -v dpkg-query)" ]; then
-			echo "sudo apt-get install ${array_deps_missing[@]}"
+			echo "sudo dpkg --add-architecture i386; sudo apt-get install ${array_deps_missing[@]}"
 		elif [ -n "$(command -v yum)" ]; then
 			echo "yum install ${array_deps_missing[@]}"
 		fi	
@@ -67,7 +67,7 @@ if [ "${#array_deps_missing[@]}" != "0" ]; then
 		fn_printinfomationnl "$(whoami) does not have sudo access. manually install dependencies"
 		echo ""
 		if [ -n "$(command -v dpkg-query)" ]; then
-			echo "sudo apt-get install ${array_deps_missing[@]}"
+			echo "sudo dpkg --add-architecture i386; sudo apt-get install ${array_deps_missing[@]}"
 		elif [ -n "$(command -v yum)" ]; then
 			echo "yum install ${array_deps_missing[@]}"
 		fi	

From e561a86acdce50ff1758feaf3cfdafe1800ca15a Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Sun, 31 Jan 2016 22:46:06 +0000
Subject: [PATCH 44/54] Added to installer

---
 functions/check_deps.sh      | 14 ++++++++++----
 functions/command_install.sh |  2 +-
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/functions/check_deps.sh b/functions/check_deps.sh
index 11a76d54b..d14d813bb 100644
--- a/functions/check_deps.sh
+++ b/functions/check_deps.sh
@@ -4,11 +4,11 @@
 # Website: http://gameservermanagers.com
 lgsm_version="310116"
 
-# Description: Checks that the require dependencies are installed for LGSM
+# Description: Checks that the requires dependencies are installed for LGSM.
 
 
 fn_deps_detector(){
-# Checks is dependency is missing
+# Checks if dependency is missing
 if [ -n "$(command -v dpkg-query)" ]; then
 	dpkg-query -W -f='${Status}' ${deptocheck} 2>/dev/null| grep -q -P '^install ok installed$'
 	depstatus=$?
@@ -19,11 +19,11 @@ fi
 if [ "${depstatus}" == "0" ]; then
 	missingdep=0
 else
-	# if missing dependency is flagged
+	# if missing dependency is found
 	missingdep=1
 fi
 
-# Add missing dependencies are added to array_deps_missing array
+# Missing dependencies are added to array_deps_missing
 if [ "${missingdep}" == "1" ]; then
 	array_deps_missing+=("${deptocheck}")
 fi
@@ -87,6 +87,12 @@ fn_check_loop(){
 	fn_found_missing_deps
 }
 
+if [ "${function_selfname}" == "command_install.sh" ]; then
+echo "Server Directory"
+echo "================================="
+fi
+
+
 # Check will only run if using apt-get or yum
 if [ -n "$(command -v dpkg-query)" ]; then
 	# Generate array of missing deps
diff --git a/functions/command_install.sh b/functions/command_install.sh
index f2021f071..791cb160d 100644
--- a/functions/command_install.sh
+++ b/functions/command_install.sh
@@ -9,7 +9,7 @@ function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 check.sh
 install_header.sh
 install_serverdir.sh
-
+check_deps.sh 
 # Download and install
 if [ "${gamename}" == "Unreal Tournament 2004" ]; then
 	install_dl_ut2k4.sh

From 5906e07c01001e5674610d43d58f2f7edcf53150 Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Sun, 31 Jan 2016 22:47:35 +0000
Subject: [PATCH 45/54] Added installer mode

---
 functions/check_deps.sh | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/functions/check_deps.sh b/functions/check_deps.sh
index d14d813bb..2224ea2f4 100644
--- a/functions/check_deps.sh
+++ b/functions/check_deps.sh
@@ -18,9 +18,13 @@ elif [ -n "$(command -v yum)" ]; then
 fi	
 if [ "${depstatus}" == "0" ]; then
 	missingdep=0
+	echo -e "\e[0;32m${deptocheck}\e[0m"
+	sleep 0.5
 else
 	# if missing dependency is found
 	missingdep=1
+	echo -e "\e[0;31m${deptocheck}\e[0m"
+	sleep 0.5
 fi
 
 # Missing dependencies are added to array_deps_missing
@@ -88,8 +92,9 @@ fn_check_loop(){
 }
 
 if [ "${function_selfname}" == "command_install.sh" ]; then
-echo "Server Directory"
-echo "================================="
+	echo ""
+	echo "Checking Dependecies"
+	echo "================================="
 fi
 
 

From a3c917d3b77115a5f723c87856d4a67ec9e3c06a Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Sun, 31 Jan 2016 22:48:13 +0000
Subject: [PATCH 46/54] added if

---
 functions/check_deps.sh | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/functions/check_deps.sh b/functions/check_deps.sh
index 2224ea2f4..cf685d3a1 100644
--- a/functions/check_deps.sh
+++ b/functions/check_deps.sh
@@ -18,13 +18,17 @@ elif [ -n "$(command -v yum)" ]; then
 fi	
 if [ "${depstatus}" == "0" ]; then
 	missingdep=0
-	echo -e "\e[0;32m${deptocheck}\e[0m"
-	sleep 0.5
+	if [ "${function_selfname}" == "command_install.sh" ]; then
+		echo -e "\e[0;32m${deptocheck}\e[0m"
+		sleep 0.5
+	fi
 else
 	# if missing dependency is found
 	missingdep=1
-	echo -e "\e[0;31m${deptocheck}\e[0m"
-	sleep 0.5
+	if [ "${function_selfname}" == "command_install.sh" ]; then
+		echo -e "\e[0;31m${deptocheck}\e[0m"
+		sleep 0.5
+	fi	
 fi
 
 # Missing dependencies are added to array_deps_missing

From 26ca719fa456779063dec194f56934364c0fc085 Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Mon, 1 Feb 2016 20:48:19 +0000
Subject: [PATCH 47/54] Add sleep for installer

---
 functions/check_deps.sh | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/functions/check_deps.sh b/functions/check_deps.sh
index cf685d3a1..1e2e99fee 100644
--- a/functions/check_deps.sh
+++ b/functions/check_deps.sh
@@ -81,6 +81,9 @@ if [ "${#array_deps_missing[@]}" != "0" ]; then
 		fi	
 		echo ""
 	fi
+	if [ "${function_selfname}" == "command_install.sh" ]; then
+		sleep 5
+	fi
 fi	
 }
 

From 6f7bd74c8b07057e0f792e20c0293514386f269a Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Mon, 1 Feb 2016 22:54:59 +0000
Subject: [PATCH 48/54] Added fixes to email notification

Further improvements to come.
---
 functions/email.sh | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/functions/email.sh b/functions/email.sh
index ba5d47717..05ad05bbf 100644
--- a/functions/email.sh
+++ b/functions/email.sh
@@ -2,41 +2,41 @@
 # LGSM email.sh function
 # Author: Daniel Gibbs
 # Website: http://gameservermanagers.com
-lgsm_version="271215"
+lgsm_version="010216"
 
 # Description: Sends email notification if monitor picks up a failure.
 
 local modulename="Email"
 fn_printdots "Sending notification to ${email}"
-echo -en "\n"
 info_distro.sh
 {
-	echo -e "========================================\n${servicename} details\n========================================\n"
+	echo -e "========================================\n${servicename} details\n========================================"
 	echo -e "Service: ${servicename}"
 	echo -e "Server: ${servername}"
 	echo -e "Game: ${gamename}"
 	echo -e "Failure reason: ${failurereason}"
 	echo -e "Action Taken: ${actiontaken}\n"
-	echo -e "========================================\nServer details\n========================================\n"
+	echo -e "========================================\nServer details\n========================================"
 	echo -e "Date: $(date)"
 	echo -e "Distro: ${os}"
 	echo -e "Arch: ${arch}"
 	echo -e "Kernel: ${kernel}"
 	echo -e "Hostname: $HOSTNAME"
+	echo -e "tmux: ${tmuxv}"
+	echo -e "GLIBC: ${glibcv}"	
 	echo -e "Uptime: ${days}d, ${hours}h, ${minutes}m"
 	echo -e "Avg Load${load}\n"
-	echo -e "========================================\nLogs\n========================================\n"
-	echo -e "Script log\n===================\n"
-	command_details.sh
-}|sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"|tee "${scriptlogdir}/${servicename}-email.log"
+	echo -e "========================================\nLogs\n========================================"
+}| sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"| tee "${scriptlogdir}/${servicename}-email.log" > /dev/null 2>&1
+echo -e "Script log\n===================\n" >> "${emaillog}"
 tail -25 "${scriptlog}" >> "${emaillog}"
 if [ ! -z "${consolelog}" ]; then
 	echo -e "\n\nConsole log\n====================\n" >> "${emaillog}"
-	tail -25 "${consolelog}" >> "${emaillog}"
+	tail -25 "${consolelog}" | awk '{ sub("\r$", ""); print }' >> "${emaillog}"
 fi
 if [ ! -z "${gamelogdir}" ]; then
 	echo -e "\n\nServer log\n====================\n" >> "${emaillog}"
-	tail "${gamelogdir}"/*|grep -v "==>"|sed '/^$/d'|tail -25 >> "${emaillog}"
+	tail "${gamelogdir}"/* | grep -v "==>" | sed '/^$/d' | tail -25 >> "${emaillog}"
 fi
 mail -s "${subject}" ${email} < "${emaillog}"
 fn_printok "Sending notification to ${email}"

From 49807528c90c8bdebd640fab93da774a3f0b94d1 Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Tue, 2 Feb 2016 21:05:15 +0000
Subject: [PATCH 49/54] Disk details missing re-added

---
 functions/command_details.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/functions/command_details.sh b/functions/command_details.sh
index ef63a08f9..0084f20e5 100644
--- a/functions/command_details.sh
+++ b/functions/command_details.sh
@@ -586,6 +586,7 @@ info_distro.sh
 info_glibc.sh
 fn_details_os
 fn_details_performance
+fn_details_disk
 fn_details_gameserver
 fn_details_backup
 # Some game servers do not have parms.

From 67558f076493d91cbb17479b5cbf9babb6b198e4 Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Tue, 2 Feb 2016 21:05:52 +0000
Subject: [PATCH 50/54] More useful details on the monitor email

---
 functions/email.sh | 45 +++++++++++++++++++++++++++++++++++----------
 1 file changed, 35 insertions(+), 10 deletions(-)

diff --git a/functions/email.sh b/functions/email.sh
index 05ad05bbf..93d259d80 100644
--- a/functions/email.sh
+++ b/functions/email.sh
@@ -2,40 +2,65 @@
 # LGSM email.sh function
 # Author: Daniel Gibbs
 # Website: http://gameservermanagers.com
-lgsm_version="010216"
+lgsm_version="020216"
 
 # Description: Sends email notification if monitor picks up a failure.
 
 local modulename="Email"
 fn_printdots "Sending notification to ${email}"
 info_distro.sh
+info_config.sh
+check_ip.sh
+fn_parms
 {
 	echo -e "========================================\n${servicename} details\n========================================"
-	echo -e "Service: ${servicename}"
-	echo -e "Server: ${servername}"
-	echo -e "Game: ${gamename}"
+	echo -e "Service name: ${servicename}"
+	echo -e "Server name: ${servername}"
+	echo -e "Game name: ${gamename}"
+	echo -e "Server IP: ${ip}:${port}"
 	echo -e "Failure reason: ${failurereason}"
 	echo -e "Action Taken: ${actiontaken}\n"
-	echo -e "========================================\nServer details\n========================================"
+	echo -e ""
+	echo -e "========================================\nDistro Details\n========================================"
 	echo -e "Date: $(date)"
 	echo -e "Distro: ${os}"
 	echo -e "Arch: ${arch}"
 	echo -e "Kernel: ${kernel}"
 	echo -e "Hostname: $HOSTNAME"
 	echo -e "tmux: ${tmuxv}"
-	echo -e "GLIBC: ${glibcv}"	
+	echo -e "GLIBC: ${glibcv}"
+	echo -e ""
+	echo -e "========================================\nPerformance\n========================================"
 	echo -e "Uptime: ${days}d, ${hours}h, ${minutes}m"
-	echo -e "Avg Load${load}\n"
+	echo -e "Avg Load: ${load}" 
+	echo -e ""
+	echo -e "Mem: total used free"
+	echo -e "Physical: ${physmemtotal} ${physmemused} ${physmemfree}"
+	echo -e "Swap: ${swaptotal}${swapused} ${swapfree}"
+	echo -e ""
+	echo -e "========================================\nStorage\n========================================"	
+	echo -e "\e[34mFilesystem:\t\e[0m${filesystem}"
+	echo -e "\e[34mTotal:\t\e[0m${totalspace}"
+	echo -e "\e[34mUsed:\t\e[0m${usedspace}"
+	echo -e "\e[34mAvailable:\t\e[0m${availspace}"
+	echo -e "\e[34mServerfiles:\t\e[0m${filesdirdu}"
+	if [ -d "${backupdir}" ]; then
+		echo -e "\e[34mBackups:\t\e[0m${backupdirdu}"
+	fi
+	echo -e ""	
+	echo -e "========================================\nCommand-line Parameters\n========================================"
+	echo -e "${executable} ${parms}"
+	echo -e ""
 	echo -e "========================================\nLogs\n========================================"
 }| sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"| tee "${scriptlogdir}/${servicename}-email.log" > /dev/null 2>&1
-echo -e "Script log\n===================\n" >> "${emaillog}"
+echo -e "\n\n	Script log\n===================" >> "${emaillog}"
 tail -25 "${scriptlog}" >> "${emaillog}"
 if [ ! -z "${consolelog}" ]; then
-	echo -e "\n\nConsole log\n====================\n" >> "${emaillog}"
+	echo -e "\n\n	Console log\n====================" >> "${emaillog}"
 	tail -25 "${consolelog}" | awk '{ sub("\r$", ""); print }' >> "${emaillog}"
 fi
 if [ ! -z "${gamelogdir}" ]; then
-	echo -e "\n\nServer log\n====================\n" >> "${emaillog}"
+	echo -e "\n\n	Server log\n====================" >> "${emaillog}"
 	tail "${gamelogdir}"/* | grep -v "==>" | sed '/^$/d' | tail -25 >> "${emaillog}"
 fi
 mail -s "${subject}" ${email} < "${emaillog}"

From 9258cc7146ee3711068603f0c51c1b730f7bd50a Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Tue, 2 Feb 2016 22:57:50 +0000
Subject: [PATCH 51/54] Fixed ts3 updater not detecting new version 3.0.12

Fixed with some clever awk and sort commands
---
 functions/update_check.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/functions/update_check.sh b/functions/update_check.sh
index 38e786544..70f958d68 100644
--- a/functions/update_check.sh
+++ b/functions/update_check.sh
@@ -2,7 +2,7 @@
 # LGSM update_check.sh function
 # Author: Daniel Gibbs
 # Website: http://gameservermanagers.com
-lgsm_version="271215"
+lgsm_version="020216"
 
 # Description: Checks if a server update is available.
 
@@ -216,14 +216,14 @@ ts3arch=$(ls $(find ${filesdir}/ -name 'ts3server_*_*' 2> /dev/null | grep -v 't
 wget "http://dl.4players.de/ts/releases/?C=M;O=D" -q -O -| grep -i dir | egrep -o '<a href=\".*\/\">.*\/<\/a>' | egrep -o '[0-9\.?]+'|uniq > .ts3_version_numbers_unsorted.tmp
 
 # removes digits to allow sorting of numbers
-cat .ts3_version_numbers_unsorted.tmp |tr -cd '[:digit:][*\n]' > .ts3_version_numbers_digit.tmp
+ cat .ts3_version_numbers_unsorted.tmp | tr "." " " > .ts3_version_numbers_digit.tmp
 # Sorts numbers in to correct order
 # merges two files in to one with two columns sorts the numbers in to order then only outputs the second to the ts3_version_numbers.tmp
-paste .ts3_version_numbers_digit.tmp .ts3_version_numbers_unsorted.tmp |sort -rn|awk '{ print $2 }' > .ts3_version_numbers.tmp
+paste .ts3_version_numbers_digit.tmp .ts3_version_numbers_unsorted.tmp | awk '{print $1,$2,$3,$4 " " $0;}'| sort  -k1rn -k2rn -k3rn -k4rn | awk '{print $NF}' > .ts3_version_numbers.tmp
 
 # Finds directory with most recent server version.
 while read ts3_version_number; do
-	wget --spider -q "http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux-${ts3arch}-${ts3_version_number}.tar.gz"
+	wget --spider -q "http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2"
 	if [ $? -eq 0 ]; then
 		availablebuild="${ts3_version_number}"
 		# Break while-loop, if the latest release could be found

From 9d81778e4e25072145f9cadf285e5f96adf258a9 Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Tue, 2 Feb 2016 23:02:34 +0000
Subject: [PATCH 52/54] renamed downloadable file

---
 functions/update_dl.sh | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/functions/update_dl.sh b/functions/update_dl.sh
index 09bd3ebe9..3c18cab9a 100644
--- a/functions/update_dl.sh
+++ b/functions/update_dl.sh
@@ -2,7 +2,7 @@
 # LGSM update_dl.sh function
 # Author: Daniel Gibbs
 # Website: http://gameservermanagers.com
-lgsm_version="271215"
+lgsm_version="020216"
 
 # Description: Runs a server update.
 
@@ -29,13 +29,13 @@ fix.sh
 
 fn_teamspeak3_dl(){
 cd "${rootdir}"
-echo -e "downloading teamspeak3-server_linux-${ts3arch}-${availablebuild}.tar.gz...\c"
-fn_scriptlog "Downloading teamspeak3-server_linux-${ts3arch}-${availablebuild}.tar.gz"
-wget -N /dev/null http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux-${ts3arch}-${ts3_version_number}.tar.gz 2>&1 | grep -F HTTP | cut -c45-| uniq
+echo -e "downloading teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2...\c"
+fn_scriptlog "Downloading teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2"
+wget -N /dev/null http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2 2>&1 | grep -F HTTP | cut -c45-| uniq
 sleep 1
-echo -e "extracting teamspeak3-server_linux-${ts3arch}-${availablebuild}.tar.gz...\c"
-fn_scriptlog "Extracting teamspeak3-server_linux-${ts3arch}-${availablebuild}.tar.gz"
-tar -xf "teamspeak3-server_linux-${ts3arch}-${availablebuild}.tar.gz" 2> "${scriptlogdir}/.${servicename}-tar-error.tmp"
+echo -e "extracting teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2...\c"
+fn_scriptlog "Extracting teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2"
+tar -xf "teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" 2> "${scriptlogdir}/.${servicename}-tar-error.tmp"
 local status=$?
 if [ ${status} -eq 0 ]; then
 	echo "OK"
@@ -65,7 +65,7 @@ else
 	fn_scriptlog "Failure! Unable to update"
 	exit ${status}
 fi
-rm -f teamspeak3-server_linux-${ts3arch}-${availablebuild}.tar.gz
+rm -f teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2
 rm -rf "${rootdir}/teamspeak3-server_linux-${ts3arch}"
 }
 

From 559bce4cc7381b4bd33c127a06f853850043f20b Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Tue, 2 Feb 2016 23:04:42 +0000
Subject: [PATCH 53/54] renamed extract dir

---
 functions/update_dl.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/functions/update_dl.sh b/functions/update_dl.sh
index 3c18cab9a..a80caa6d8 100644
--- a/functions/update_dl.sh
+++ b/functions/update_dl.sh
@@ -51,7 +51,7 @@ else
 fi
 echo -e "copying to ${filesdir}...\c"
 fn_scriptlog "Copying to ${filesdir}"
-cp -R "${rootdir}/teamspeak3-server_linux-${ts3arch}/"* "${filesdir}" 2> "${scriptlogdir}/.${servicename}-cp-error.tmp"
+cp -R "${rootdir}/teamspeak3-server_linux_${ts3arch}/"* "${filesdir}" 2> "${scriptlogdir}/.${servicename}-cp-error.tmp"
 local status=$?
 if [ ${status} -eq 0 ]; then
 	echo "OK"
@@ -66,7 +66,7 @@ else
 	exit ${status}
 fi
 rm -f teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2
-rm -rf "${rootdir}/teamspeak3-server_linux-${ts3arch}"
+rm -rf "${rootdir}/teamspeak3-server_linux_${ts3arch}"
 }
 
 check.sh

From d7ff36d12dae6d10c9445cd5c906aa633059d386 Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Wed, 3 Feb 2016 19:14:49 +0000
Subject: [PATCH 54/54] made corrections to ts3 server installer

---
 functions/install_ts3.sh  | 34 +++++++++++++++++-----------------
 functions/update_check.sh | 16 +++++++++-------
 2 files changed, 26 insertions(+), 24 deletions(-)

diff --git a/functions/install_ts3.sh b/functions/install_ts3.sh
index 3860fbc50..f90f91073 100644
--- a/functions/install_ts3.sh
+++ b/functions/install_ts3.sh
@@ -15,29 +15,29 @@ else
 	exit 1
 fi
 
-# Grabs all version numbers not in correct order
+# Grabs all version numbers but not in correct order
 wget "http://dl.4players.de/ts/releases/?C=M;O=D" -q -O -| grep -i dir | egrep -o '<a href=\".*\/\">.*\/<\/a>' | egrep -o '[0-9\.?]+'|uniq > .ts3_version_numbers_unsorted.tmp
 
-# removes digits to allow sorting of numbers
-cat .ts3_version_numbers_unsorted.tmp |tr -cd '[:digit:][*\n]' > .ts3_version_numbers_digit.tmp
-# Sorts numbers in to correct order
-# merges two files in to one with two columns sorts the numbers in to order then only outputs the second to the ts3_version_numbers.tmp
-paste .ts3_version_numbers_digit.tmp .ts3_version_numbers_unsorted.tmp |sort -rn|awk '{ print $2 }' > .ts3_version_numbers.tmp
+# Replaces dots with spaces to split up the number. e.g 3 0 12 1 is 3.0.12.1 this allows correct sorting
+ cat .ts3_version_numbers_unsorted.tmp | tr "." " " > .ts3_version_numbers_digit.tmp
+# Sorts versions in to correct order
+# merges 2 files and orders by each column in order allowing these version numbers to be sorted in order
+paste .ts3_version_numbers_digit.tmp .ts3_version_numbers_unsorted.tmp | awk '{print $1,$2,$3,$4 " " $0;}'| sort  -k1rn -k2rn -k3rn -k4rn | awk '{print $NF}' > .ts3_version_numbers.tmp
 
 # Finds directory with most recent server version.
 while read ts3_version_number; do
-	wget --spider -q "http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux-${ts3arch}-${ts3_version_number}.tar.gz"
+	wget --spider -q "http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2"
 	if [ $? -eq 0 ]; then
 		availablebuild="${ts3_version_number}"
-		echo "Latest Build: ${availablebuild}"
 		# Break while-loop, if the latest release could be found
-		echo "http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-66server_linux-${ts3arch}-${ts3_version_number}.tar.g"
 		break
 	fi
 done < .ts3_version_numbers.tmp
-rm -f .ts3_version_numbers_digit.tmp
-rm -f .ts3_version_numbers_unsorted.tmp
-rm -f .ts3_version_numbers.tmp
+
+# tidy up
+rm -f ".ts3_version_numbers_digit.tmp"
+rm -f ".ts3_version_numbers_unsorted.tmp"
+rm -f ".ts3_version_numbers.tmp"
 
 # Checks availablebuild info is available
 if [ -z "${availablebuild}" ]; then
@@ -49,11 +49,11 @@ if [ -z "${availablebuild}" ]; then
 fi
 
 cd "${rootdir}"
-echo -e "downloading teamspeak3-server_linux-${ts3arch}-${availablebuild}.tar.gz...\c"
-wget -N /dev/null http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux-${ts3arch}-${ts3_version_number}.tar.gz 2>&1 | grep -F HTTP | cut -c45-| uniq
+echo -e "downloading teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2...\c"
+wget -N /dev/null http://dl.4players.de/ts/releases/${ts3_version_number}/teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2 2>&1 | grep -F HTTP | cut -c45-| uniq
 sleep 1
-echo -e "extracting teamspeak3-server_linux-${ts3arch}-${availablebuild}.tar.gz...\c"
-tar -xf "teamspeak3-server_linux-${ts3arch}-${availablebuild}.tar.gz" 2> ".${servicename}-tar-error.tmp"
+echo -e "extracting teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2...\c"
+tar -xf "teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2" 2> ".${servicename}-tar-error.tmp"
 local status=$?
 if [ ${status} -eq 0 ]; then
 	echo "OK"
@@ -76,5 +76,5 @@ else
 	rm ".${servicename}-cp-error.tmp"
 	exit $?
 fi
-rm -f teamspeak3-server_linux-${ts3arch}-${availablebuild}.tar.gz
+rm -f "teamspeak3-server_linux_${ts3arch}-${ts3_version_number}.tar.bz2"
 rm -rf "${rootdir}/teamspeak3-server_linux-${ts3arch}"
diff --git a/functions/update_check.sh b/functions/update_check.sh
index 70f958d68..ece46fb88 100644
--- a/functions/update_check.sh
+++ b/functions/update_check.sh
@@ -212,13 +212,13 @@ ts3arch=$(ls $(find ${filesdir}/ -name 'ts3server_*_*' 2> /dev/null | grep -v 't
 
 # Gets availablebuild info
 
-# Grabs all version numbers not in correct order
+# Grabs all version numbers but not in correct order
 wget "http://dl.4players.de/ts/releases/?C=M;O=D" -q -O -| grep -i dir | egrep -o '<a href=\".*\/\">.*\/<\/a>' | egrep -o '[0-9\.?]+'|uniq > .ts3_version_numbers_unsorted.tmp
 
-# removes digits to allow sorting of numbers
+# Replaces dots with spaces to split up the number. e.g 3 0 12 1 is 3.0.12.1 this allows correct sorting
  cat .ts3_version_numbers_unsorted.tmp | tr "." " " > .ts3_version_numbers_digit.tmp
-# Sorts numbers in to correct order
-# merges two files in to one with two columns sorts the numbers in to order then only outputs the second to the ts3_version_numbers.tmp
+# Sorts versions in to correct order
+# merges 2 files and orders by each column in order allowing these version numbers to be sorted in order
 paste .ts3_version_numbers_digit.tmp .ts3_version_numbers_unsorted.tmp | awk '{print $1,$2,$3,$4 " " $0;}'| sort  -k1rn -k2rn -k3rn -k4rn | awk '{print $NF}' > .ts3_version_numbers.tmp
 
 # Finds directory with most recent server version.
@@ -230,9 +230,11 @@ while read ts3_version_number; do
 		break
 	fi
 done < .ts3_version_numbers.tmp
-rm -f .ts3_version_numbers_digit.tmp
-rm -f .ts3_version_numbers_unsorted.tmp
-rm -f .ts3_version_numbers.tmp
+
+# tidy up
+rm -f ".ts3_version_numbers_digit.tmp"
+rm -f ".ts3_version_numbers_unsorted.tmp"
+rm -f ".ts3_version_numbers.tmp"
 
 # Checks availablebuild info is available
 if [ -z "${availablebuild}" ]; then