From ca7cb329354f53c2d3fc20ea81c7054ba379a301 Mon Sep 17 00:00:00 2001
From: Daniel Gibbs <me@danielgibbs.co.uk>
Date: Sun, 23 Nov 2014 22:11:00 +0000
Subject: [PATCH] functions code now uses absolute paths

sometimes the code was not in the correct dir causing the function to be
re downloaded or not function. Now using absolute paths to make sure the
script uses the correct dir
---
 Arma3/arma3server                       |  16 +-
 BladeSymphony/bsserver                  |  16 +-
 CounterStrike/csserver                  |  12 +-
 CounterStrikeConditionZero/csczserver   |  12 +-
 CounterStrikeGlobalOffensive/csgoserver |  12 +-
 CounterStrikeSource/cssserver           |  12 +-
 DayOfDefeat/dodserver                   |  12 +-
 DayOfDefeatSource/dodsserver            |  16 +-
 FistfulOfFrags/fofserver                |  14 +-
 GarrysMod/gmodserver                    |  16 +-
 HalfLife2Deathmatch/hl2dmserver         |  12 +-
 HalfLifeDeathmatchClassic/hldmcserver   |  12 +-
 Insurgency/insserver                    |  16 +-
 JustCause2/jc2server                    |  14 +-
 KillingFloor/kfserver                   |  12 +-
 Left4Dead/l4dserver                     |  12 +-
 Left4Dead2/l4d2server                   |  12 +-
 NaturalSelection2/ns2server             |  16 +-
 NoMoreRoomInHell/nmrihserver            |  16 +-
 RedOrchestra/roserver                   |  12 +-
 StarBound/sbserver                      | 894 ++++++++++++++++++++++++
 TeamFortress2/tf2server                 |  12 +-
 TeamFortressClassic/tfcserver           |  12 +-
 UnrealTournament2004/ut2k4server        |   8 +-
 UnrealTournament99/ut99server           |   8 +-
 25 files changed, 1050 insertions(+), 156 deletions(-)
 create mode 100644 StarBound/sbserver

diff --git a/Arma3/arma3server b/Arma3/arma3server
index 43309c29d..82b60b3dc 100644
--- a/Arma3/arma3server
+++ b/Arma3/arma3server
@@ -196,11 +196,11 @@ fi
 }
 
 fn_debugserver(){
-if [ ! -f functions/fn_debugserver ]; then
+if [ ! -f ${rootdir}/functions/fn_debugserver ]; then
 	functionfile="fn_debugserver"
 	fn_fninstall
 fi
-source functions/fn_debugserver
+source ${rootdir}/functions/fn_debugserver
 }
 
 fn_console(){
@@ -605,11 +605,11 @@ echo -en "\n"
 }
 
 fn_details(){
-if [ ! -f functions/fn_details ]; then
+if [ ! -f ${rootdir}/functions/fn_details ]; then
 	functionfile="fn_details"
 	fn_fninstall
 fi
-source functions/fn_details
+source ${rootdir}/functions/fn_details
 }
 
 fn_fninstall(){
@@ -632,11 +632,11 @@ echo ""
 #
 
 fn_glibcfix(){
-if [ ! -f functions/fn_glibcfix ]; then
+if [ ! -f ${rootdir}/functions/fn_glibcfix ]; then
 	functionfile="fn_glibcfix"
 	fn_fninstall
 fi	
-source functions/fn_glibcfix
+source ${rootdir}/functions/fn_glibcfix
 }
 
 fn_header(){
@@ -706,11 +706,11 @@ echo ""
 }
 
 fn_steamfix(){
-if [ ! -f functions/fn_steamfix ]; then
+if [ ! -f ${rootdir}/functions/fn_steamfix ]; then
 	functionfile="fn_steamfix"
 	fn_fninstall
 fi	
-source functions/fn_steamfix
+source ${rootdir}/functions/fn_steamfix
 }
 
 fn_loginstall(){
diff --git a/BladeSymphony/bsserver b/BladeSymphony/bsserver
index 48c1d0e9d..e6f15dbe6 100644
--- a/BladeSymphony/bsserver
+++ b/BladeSymphony/bsserver
@@ -200,11 +200,11 @@ fi
 }
 
 fn_debugserver(){
-if [ ! -f functions/fn_debugserver ]; then
+if [ ! -f ${rootdir}/functions/fn_debugserver ]; then
 	functionfile="fn_debugserver"
 	fn_fninstall
 fi
-source functions/fn_debugserver
+source ${rootdir}/functions/fn_debugserver
 }
 
 fn_console(){
@@ -609,11 +609,11 @@ echo -en "\n"
 }
 
 fn_details(){
-if [ ! -f functions/fn_details ]; then
+if [ ! -f ${rootdir}/functions/fn_details ]; then
 	functionfile="fn_details"
 	fn_fninstall
 fi
-source functions/fn_details
+source ${rootdir}/functions/fn_details
 }
 
 fn_fninstall(){
@@ -636,11 +636,11 @@ echo ""
 #
 
 fn_glibcfix(){
-if [ ! -f functions/fn_glibcfix ]; then
+if [ ! -f ${rootdir}/functions/fn_glibcfix ]; then
 	functionfile="fn_glibcfix"
 	fn_fninstall
 fi	
-source functions/fn_glibcfix
+source ${rootdir}/functions/fn_glibcfix
 }
 
 fn_header(){
@@ -696,11 +696,11 @@ echo ""
 }
 
 fn_steamfix(){
-if [ ! -f functions/fn_steamfix ]; then
+if [ ! -f ${rootdir}/functions/fn_steamfix ]; then
 	functionfile="fn_steamfix"
 	fn_fninstall
 fi	
-source functions/fn_steamfix
+source ${rootdir}/functions/fn_steamfix
 }
 
 fn_loginstall(){
diff --git a/CounterStrike/csserver b/CounterStrike/csserver
index 1cb2c70f8..94a01810a 100644
--- a/CounterStrike/csserver
+++ b/CounterStrike/csserver
@@ -199,11 +199,11 @@ fi
 }
 
 fn_debugserver(){
-if [ ! -f functions/fn_debugserver ]; then
+if [ ! -f ${rootdir}/functions/fn_debugserver ]; then
 	functionfile="fn_debugserver"
 	fn_fninstall
 fi
-source functions/fn_debugserver
+source ${rootdir}/functions/fn_debugserver
 }
 
 fn_console(){
@@ -608,11 +608,11 @@ echo -en "\n"
 }
 
 fn_details(){
-if [ ! -f functions/fn_details ]; then
+if [ ! -f ${rootdir}/functions/fn_details ]; then
 	functionfile="fn_details"
 	fn_fninstall
 fi
-source functions/fn_details
+source ${rootdir}/functions/fn_details
 }
 
 fn_fninstall(){
@@ -687,11 +687,11 @@ echo ""
 }
 
 fn_steamfix(){
-if [ ! -f functions/fn_steamfix ]; then
+if [ ! -f ${rootdir}/functions/fn_steamfix ]; then
 	functionfile="fn_steamfix"
 	fn_fninstall
 fi	
-source functions/fn_steamfix
+source ${rootdir}/functions/fn_steamfix
 }
 
 fn_loginstall(){
diff --git a/CounterStrikeConditionZero/csczserver b/CounterStrikeConditionZero/csczserver
index fc4fc16e5..7e155e355 100644
--- a/CounterStrikeConditionZero/csczserver
+++ b/CounterStrikeConditionZero/csczserver
@@ -199,11 +199,11 @@ fi
 }
 
 fn_debugserver(){
-if [ ! -f functions/fn_debugserver ]; then
+if [ ! -f ${rootdir}/functions/fn_debugserver ]; then
 	functionfile="fn_debugserver"
 	fn_fninstall
 fi
-source functions/fn_debugserver
+source ${rootdir}/functions/fn_debugserver
 }
 
 fn_console(){
@@ -608,11 +608,11 @@ echo -en "\n"
 }
 
 fn_details(){
-if [ ! -f functions/fn_details ]; then
+if [ ! -f ${rootdir}/functions/fn_details ]; then
 	functionfile="fn_details"
 	fn_fninstall
 fi
-source functions/fn_details
+source ${rootdir}/functions/fn_details
 }
 
 fn_fninstall(){
@@ -687,11 +687,11 @@ echo ""
 }
 
 fn_steamfix(){
-if [ ! -f functions/fn_steamfix ]; then
+if [ ! -f ${rootdir}/functions/fn_steamfix ]; then
 	functionfile="fn_steamfix"
 	fn_fninstall
 fi	
-source functions/fn_steamfix
+source ${rootdir}/functions/fn_steamfix
 }
 
 fn_loginstall(){
diff --git a/CounterStrikeGlobalOffensive/csgoserver b/CounterStrikeGlobalOffensive/csgoserver
index d7b51eec9..5fec75317 100644
--- a/CounterStrikeGlobalOffensive/csgoserver
+++ b/CounterStrikeGlobalOffensive/csgoserver
@@ -217,11 +217,11 @@ fi
 }
 
 fn_debugserver(){
-if [ ! -f functions/fn_debugserver ]; then
+if [ ! -f ${rootdir}/functions/fn_debugserver ]; then
 	functionfile="fn_debugserver"
 	fn_fninstall
 fi
-source functions/fn_debugserver
+source ${rootdir}/functions/fn_debugserver
 }
 
 fn_console(){
@@ -627,11 +627,11 @@ echo -en "\n"
 }
 
 fn_details(){
-if [ ! -f functions/fn_details ]; then
+if [ ! -f ${rootdir}/functions/fn_details ]; then
 	functionfile="fn_details"
 	fn_fninstall
 fi
-source functions/fn_details
+source ${rootdir}/functions/fn_details
 }
 
 fn_fninstall(){
@@ -773,11 +773,11 @@ echo ""
 }
 
 fn_steamfix(){
-if [ ! -f functions/fn_steamfix ]; then
+if [ ! -f ${rootdir}/functions/fn_steamfix ]; then
 	functionfile="fn_steamfix"
 	fn_fninstall
 fi	
-source functions/fn_steamfix
+source ${rootdir}/functions/fn_steamfix
 }
 
 fn_loginstall(){
diff --git a/CounterStrikeSource/cssserver b/CounterStrikeSource/cssserver
index 09b3de7ad..540ec4952 100644
--- a/CounterStrikeSource/cssserver
+++ b/CounterStrikeSource/cssserver
@@ -200,11 +200,11 @@ fi
 }
 
 fn_debugserver(){
-if [ ! -f functions/fn_debugserver ]; then
+if [ ! -f ${rootdir}/functions/fn_debugserver ]; then
 	functionfile="fn_debugserver"
 	fn_fninstall
 fi
-source functions/fn_debugserver
+source ${rootdir}/functions/fn_debugserver
 }
 
 fn_console(){
@@ -609,11 +609,11 @@ echo -en "\n"
 }
 
 fn_details(){
-if [ ! -f functions/fn_details ]; then
+if [ ! -f ${rootdir}/functions/fn_details ]; then
 	functionfile="fn_details"
 	fn_fninstall
 fi
-source functions/fn_details
+source ${rootdir}/functions/fn_details
 }
 
 fn_fninstall(){
@@ -688,11 +688,11 @@ echo ""
 }
 
 fn_steamfix(){
-if [ ! -f functions/fn_steamfix ]; then
+if [ ! -f ${rootdir}/functions/fn_steamfix ]; then
 	functionfile="fn_steamfix"
 	fn_fninstall
 fi	
-source functions/fn_steamfix
+source ${rootdir}/functions/fn_steamfix
 }
 
 fn_loginstall(){
diff --git a/DayOfDefeat/dodserver b/DayOfDefeat/dodserver
index 9960ab5be..27839eca2 100644
--- a/DayOfDefeat/dodserver
+++ b/DayOfDefeat/dodserver
@@ -199,11 +199,11 @@ fi
 }
 
 fn_debugserver(){
-if [ ! -f functions/fn_debugserver ]; then
+if [ ! -f ${rootdir}/functions/fn_debugserver ]; then
 	functionfile="fn_debugserver"
 	fn_fninstall
 fi
-source functions/fn_debugserver
+source ${rootdir}/functions/fn_debugserver
 }
 
 fn_console(){
@@ -608,11 +608,11 @@ echo -en "\n"
 }
 
 fn_details(){
-if [ ! -f functions/fn_details ]; then
+if [ ! -f ${rootdir}/functions/fn_details ]; then
 	functionfile="fn_details"
 	fn_fninstall
 fi
-source functions/fn_details
+source ${rootdir}/functions/fn_details
 }
 
 fn_fninstall(){
@@ -687,11 +687,11 @@ echo ""
 }
 
 fn_steamfix(){
-if [ ! -f functions/fn_steamfix ]; then
+if [ ! -f ${rootdir}/functions/fn_steamfix ]; then
 	functionfile="fn_steamfix"
 	fn_fninstall
 fi	
-source functions/fn_steamfix
+source ${rootdir}/functions/fn_steamfix
 }
 
 fn_loginstall(){
diff --git a/DayOfDefeatSource/dodsserver b/DayOfDefeatSource/dodsserver
index e9cf5a0fc..29d877389 100644
--- a/DayOfDefeatSource/dodsserver
+++ b/DayOfDefeatSource/dodsserver
@@ -200,11 +200,11 @@ fi
 }
 
 fn_debugserver(){
-if [ ! -f functions/fn_debugserver ]; then
+if [ ! -f ${rootdir}/functions/fn_debugserver ]; then
 	functionfile="fn_debugserver"
 	fn_fninstall
 fi
-source functions/fn_debugserver
+source ${rootdir}/functions/fn_debugserver
 }
 
 fn_console(){
@@ -609,11 +609,11 @@ echo -en "\n"
 }
 
 fn_details(){
-if [ ! -f functions/fn_details ]; then
+if [ ! -f ${rootdir}/functions/fn_details ]; then
 	functionfile="fn_details"
 	fn_fninstall
 fi
-source functions/fn_details
+source ${rootdir}/functions/fn_details
 }
 
 fn_fninstall(){
@@ -636,11 +636,11 @@ echo ""
 #
 
 fn_glibcfix(){
-if [ ! -f functions/fn_glibcfix ]; then
+if [ ! -f ${rootdir}/functions/fn_glibcfix ]; then
 	functionfile="fn_glibcfix"
 	fn_fninstall
 fi	
-source functions/fn_glibcfix
+source ${rootdir}/functions/fn_glibcfix
 }
 
 fn_header(){
@@ -696,11 +696,11 @@ echo ""
 }
 
 fn_steamfix(){
-if [ ! -f functions/fn_steamfix ]; then
+if [ ! -f ${rootdir}/functions/fn_steamfix ]; then
 	functionfile="fn_steamfix"
 	fn_fninstall
 fi	
-source functions/fn_steamfix
+source ${rootdir}/functions/fn_steamfix
 }
 
 fn_loginstall(){
diff --git a/FistfulOfFrags/fofserver b/FistfulOfFrags/fofserver
index f941ea0fb..fa2d3093b 100644
--- a/FistfulOfFrags/fofserver
+++ b/FistfulOfFrags/fofserver
@@ -204,7 +204,7 @@ if [ ! -f functions/fn_debugserver ]; then
 	functionfile="fn_debugserver"
 	fn_fninstall
 fi
-source functions/fn_debugserver
+source ${rootdir}/functions/fn_debugserver
 }
 
 fn_console(){
@@ -609,11 +609,11 @@ echo -en "\n"
 }
 
 fn_details(){
-if [ ! -f functions/fn_details ]; then
+if [ ! -f ${rootdir}/functions/fn_details ]; then
 	functionfile="fn_details"
 	fn_fninstall
 fi
-source functions/fn_details
+source ${rootdir}/functions/fn_details
 }
 
 fn_fninstall(){
@@ -636,11 +636,11 @@ echo ""
 #
 
 fn_glibcfix(){
-if [ ! -f functions/fn_glibcfix ]; then
+if [ ! -f ${rootdir}/functions/fn_glibcfix ]; then
 	functionfile="fn_glibcfix"
 	fn_fninstall
 fi	
-source functions/fn_glibcfix
+source ${rootdir}/functions/fn_glibcfix
 }
 
 fn_header(){
@@ -696,11 +696,11 @@ echo ""
 }
 
 fn_steamfix(){
-if [ ! -f functions/fn_steamfix ]; then
+if [ ! -f ${rootdir}/functions/fn_steamfix ]; then
 	functionfile="fn_steamfix"
 	fn_fninstall
 fi	
-source functions/fn_steamfix
+source ${rootdir}/functions/fn_steamfix
 }
 
 fn_loginstall(){
diff --git a/GarrysMod/gmodserver b/GarrysMod/gmodserver
index 9cb47862a..7ee9db922 100644
--- a/GarrysMod/gmodserver
+++ b/GarrysMod/gmodserver
@@ -205,11 +205,11 @@ fi
 }
 
 fn_debugserver(){
-if [ ! -f functions/fn_debugserver ]; then
+if [ ! -f ${rootdir}/functions/fn_debugserver ]; then
 	functionfile="fn_debugserver"
 	fn_fninstall
 fi
-source functions/fn_debugserver
+source ${rootdir}/functions/fn_debugserver
 }
 
 fn_console(){
@@ -614,11 +614,11 @@ echo -en "\n"
 }
 
 fn_details(){
-if [ ! -f functions/fn_details ]; then
+if [ ! -f ${rootdir}/functions/fn_details ]; then
 	functionfile="fn_details"
 	fn_fninstall
 fi
-source functions/fn_details
+source ${rootdir}/functions/fn_details
 }
 
 fn_fninstall(){
@@ -641,11 +641,11 @@ echo ""
 #
 
 fn_glibcfix(){
-if [ ! -f functions/fn_glibcfix ]; then
+if [ ! -f ${rootdir}/functions/fn_glibcfix ]; then
 	functionfile="fn_glibcfix"
 	fn_fninstall
 fi	
-source functions/fn_glibcfix
+source ${rootdir}/functions/fn_glibcfix
 }
 
 fn_header(){
@@ -701,11 +701,11 @@ echo ""
 }
 
 fn_steamfix(){
-if [ ! -f functions/fn_steamfix ]; then
+if [ ! -f ${rootdir}/functions/fn_steamfix ]; then
 	functionfile="fn_steamfix"
 	fn_fninstall
 fi	
-source functions/fn_steamfix
+source ${rootdir}/functions/fn_steamfix
 }
 
 fn_loginstall(){
diff --git a/HalfLife2Deathmatch/hl2dmserver b/HalfLife2Deathmatch/hl2dmserver
index d092f02a6..3c16c80b6 100644
--- a/HalfLife2Deathmatch/hl2dmserver
+++ b/HalfLife2Deathmatch/hl2dmserver
@@ -200,11 +200,11 @@ fi
 }
 
 fn_debugserver(){
-if [ ! -f functions/fn_debugserver ]; then
+if [ ! -f ${rootdir}/functions/fn_debugserver ]; then
 	functionfile="fn_debugserver"
 	fn_fninstall
 fi
-source functions/fn_debugserver
+source ${rootdir}/functions/fn_debugserver
 }
 
 fn_console(){
@@ -609,11 +609,11 @@ echo -en "\n"
 }
 
 fn_details(){
-if [ ! -f functions/fn_details ]; then
+if [ ! -f ${rootdir}/functions/fn_details ]; then
 	functionfile="fn_details"
 	fn_fninstall
 fi
-source functions/fn_details
+source ${rootdir}/functions/fn_details
 }
 
 fn_fninstall(){
@@ -688,11 +688,11 @@ echo ""
 }
 
 fn_steamfix(){
-if [ ! -f functions/fn_steamfix ]; then
+if [ ! -f ${rootdir}/functions/fn_steamfix ]; then
 	functionfile="fn_steamfix"
 	fn_fninstall
 fi	
-source functions/fn_steamfix
+source ${rootdir}/functions/fn_steamfix
 }
 
 fn_loginstall(){
diff --git a/HalfLifeDeathmatchClassic/hldmcserver b/HalfLifeDeathmatchClassic/hldmcserver
index 35e6e5227..aaa710509 100644
--- a/HalfLifeDeathmatchClassic/hldmcserver
+++ b/HalfLifeDeathmatchClassic/hldmcserver
@@ -199,11 +199,11 @@ fi
 }
 
 fn_debugserver(){
-if [ ! -f functions/fn_debugserver ]; then
+if [ ! -f ${rootdir}/functions/fn_debugserver ]; then
 	functionfile="fn_debugserver"
 	fn_fninstall
 fi
-source functions/fn_debugserver
+source ${rootdir}/functions/fn_debugserver
 }
 
 fn_console(){
@@ -608,11 +608,11 @@ echo -en "\n"
 }
 
 fn_details(){
-if [ ! -f functions/fn_details ]; then
+if [ ! -f ${rootdir}/functions/fn_details ]; then
 	functionfile="fn_details"
 	fn_fninstall
 fi
-source functions/fn_details
+source ${rootdir}/functions/fn_details
 }
 
 fn_fninstall(){
@@ -687,11 +687,11 @@ echo ""
 }
 
 fn_steamfix(){
-if [ ! -f functions/fn_steamfix ]; then
+if [ ! -f ${rootdir}/functions/fn_steamfix ]; then
 	functionfile="fn_steamfix"
 	fn_fninstall
 fi	
-source functions/fn_steamfix
+source ${rootdir}/functions/fn_steamfix
 }
 
 fn_loginstall(){
diff --git a/Insurgency/insserver b/Insurgency/insserver
index ba0f7684d..6e9431d1e 100644
--- a/Insurgency/insserver
+++ b/Insurgency/insserver
@@ -200,11 +200,11 @@ fi
 }
 
 fn_debugserver(){
-if [ ! -f functions/fn_debugserver ]; then
+if [ ! -f ${rootdir}/functions/fn_debugserver ]; then
 	functionfile="fn_debugserver"
 	fn_fninstall
 fi
-source functions/fn_debugserver
+source ${rootdir}/functions/fn_debugserver
 }
 
 fn_console(){
@@ -609,11 +609,11 @@ echo -en "\n"
 }
 
 fn_details(){
-if [ ! -f functions/fn_details ]; then
+if [ ! -f ${rootdir}/functions/fn_details ]; then
 	functionfile="fn_details"
 	fn_fninstall
 fi
-source functions/fn_details
+source ${rootdir}/functions/fn_details
 }
 
 fn_fninstall(){
@@ -636,11 +636,11 @@ echo ""
 #
 
 fn_glibcfix(){
-if [ ! -f functions/fn_glibcfix ]; then
+if [ ! -f ${rootdir}/functions/fn_glibcfix ]; then
 	functionfile="fn_glibcfix"
 	fn_fninstall
 fi	
-source functions/fn_glibcfix
+source ${rootdir}/functions/fn_glibcfix
 }
 
 fn_header(){
@@ -696,11 +696,11 @@ echo ""
 }
 
 fn_steamfix(){
-if [ ! -f functions/fn_steamfix ]; then
+if [ ! -f ${rootdir}/functions/fn_steamfix ]; then
 	functionfile="fn_steamfix"
 	fn_fninstall
 fi	
-source functions/fn_steamfix
+source ${rootdir}/functions/fn_steamfix
 }
 
 fn_loginstall(){
diff --git a/JustCause2/jc2server b/JustCause2/jc2server
index bcd8a627b..d5251503c 100644
--- a/JustCause2/jc2server
+++ b/JustCause2/jc2server
@@ -3,7 +3,7 @@
 # Server Management Script
 # Author: Daniel Gibbs
 # Website: http://danielgibbs.co.uk
-# Version: 121114
+# Version: 221114
 
 #### Variables ####
 
@@ -194,11 +194,11 @@ fi
 }
 
 fn_debugserver(){
-if [ ! -f functions/fn_debugserver ]; then
+if [ ! -f ${rootdir}/functions/fn_debugserver ]; then
 	functionfile="fn_debugserver"
 	fn_fninstall
 fi
-source functions/fn_debugserver
+source ${rootdir}/functions/fn_debugserver
 }
 
 fn_console(){
@@ -603,11 +603,11 @@ echo -en "\n"
 }
 
 fn_details(){
-if [ ! -f functions/fn_details ]; then
+if [ ! -f ${rootdir}/functions/fn_details ]; then
 	functionfile="fn_details"
 	fn_fninstall
 fi
-source functions/fn_details
+source ${rootdir}/functions/fn_details
 }
 
 fn_fninstall(){
@@ -630,11 +630,11 @@ echo ""
 #
 
 fn_glibcfix(){
-if [ ! -f functions/fn_glibcfix ]; then
+if [ ! -f ${rootdir}/functions/fn_glibcfix ]; then
 	functionfile="fn_glibcfix"
 	fn_fninstall
 fi	
-source functions/fn_glibcfix
+source ${rootdir}/functions/fn_glibcfix
 }
 
 fn_header(){
diff --git a/KillingFloor/kfserver b/KillingFloor/kfserver
index 0dae15770..3168108f7 100644
--- a/KillingFloor/kfserver
+++ b/KillingFloor/kfserver
@@ -194,11 +194,11 @@ fi
 }
 
 fn_debugserver(){
-if [ ! -f functions/fn_debugserver ]; then
+if [ ! -f ${rootdir}/functions/fn_debugserver ]; then
 	functionfile="fn_debugserver"
 	fn_fninstall
 fi
-source functions/fn_debugserver
+source ${rootdir}/functions/fn_debugserver
 }
 
 fn_console(){
@@ -603,11 +603,11 @@ echo -en "\n"
 }
 
 fn_details(){
-if [ ! -f functions/fn_details ]; then
+if [ ! -f ${rootdir}/functions/fn_details ]; then
 	functionfile="fn_details"
 	fn_fninstall
 fi
-source functions/fn_details
+source ${rootdir}/functions/fn_details
 }
 
 fn_fninstall(){
@@ -712,11 +712,11 @@ echo ""
 }
 
 fn_steamfix(){
-if [ ! -f functions/fn_steamfix ]; then
+if [ ! -f ${rootdir}/functions/fn_steamfix ]; then
 	functionfile="fn_steamfix"
 	fn_fninstall
 fi	
-source functions/fn_steamfix
+source ${rootdir}/functions/fn_steamfix
 }
 
 fn_loginstall(){
diff --git a/Left4Dead/l4dserver b/Left4Dead/l4dserver
index 8f19224f3..6caba7766 100644
--- a/Left4Dead/l4dserver
+++ b/Left4Dead/l4dserver
@@ -199,11 +199,11 @@ fi
 }
 
 fn_debugserver(){
-if [ ! -f functions/fn_debugserver ]; then
+if [ ! -f ${rootdir}/functions/fn_debugserver ]; then
 	functionfile="fn_debugserver"
 	fn_fninstall
 fi
-source functions/fn_debugserver
+source ${rootdir}/functions/fn_debugserver
 }
 
 fn_console(){
@@ -608,11 +608,11 @@ echo -en "\n"
 }
 
 fn_details(){
-if [ ! -f functions/fn_details ]; then
+if [ ! -f ${rootdir}/functions/fn_details ]; then
 	functionfile="fn_details"
 	fn_fninstall
 fi
-source functions/fn_details
+source ${rootdir}/functions/fn_details
 }
 
 fn_fninstall(){
@@ -698,11 +698,11 @@ echo ""
 }
 
 fn_steamfix(){
-if [ ! -f functions/fn_steamfix ]; then
+if [ ! -f ${rootdir}/functions/fn_steamfix ]; then
 	functionfile="fn_steamfix"
 	fn_fninstall
 fi	
-source functions/fn_steamfix
+source ${rootdir}/functions/fn_steamfix
 }
 
 fn_loginstall(){
diff --git a/Left4Dead2/l4d2server b/Left4Dead2/l4d2server
index 81bf0ed23..ebb2ee629 100644
--- a/Left4Dead2/l4d2server
+++ b/Left4Dead2/l4d2server
@@ -199,11 +199,11 @@ fi
 }
 
 fn_debugserver(){
-if [ ! -f functions/fn_debugserver ]; then
+if [ ! -f ${rootdir}/functions/fn_debugserver ]; then
 	functionfile="fn_debugserver"
 	fn_fninstall
 fi
-source functions/fn_debugserver
+source ${rootdir}/functions/fn_debugserver
 }
 
 fn_console(){
@@ -608,11 +608,11 @@ echo -en "\n"
 }
 
 fn_details(){
-if [ ! -f functions/fn_details ]; then
+if [ ! -f ${rootdir}/functions/fn_details ]; then
 	functionfile="fn_details"
 	fn_fninstall
 fi
-source functions/fn_details
+source ${rootdir}/functions/fn_details
 }
 
 fn_fninstall(){
@@ -687,11 +687,11 @@ echo ""
 }
 
 fn_steamfix(){
-if [ ! -f functions/fn_steamfix ]; then
+if [ ! -f ${rootdir}/functions/fn_steamfix ]; then
 	functionfile="fn_steamfix"
 	fn_fninstall
 fi	
-source functions/fn_steamfix
+source ${rootdir}/functions/fn_steamfix
 }
 
 fn_loginstall(){
diff --git a/NaturalSelection2/ns2server b/NaturalSelection2/ns2server
index e3582c349..a43047000 100644
--- a/NaturalSelection2/ns2server
+++ b/NaturalSelection2/ns2server
@@ -199,11 +199,11 @@ fi
 }
 
 fn_debugserver(){
-if [ ! -f functions/fn_debugserver ]; then
+if [ ! -f ${rootdir}/functions/fn_debugserver ]; then
 	functionfile="fn_debugserver"
 	fn_fninstall
 fi
-source functions/fn_debugserver
+source ${rootdir}/functions/fn_debugserver
 }
 
 fn_console(){
@@ -608,11 +608,11 @@ echo -en "\n"
 }
 
 fn_details(){
-if [ ! -f functions/fn_details ]; then
+if [ ! -f ${rootdir}/functions/fn_details ]; then
 	functionfile="fn_details"
 	fn_fninstall
 fi
-source functions/fn_details
+source ${rootdir}/functions/fn_details
 }
 
 fn_fninstall(){
@@ -635,11 +635,11 @@ echo ""
 #
 
 fn_glibcfix(){
-if [ ! -f functions/fn_glibcfix ]; then
+if [ ! -f ${rootdir}/functions/fn_glibcfix ]; then
 	functionfile="fn_glibcfix"
 	fn_fninstall
 fi	
-source functions/fn_glibcfix
+source ${rootdir}/functions/fn_glibcfix
 }
 
 fn_header(){
@@ -695,11 +695,11 @@ echo ""
 }
 
 fn_steamfix(){
-if [ ! -f functions/fn_steamfix ]; then
+if [ ! -f ${rootdir}/functions/fn_steamfix ]; then
 	functionfile="fn_steamfix"
 	fn_fninstall
 fi	
-source functions/fn_steamfix
+source ${rootdir}/functions/fn_steamfix
 }
 
 fn_loginstall(){
diff --git a/NoMoreRoomInHell/nmrihserver b/NoMoreRoomInHell/nmrihserver
index dfaad1ca5..c1e8bb4d1 100644
--- a/NoMoreRoomInHell/nmrihserver
+++ b/NoMoreRoomInHell/nmrihserver
@@ -200,11 +200,11 @@ fi
 }
 
 fn_debugserver(){
-if [ ! -f functions/fn_debugserver ]; then
+if [ ! -f ${rootdir}/functions/fn_debugserver ]; then
 	functionfile="fn_debugserver"
 	fn_fninstall
 fi
-source functions/fn_debugserver
+source ${rootdir}/functions/fn_debugserver
 }
 
 fn_console(){
@@ -609,11 +609,11 @@ echo -en "\n"
 }
 
 fn_details(){
-if [ ! -f functions/fn_details ]; then
+if [ ! -f ${rootdir}/functions/fn_details ]; then
 	functionfile="fn_details"
 	fn_fninstall
 fi
-source functions/fn_details
+source ${rootdir}/functions/fn_details
 }
 
 fn_fninstall(){
@@ -636,11 +636,11 @@ echo ""
 #
 
 fn_glibcfix(){
-if [ ! -f functions/fn_glibcfix ]; then
+if [ ! -f ${rootdir}/functions/fn_glibcfix ]; then
 	functionfile="fn_glibcfix"
 	fn_fninstall
 fi	
-source functions/fn_glibcfix
+source ${rootdir}/functions/fn_glibcfix
 }
 
 fn_header(){
@@ -696,11 +696,11 @@ echo ""
 }
 
 fn_steamfix(){
-if [ ! -f functions/fn_steamfix ]; then
+if [ ! -f ${rootdir}/functions/fn_steamfix ]; then
 	functionfile="fn_steamfix"
 	fn_fninstall
 fi	
-source functions/fn_steamfix
+source ${rootdir}/functions/fn_steamfix
 }
 
 fn_loginstall(){
diff --git a/RedOrchestra/roserver b/RedOrchestra/roserver
index 9bb6a3d59..756b7306c 100644
--- a/RedOrchestra/roserver
+++ b/RedOrchestra/roserver
@@ -190,11 +190,11 @@ fi
 }
 
 fn_debugserver(){
-if [ ! -f functions/fn_debugserver ]; then
+if [ ! -f ${rootdir}/functions/fn_debugserver ]; then
 	functionfile="fn_debugserver"
 	fn_fninstall
 fi
-source functions/fn_debugserver
+source ${rootdir}/functions/fn_debugserver
 }
 
 fn_console(){
@@ -599,11 +599,11 @@ echo -en "\n"
 }
 
 fn_details(){
-if [ ! -f functions/fn_details ]; then
+if [ ! -f ${rootdir}/functions/fn_details ]; then
 	functionfile="fn_details"
 	fn_fninstall
 fi
-source functions/fn_details
+source ${rootdir}/functions/fn_details
 }
 
 fn_fninstall(){
@@ -708,11 +708,11 @@ echo ""
 }
 
 fn_steamfix(){
-if [ ! -f functions/fn_steamfix ]; then
+if [ ! -f ${rootdir}/functions/fn_steamfix ]; then
 	functionfile="fn_steamfix"
 	fn_fninstall
 fi	
-source functions/fn_steamfix
+source ${rootdir}/functions/fn_steamfix
 }
 
 fn_loginstall(){
diff --git a/StarBound/sbserver b/StarBound/sbserver
new file mode 100644
index 000000000..c86ef4c96
--- /dev/null
+++ b/StarBound/sbserver
@@ -0,0 +1,894 @@
+#!/bin/bash
+# StarBound
+# Server Management Script
+# Author: Daniel Gibbs
+# Website: http://danielgibbs.co.uk
+# Version: 200914
+
+#### Variables ####
+
+# Notification Email
+# (on|off)
+emailnotification="off"
+email="email@example.com"
+
+# Steam login
+steamuser="anonymous"
+steampass=""
+
+# Start Variables
+defaultmap="de_dust2"
+maxplayers="16"
+port="27015"
+sourcetvport="27020"
+clientport="27005"
+ip="0.0.0.0"
+
+# https://developer.valvesoftware.com/wiki/Command_Line_Options#Source_Dedicated_Server
+fn_parms(){
+parms="-game cstrike -strictportbind -ip ${ip} -port ${port} +clientport ${clientport} +tv_port ${sourcetvport} +map ${defaultmap} +servercfgfile ${servercfg} -maxplayers ${maxplayers}"
+}
+
+#### Advanced Variables ####
+
+# Steam
+appid="211820"
+
+# Server Details
+servicename="css-server"
+gamename="Counter Strike: Source"
+engine="source"
+
+# Directories
+rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd )"
+selfname="$0"
+lockselfname=$(echo ".${servicename}.lock")
+filesdir="${rootdir}/serverfiles"
+systemdir="${filesdir}/cstrike"
+executabledir="${filesdir}"
+executable="./srcds_run"
+servercfgdir="${systemdir}/cfg"
+servercfg="${servicename}.cfg"
+servercfgfullpath="${servercfgdir}/${servercfg}"
+defaultcfg="${servercfgdir}/server.cfg"
+backupdir="backups"
+
+# Server Details
+servername=$(grep -s hostname "${servercfgfullpath}"|sed 's/hostname //g'|sed 's/"//g')
+rcon=$(grep -s rcon_password "${servercfgfullpath}"|sed 's/rcon_password //g'|sed 's/"//g')
+
+# 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
+# unless you know
+# what you are doing
+
+fn_scriptlog(){
+	echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: '$1'" >> ${scriptlog}
+}
+
+# [ FAIL ]
+fn_printfail(){
+    echo -en "\r\033[K[\e[0;31m FAIL \e[0;39m] $@"
+}
+
+fn_printfailnl(){
+    echo -e "\r\033[K[\e[0;31m FAIL \e[0;39m] $@"
+}
+
+fn_printok(){
+    echo -en "\r\033[K[\e[0;32m  OK  \e[0;39m] $@"
+}
+
+# [  OK  ]
+fn_printoknl(){
+    echo -e "\r\033[K[\e[0;32m  OK  \e[0;39m] $@"
+}
+
+fn_printinfo(){
+    echo -en "\r\033[K[\e[0;36m INFO \e[0;39m] $@"
+}
+
+fn_printinfonl(){
+    echo -e "\r\033[K[\e[0;36m INFO \e[0;39m] $@"
+}
+
+# [ INFO ]
+fn_printokinfonl(){
+    echo -e "\r\033[K[\e[0;36m INFO \e[0;39m] $@"
+}
+
+fn_printwarn(){
+	echo -en "\r\033[K[\e[1;33m WARN \e[0;39m] $@"
+}
+
+fn_printwarnnl(){
+	echo -e "\r\033[K[\e[1;33m WARN \e[0;39m] $@"
+}
+
+# [ .... ]
+fn_printdots(){
+    echo -en "\r\033[K[ .... ] $@"
+}
+
+fn_rootcheck(){
+if [ `whoami` = "root" ]; then
+	fn_printfailnl "Script will not run as root!"
+	exit
+fi
+}
+
+fn_syscheck(){
+if [ ! -e "${systemdir}" ]; then
+	fn_printfailnl "Cannot access ${systemdir}: No such directory"
+	exit
+fi
+}
+
+fn_autoip(){
+# Identifies the server interface IP
+# If multiple interfaces this will need to be set manually
+getip=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0)
+getipwc=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0|wc -l)
+if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then
+	if [ "${getipwc}" -ge "2" ]; then
+		fn_printwarn "Multiple active network interfaces.\n\n"
+		echo -en "Manually specify the IP you want to use within the ${selfname} script.\n"
+		echo -en "Set ip=\"0.0.0.0\" to one of the following:\n"
+		echo -en "${getip}\n"
+		exit
+	else
+		ip=${getip}
+	fi
+fi
+}
+
+fn_logmanager(){
+if [ ! -e "${consolelog}" ]; then
+	touch "${consolelog}"
+fi
+# log manager will active if finds logs older than ${logdays}
+if [ `find "${scriptlogdir}"/* -mtime +${logdays}|wc -l` -ne "0" ]; then
+	fn_printdots "Starting log cleaner"
+	sleep 1
+	fn_printok "Starting log cleaner"
+	fn_scriptlog "Starting log cleaner"
+	sleep 1
+	echo -en "\n"
+	fn_printinfo "Removing logs older than ${logdays} days"
+	fn_scriptlog "Removing logs older than ${logdays} days"
+	sleep 1
+	echo -en "\n"
+	if [ "${engine}" == "unreal2" ]; then
+		find "${gamelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}"
+	fi
+	find "${scriptlogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}"
+	find "${consolelogdir}"/* -mtime +${logdays}|tee >> "${scriptlog}"
+	if [ "${engine}" == "unreal2" ]; then
+		gamecount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l)
+	fi
+	scriptcount=$(find "${scriptlogdir}"/* -mtime +${logdays}|wc -l)
+	consolecount=$(find "${consolelogdir}"/* -mtime +${logdays}|wc -l)
+	count=$((${scriptcount} + ${consolecount}))
+	if [ "${engine}" == "unreal2" ]; then
+		count=$((${scriptcount} + ${consolecount} + ${gamecount}))
+	else
+		count=$((${scriptcount} + ${consolecount}))
+	fi
+	if [ "${engine}" == "unreal2" ]; then
+		find "${gamelogdir}"/* -mtime +${logdays} -exec rm {} \;
+	fi
+	find "${scriptlogdir}"/* -mtime +${logdays} -exec rm {} \;
+	find "${consolelogdir}"/* -mtime +${logdays} -exec rm {} \;
+	fn_printok "Log cleaner removed ${count} log files"
+	fn_scriptlog "Log cleaner removed ${count} log files"
+	sleep 1
+	echo -en "\n"
+fi
+}
+
+fn_debugserver(){
+fn_rootcheck
+fn_syscheck
+fn_autoip
+fn_distro
+fn_uptime
+fn_load
+fn_parms
+echo ""
+echo "${gamename} Debug"
+echo "============================"
+echo ""
+echo -e "Distro: ${os}"
+echo -e "Arch: ${arch}"
+echo -e "Kernel: ${kernel}"
+echo -e "Hostname: $HOSTNAME"
+echo ""
+echo "Start parameters:"
+echo ${parms}
+echo ""
+echo -e "Use for identifying server issues only!"
+echo -e "Press CTRL+c to drop out of debug mode"
+echo -e "\e[0;31mWARNING!\e[0;39m If ${servicename} is already running it will be stopped"
+echo ""
+while true; do
+	read -p "Continue? [y/N]" yn
+	case $yn in
+	[Yy]* ) break;;
+	[Nn]* ) echo Exiting; return 1;;
+	* ) echo "Please answer yes or no.";;
+esac
+done
+fn_stopserver
+fn_printdots "Starting debug mode ${servicename}: ${servername}"
+sleep 1
+fn_printok "Starting debug mode ${servicename}: ${servername}"
+sleep 1
+fn_scriptlog "Started debug mode ${servername}"
+echo -en "\n"
+cd "${executabledir}"
+${executable} ${parms} -debug
+}
+
+fn_console(){
+fn_rootcheck
+fn_syscheck
+echo ""
+echo "${gamename} Console"
+echo "============================"
+echo ""
+echo "Press \"CTRL+b d\" to exit console"
+echo -e "\e[0;31mWARNING!\e[0;39m Do NOT press CTRL+c to exit"
+echo ""
+while true; do
+	read -p "Continue? [y/N]" yn
+	case $yn in
+	[Yy]* ) break;;
+	[Nn]* ) echo Exiting; return 1;;
+	* ) echo "Please answer yes or no.";;
+esac
+done
+fn_printdots "Starting ${servicename} console"
+sleep 1
+tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l)
+if [ ${tmuxwc} -eq 1 ]; then
+	fn_printoknl "Starting ${servicename} console"
+	fn_scriptlog "Console accessed"
+	sleep 1
+	tmux attach-session -t ${servicename}
+else
+	fn_printfailnl "Starting ${servicename} console: ${servername} not running"
+	sleep 1
+	while true; do
+		read -p "Do you want to start the server? [y/N]" yn
+		case $yn in
+		[Yy]* ) fn_startserver; break;;
+		[Nn]* ) break;;
+		* ) echo "Please answer yes or no.";;
+	esac
+	done
+fi
+}
+
+fn_backupserver(){
+fn_rootcheck
+fn_syscheck
+backupname="${servicename}-$(date '+%Y-%m-%d-%H%M%S')"
+echo ""
+echo "${gamename} Backup"
+echo "============================"
+echo ""
+echo "The following backup will be created."
+echo ""
+echo "${backupdir}/${backupname}.tar.gz"
+echo ""
+while true; do
+	read -p "Continue? [y/N]" yn
+	case $yn in
+	[Yy]* ) break;;
+	[Nn]* ) echo Exiting; return 1;;
+	* ) echo "Please answer yes or no.";;
+esac
+done
+tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l)
+if [ ${tmuxwc} -eq 1 ]; then
+	echo -e "\e[0;31mWARNING!\e[0;39m ${servicename} is currently running"
+	while true; do
+		read -p "Would you like to stop ${servicename} while running the backup? [y/N]" yn
+		case $yn in
+		[Yy]* ) fn_stopserver; break;;
+		[Nn]* ) break;;
+		* ) echo "Please answer yes or no.";;
+	esac
+	done
+fi
+fn_printdots "Starting backup ${servicename}: ${servername}"
+sleep 1
+fn_printok "Starting backup ${servicename}: ${servername}"
+fn_scriptlog "Backup started"
+sleep 1
+echo -en "\n"
+cd "${rootdir}"
+mkdir -pv "${backupdir}" > /dev/null 2>&1
+tar -cvzf "${backupdir}/${backupname}.tar.gz" --exclude "${backupdir}" *
+echo -en "\r\033[K${servicename} Backup complete"
+fn_scriptlog "Backup complete"
+}
+
+fn_distro(){
+arch=$(uname -m)
+kernel=$(uname -r)
+if [ -f /etc/lsb-release ]; then
+	os=$(lsb_release -s -d)
+elif [ -f /etc/debian_version ]; then
+	os="Debian $(cat /etc/debian_version)"
+elif [ -f /etc/redhat-release ]; then
+	os=$(cat /etc/redhat-release)
+else
+	os="$(uname -s) $(uname -r)"
+fi
+}
+
+fn_uptime(){
+uptime=$(</proc/uptime)
+uptime=${uptime%%.*}
+minutes=$(( uptime/60%60 ))
+hours=$(( uptime/60/60%24 ))
+days=$(( uptime/60/60/24 ))
+}
+
+fn_load(){
+load=$(uptime|awk -F 'load average' '{ print $2 }')
+}
+
+fn_emailnotification(){
+fn_distro
+fn_uptime
+fn_load
+{
+	echo -e "========================================\n${servicename} details\n========================================\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 "Date: $(date)"
+	echo -e "Distro: ${os}"
+	echo -e "Arch: ${arch}"
+	echo -e "Kernel: ${kernel}"
+	echo -e "Hostname: $HOSTNAME"
+	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"
+}|tee "${scriptlogdir}/${servicename}-email.log" > /dev/null 2>&1
+tail -25 "${scriptlog}" >> "${emaillog}"
+if [ ! -z "${consolelog}" ]; then
+	echo -e "\n\nConsole log\n====================\n" >> "${emaillog}"
+	tail -25 "${consolelog}" >> "${emaillog}"
+fi
+if [ ! -z "${gamelogdir}" ]; then
+	echo -e "\n\nServer log\n====================\n" >> "${emaillog}"
+	tail "${gamelogdir}"/*|grep -v "==>"|sed '/^$/d'|tail -25 >> "${emaillog}"
+fi
+mail -s "${subject}" ${email} < "${emaillog}"
+fn_printinfo "Sent email notification to ${email}"
+fn_scriptlog "Sent email notification to ${email}"
+sleep 1
+echo -en "\n"
+}
+
+fn_emailtest(){
+fn_rootcheck
+fn_syscheck
+fn_scriptlog "Emailing test notification"
+if [ "${emailnotification}" = "on" ]; then
+	subject="${servicename} Email Test Notification - Testing ${servername}"
+	failurereason="Testing ${servicename} email notification"
+	actiontaken="Sent test email...hello is this thing on?"
+	fn_emailnotification
+else
+	fn_printfailnl "Email notification not enabled"
+	fn_scriptlog "Email notification not enabled"
+fi
+sleep 1
+echo -en "\n"
+}
+
+fn_serverquery(){
+# uses gsquery.py to directly query the server
+# detects if the server locks up
+if [ -f gsquery.py ]; then
+	if [ "${engine}" == "unreal" ]||[ "${engine}" == "unreal2" ]; then
+		gameport=$(grep Port= ${systemdir}/${ini}|grep -v Master|grep -v LAN|grep -v Proxy|grep -v Listen|sed 's/\Port=//g')
+		port=$((${gameport} + 1))
+	elif [ "${engine}" == "spark" ]; then
+		port=$((${port} + 1))
+	fi
+	fn_printinfo "Monitoring ${servicename}: Detected gsquery.py"
+	fn_scriptlog "Detected gsquery.py"
+	sleep 1
+	fn_printdots "Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING"
+	fn_scriptlog "Querying port: ${ip}:${port}: QUERYING"
+	sleep 1
+	serverquery=$(./gsquery.py -a ${ip} -p ${port} -e ${engine} 2>&1)
+	exitcode=$?
+	if [ "${exitcode}" == "1" ]||[ "${exitcode}" == "2" ]||[ "${exitcode}" == "3" ]||[ "${exitcode}" == "4" ]; then
+		fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: ${serverquery}"
+		sleep 1
+		echo -en "\n"
+		fn_scriptlog "Querying port: ${ip}:${port}: ${serverquery}"
+		if [[ -z "${secondquery}" ]]; then
+			fn_printinfo "Monitoring ${servicename}: Waiting 30 seconds to re-query"
+			fn_scriptlog "Waiting 30 seconds to re-query"
+			sleep 30
+			secondquery=1
+			fn_serverquery
+		fi
+		if [ "${emailnotification}" = "on" ]; then
+			subject="${servicename} Monitor - Starting ${servername}"
+			failurereason="Failed to query ${servicename}: ${serverquery}"
+			actiontaken="restarted ${servicename}"
+			fn_emailnotification
+		fi
+		fn_restartserver
+		exit
+	elif [ "${exitcode}" == "0" ]; then
+		fn_printok "Monitoring ${servicename}: Querying port: ${ip}:${port}: OK"
+		fn_scriptlog "Querying port: ${ip}:${port}: OK"
+		sleep 1
+		echo -en "\n"
+		exit
+	elif [ "${exitcode}" == "126" ]; then
+		fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: ERROR: ./gsquery.py: Permission denied"
+		fn_scriptlog "Querying port: ${ip}:${port}: ./gsquery.py: Permission denied"
+		sleep 1
+		echo -en "\n"
+		echo "Attempting to resolve automatically"
+		chmod +x -v gsquery.py
+		exitcode=$?
+		if [ "${exitcode}" == "0" ]; then
+			fn_serverquery
+		else
+			echo -en "\nUnable to resolve automatically. Please manually fix permissions\n"
+			owner=$(ls -al gsquery.py|awk '{ print $3 }')
+			echo "As user ${owner} or root run the following command"
+			whoami=$(whoami)
+			echo -en "\nchown ${whoami}:${whoami} gsquery.py\n\n"
+		exit
+		fi
+	else
+		fn_printfail "Monitoring ${servicename}: Querying port: ${ip}:${port}: UNKNOWN ERROR"
+		fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR"
+		sleep 1
+		echo -en "\n"
+		./gsquery.py -a ${ip} -p ${port} -e ${engine}
+		exit
+	fi
+fi
+}
+
+fn_monitorserver(){
+fn_rootcheck
+fn_syscheck
+fn_autoip
+fn_printdots "Monitoring ${servicename}: ${servername}"
+fn_scriptlog "Monitoring ${servername}"
+sleep 1
+if [ ! -f ${lockselfname} ]; then
+	fn_printinfo "Monitoring ${servicename}: No lock file found: Monitor disabled"
+	sleep 1
+	echo -en "\n"
+	echo "To enable monitor run ${selfname} start"
+	exit
+fi
+updatecheck=$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l)
+if [ "${updatecheck}" = "0" ]; then
+	fn_printdots "Monitoring ${servicename}: Checking session: CHECKING"
+	fn_scriptlog "Checking session: CHECKING"
+	sleep 1
+	tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l)
+	if [ ${tmuxwc} -eq 1 ]; then
+		fn_printok "Monitoring ${servicename}: Checking session: OK"
+		fn_scriptlog "Checking session: OK"
+		sleep 1
+		echo -en "\n"
+		fn_serverquery
+		exit
+	else
+		fn_printfail "Monitoring ${servicename}: Checking session: FAIL"
+		fn_scriptlog "Checking session: FAIL"
+		sleep 1
+		echo -en "\n"
+		if [ "${emailnotification}" = "on" ]; then
+			subject="${servicename} Monitor - Starting ${servername}"
+			failurereason="${servicename} process not running"
+			actiontaken="${servicename} has been restarted"
+			fn_emailnotification
+		fi
+		fn_scriptlog "Monitor is starting ${servername}"
+		fn_startserver
+	fi
+else
+	fn_printinfonl "Monitoring ${servicename}: Detected SteamCMD is checking for updates"
+	fn_scriptlog "Detected SteamCMD is checking for updates"
+	sleep 1
+	fn_printinfonl "Monitoring ${servicename}: When updates complete ${servicename} will start"
+	fn_scriptlog "When updates complete ${servicename} will start"
+	sleep 1
+fi
+}
+
+fn_updateserver(){
+fn_rootcheck
+fn_syscheck
+fn_printdots "Updating ${servicename}: ${servername}"
+sleep 1
+fn_printok "Updating ${servicename}: ${servername}"
+sleep 1
+fn_scriptlog "Updating ${servername}"
+cd "${rootdir}"
+cd "steamcmd"
+./steamcmd.sh +login ${steamuser} "${steampass}" +force_install_dir "${filesdir}" +app_update ${appid} +quit|tee -a "${scriptlog}"
+}
+
+fn_validateserver(){
+fn_rootcheck
+fn_syscheck
+fn_printwarn "Validating may overwrite some customised files."
+sleep 1
+echo -en "\n"
+echo -en "https://developer.valvesoftware.com/wiki/SteamCMD#Validate"
+sleep 5
+echo -en "\n"
+fn_printdots "Validating ${servicename}: ${servername}"
+sleep 1
+fn_printok "Validating ${servicename}: ${servername}"
+sleep 1
+fn_scriptlog "Validating ${servername}"
+cd "${rootdir}"
+cd "steamcmd"
+./steamcmd.sh +login ${steamuser} "${steampass}" +force_install_dir "${filesdir}" +app_update ${appid} validate +quit|tee -a "${scriptlog}"
+}
+
+fn_restartserver(){
+fn_scriptlog "Restarting ${servername}"
+fn_stopserver
+fn_startserver
+}
+
+fn_stopserver(){
+fn_rootcheck
+fn_syscheck
+pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l)
+fn_printdots "Stopping ${servicename}: ${servername}"
+fn_scriptlog "Stopping ${servername}"
+sleep 1
+if [ "${pid}" == "0" ]; then
+	fn_printfail "Stopping ${servicename}: ${servername} is already stopped"
+	fn_scriptlog "${servername} is already stopped"
+else
+	tmux kill-session -t ${servicename}
+	fn_printok "Stopping ${servicename}: ${servername}"
+	fn_scriptlog "Stopped ${servername}"
+fi
+# Remove lock file
+rm -f ${lockselfname}
+sleep 1
+echo -en "\n"
+}
+
+fn_startserver(){
+fn_rootcheck
+fn_syscheck
+fn_autoip
+fn_parms
+fn_logmanager
+tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l)
+if [ ${tmuxwc} -eq 0 ]; then
+	if [ "${engine}" == "unreal2" ]; then
+		mv "${gamelog}" "${gamelogdate}"
+	fi
+	mv "${scriptlog}" "${scriptlogdate}"
+	mv "${consolelog}" "${consolelogdate}"
+fi
+fn_printdots "Starting ${servicename}: ${servername}"
+sleep 1
+fn_scriptlog "Starting ${servername}"
+if [ ${tmuxwc} -eq 1 ]; then
+	fn_printinfo "Starting ${servicename}: ${servername} is already running"
+	fn_scriptlog "${servername} is already running"
+	sleep 1
+	echo -en "\n"
+	exit
+fi
+# Create lock file
+date > "${rootdir}/${lockselfname}"
+cd "${executabledir}"
+tmux new-session -d -s ${servicename} "${executable} ${parms}"
+tmux pipe-pane -o -t ${servicename} "exec cat >> '${consolelog}'"
+sleep 1
+tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l)
+if [ ${tmuxwc} -eq 0 ]; then
+	fn_printfail "Starting ${servicename}: Failed to start ${servername}"
+	fn_scriptlog "failed to start ${servername}"
+else
+	fn_printok "Starting ${servicename}: ${servername}"
+	fn_scriptlog "Started ${servername}"
+fi
+sleep 1
+echo -en "\n"
+}
+
+fn_details(){
+fn_autoip
+servername=$(grep -s hostname "${servercfgfullpath}"|sed 's/hostname //g'|sed 's/"//g')
+rcon=$(grep -s rcon_password "${servercfgfullpath}"|sed 's/rcon_password //g'|sed 's/"//g')
+pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l)
+echo ""
+echo "${gamename} Server Details"
+echo "============================"
+echo "Server name: ${servername}"
+echo "Server IP: ${ip}:${port}"
+echo "RCON password: ${rcon}"
+echo "Config file: ${servercfgfullpath}"
+echo ""
+echo "${servername} Ports"
+echo "============================"
+echo "Ports the server is currently using."
+echo ""
+echo "DIRECTION	DESCRIPTION		PORT"
+echo "INBOUND		Game/RCON port		${port}"
+if [ ! -z ${sourcetvport} ]; then
+	echo "INBOUND		SourceTV port		${sourcetvport}"
+fi
+echo "OUTBOUND	Client port		${clientport}"
+echo ""
+echo "You can change ports by editing the"
+echo "start parameters in ${selfname}."
+echo ""
+if [ "${pid}" == "0" ]; then
+	echo -e "Status:\e[0;31m OFFLINE\e[0;39m"
+else
+	echo -e "Status:\e[0;32m ONLINE\e[0;39m"
+fi
+echo ""
+}
+
+#
+## Installer
+#
+
+fn_header(){
+clear
+echo "================================="
+echo "${gamename}"
+echo "Linux Game Server Manager"
+echo "by Daniel Gibbs"
+echo "http://danielgibbs.co.uk"
+echo "================================="
+echo ""
+}
+
+fn_steamdl(){
+echo "Installing SteamCMD"
+echo "================================="
+cd "${rootdir}"
+mkdir -pv "steamcmd"
+sleep 1
+cd "steamcmd"
+if [ ! -f steamcmd.sh ]; then
+	wget -nv -N http://media.steampowered.com/client/steamcmd_linux.tar.gz
+	tar --verbose -zxf steamcmd_linux.tar.gz
+	rm -v steamcmd_linux.tar.gz
+	chmod +x steamcmd.sh
+	sleep 1
+else
+	echo ""
+	echo "Steam already installed!"
+fi
+sleep 1
+echo ""
+}
+
+fn_steaminstall(){
+echo "Installing ${gamename} Server"
+echo "================================="
+sleep 1
+mkdir -pv "${filesdir}"
+cd "${rootdir}/steamcmd"
+STEAMEXE=steamcmd ./steamcmd.sh +login ${steamuser} "${steampass}" +force_install_dir "${filesdir}" +app_update ${appid} validate +quit
+echo ""
+echo "================================="
+while true; do
+	read -p "Was the install successful? [y/N]" yn
+	case $yn in
+	[Yy]* ) break;;
+	[Nn]* ) fn_retryinstall;;
+	* ) echo "Please answer yes or no.";;
+	esac
+done
+echo ""
+}
+
+fn_steamfix(){
+echo "Applying steamclient.so fix"
+echo "================================="
+sleep 1
+mkdir -pv "${HOME}/.steam"
+mkdir -pv "${HOME}/.steam/sdk32"
+cp -v "${rootdir}/steamcmd/linux32/steamclient.so" "${HOME}/.steam/sdk32/steamclient.so"
+sleep 1
+echo ""
+}
+
+fn_loginstall(){
+echo "Creating log directorys"
+echo "================================="
+sleep 1
+mkdir -pv "${rootdir}/log"
+mkdir -pv "${scriptlogdir}"
+touch "${scriptlog}"
+mkdir -pv "${consolelogdir}"
+touch "${consolelog}"
+if [ ! -h ${rootdir}/log/server ]; then
+	ln -sv "${gamelogdir}" "${rootdir}/log/server"
+else
+	echo "Symbolic link ${gamelogdir} => ${rootdir}/log/server already exists!"
+fi
+sleep 1
+echo ""
+}
+
+fn_getquery(){
+	echo "GameServerQuery"
+	echo "============================"
+	while true; do
+		read -p "Do you want to install GameServerQuery? [y/N]" yn
+		case $yn in
+		[Yy]* ) cd "${rootdir}"; wget -nv -N "http://danielgibbs.co.uk/dl/gsquery.py"; chmod +x gsquery.py; break;;
+		[Nn]* ) echo -e "Not installing GameServerQuery.";break;;
+		* ) echo "Please answer yes or no.";;
+	esac
+	done
+	echo ""
+}
+
+fn_retryinstall(){
+while true; do
+	read -p "Retry install? [y/N]" yn
+	case $yn in
+	[Yy]* ) fn_install; exit;;
+	[Nn]* ) echo Exiting; exit;;
+	* ) echo "Please answer yes or no.";;
+	esac
+done
+}
+
+fn_install(){
+fn_rootcheck
+fn_header
+if [ -d "${filesdir}" ]; then
+	echo "${gamename} Server is already installed here:"
+	pwd
+	echo ""
+	while true; do
+		read -p "Continue [y/N]" yn
+		case $yn in
+		[Yy]* ) fn_header; break;;
+		[Nn]* ) echo Exiting; return 1;;
+		* ) echo "Please answer yes or no.";;
+		esac
+	done
+fi
+echo "Install Directory:"
+pwd
+echo ""
+while true; do
+	read -p "Continue [y/N]" yn
+	case $yn in
+	[Yy]* ) break;;
+	[Nn]* ) echo Exiting; return 1;;
+	* ) echo "Please answer yes or no.";;
+	esac
+done
+fn_header
+fn_steamdl
+fn_steaminstall
+fn_steamfix
+fn_loginstall
+fn_getquery
+echo "Configuring ${gamename} Server"
+echo "================================="
+	sleep 1
+	read -p "Enter server name: " servername
+	read -p "Enter rcon password: " rconpass
+	sleep 1
+	echo "Creating server.cfg."
+	touch "${defaultcfg}"
+	echo "exec ${servicename}.cfg" > "${defaultcfg}"
+	sleep 1
+	echo "Creating ${servicename}.cfg config file."
+	touch "${servercfgfullpath}"
+	{
+		echo -e "// server name"
+		echo -e "hostname \"${servername}\""
+		echo -e ""
+		echo -e "// rcon passsword"
+		echo -e "rcon_password \"${rconpass}\""
+		echo -e ""
+		echo -e "// Server password"
+		echo -e "sv_password \"\""
+		echo -e ""
+		echo -e "// server logging"
+		echo -e "log on"
+		echo -e "sv_logbans 1"
+		echo -e "sv_logecho 1"
+		echo -e "sv_logfile 1"
+		echo -e "sv_log_onefile 0"
+	}|tee "${servercfgfullpath}" > /dev/null 2>&1
+	sleep 1
+	echo ""
+	fn_header
+	sleep 1
+	fn_details
+	sleep 1
+	echo "================================="
+	echo "Install Complete!"
+	echo ""
+	echo "To start server type:"
+	echo "${selfname} start"
+	echo ""
+}
+
+case "$1" in
+	start)
+		fn_startserver;;
+	stop)
+		fn_stopserver;;
+	restart)
+		fn_restartserver;;
+	update)
+		fn_updateserver;;
+	update-restart)
+		fn_stopserver
+		fn_updateserver
+		fn_startserver;;
+	validate)
+		fn_validateserver;;
+	validate-restart)
+		fn_stopserver
+		fn_validateserver
+		fn_startserver;;
+	monitor)
+		fn_monitorserver;;
+	email-test)
+		fn_emailtest;;
+	details)
+		fn_details;;
+	backup)
+		fn_backupserver;;
+	console)
+		fn_console;;
+	debug)
+		fn_debugserver;;
+	install)
+		fn_install;;
+	*)
+	echo "Usage: $0 {start|stop|restart|update|update-restart|validate|validate-restart|monitor|email-test|details|backup|console|debug|install}"
+	exit 1;;
+esac
+exit
\ No newline at end of file
diff --git a/TeamFortress2/tf2server b/TeamFortress2/tf2server
index 9bd7a5abf..369fa3a6f 100644
--- a/TeamFortress2/tf2server
+++ b/TeamFortress2/tf2server
@@ -200,11 +200,11 @@ fi
 }
 
 fn_debugserver(){
-if [ ! -f functions/fn_debugserver ]; then
+if [ ! -f ${rootdir}/functions/fn_debugserver ]; then
 	functionfile="fn_debugserver"
 	fn_fninstall
 fi
-source functions/fn_debugserver
+source ${rootdir}/functions/fn_debugserver
 }
 
 fn_console(){
@@ -609,11 +609,11 @@ echo -en "\n"
 }
 
 fn_details(){
-if [ ! -f functions/fn_details ]; then
+if [ ! -f ${rootdir}/functions/fn_details ]; then
 	functionfile="fn_details"
 	fn_fninstall
 fi
-source functions/fn_details
+source ${rootdir}/functions/fn_details
 }
 
 fn_fninstall(){
@@ -688,11 +688,11 @@ echo ""
 }
 
 fn_steamfix(){
-if [ ! -f functions/fn_steamfix ]; then
+if [ ! -f ${rootdir}/functions/fn_steamfix ]; then
 	functionfile="fn_steamfix"
 	fn_fninstall
 fi	
-source functions/fn_steamfix
+source ${rootdir}/functions/fn_steamfix
 }
 
 fn_loginstall(){
diff --git a/TeamFortressClassic/tfcserver b/TeamFortressClassic/tfcserver
index 9f6c4d3cd..6eb0092ae 100644
--- a/TeamFortressClassic/tfcserver
+++ b/TeamFortressClassic/tfcserver
@@ -199,11 +199,11 @@ fi
 }
 
 fn_debugserver(){
-if [ ! -f functions/fn_debugserver ]; then
+if [ ! -f ${rootdir}/functions/fn_debugserver ]; then
 	functionfile="fn_debugserver"
 	fn_fninstall
 fi
-source functions/fn_debugserver
+source ${rootdir}/functions/fn_debugserver
 }
 
 fn_console(){
@@ -608,11 +608,11 @@ echo -en "\n"
 }
 
 fn_details(){
-if [ ! -f functions/fn_details ]; then
+if [ ! -f ${rootdir}/functions/fn_details ]; then
 	functionfile="fn_details"
 	fn_fninstall
 fi
-source functions/fn_details
+source ${rootdir}/functions/fn_details
 }
 
 fn_fninstall(){
@@ -687,11 +687,11 @@ echo ""
 }
 
 fn_steamfix(){
-if [ ! -f functions/fn_steamfix ]; then
+if [ ! -f ${rootdir}/functions/fn_steamfix ]; then
 	functionfile="fn_steamfix"
 	fn_fninstall
 fi	
-source functions/fn_steamfix
+source ${rootdir}/functions/fn_steamfix
 }
 
 fn_loginstall(){
diff --git a/UnrealTournament2004/ut2k4server b/UnrealTournament2004/ut2k4server
index 0f6f4b441..fa8d22565 100644
--- a/UnrealTournament2004/ut2k4server
+++ b/UnrealTournament2004/ut2k4server
@@ -183,11 +183,11 @@ fi
 }
 
 fn_debugserver(){
-if [ ! -f functions/fn_debugserver ]; then
+if [ ! -f ${rootdir}/functions/fn_debugserver ]; then
 	functionfile="fn_debugserver"
 	fn_fninstall
 fi
-source functions/fn_debugserver
+source ${rootdir}/functions/fn_debugserver
 }
 
 fn_console(){
@@ -560,11 +560,11 @@ echo -en "\n"
 }
 
 fn_details(){
-if [ ! -f functions/fn_details ]; then
+if [ ! -f ${rootdir}/functions/fn_details ]; then
 	functionfile="fn_details"
 	fn_fninstall
 fi
-source functions/fn_details
+source ${rootdir}/functions/fn_details
 }
 
 fn_fninstall(){
diff --git a/UnrealTournament99/ut99server b/UnrealTournament99/ut99server
index 5dab9a716..130b0b058 100644
--- a/UnrealTournament99/ut99server
+++ b/UnrealTournament99/ut99server
@@ -180,11 +180,11 @@ fi
 }
 
 fn_debugserver(){
-if [ ! -f functions/fn_debugserver ]; then
+if [ ! -f ${rootdir}/functions/fn_debugserver ]; then
 	functionfile="fn_debugserver"
 	fn_fninstall
 fi
-source functions/fn_debugserver
+source ${rootdir}/functions/fn_debugserver
 }
 
 fn_console(){
@@ -557,11 +557,11 @@ echo -en "\n"
 }
 
 fn_details(){
-if [ ! -f functions/fn_details ]; then
+if [ ! -f ${rootdir}/functions/fn_details ]; then
 	functionfile="fn_details"
 	fn_fninstall
 fi
-source functions/fn_details
+source ${rootdir}/functions/fn_details
 }
 
 fn_fninstall(){