Răsfoiți Sursa

Merge pull request #592 from dgibbs64/checks

Consistant checks
Daniel Gibbs 10 ani în urmă
părinte
comite
e85cd25251

+ 46 - 30
functions/check.sh

@@ -7,40 +7,56 @@ lgsm_version="271215"
 # Description: Overall function for managing checks.
 # Runs checks that will either halt on or fix an issue.
 
-fn_module_compare() {
-  local e
-  for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done
-  return 1
+array_contains () {
+	local seeking=$1; shift
+	local in=1
+	for element; do
+		if [ ${element} == ${seeking} ]; then
+			in=0
+			break
+		fi
+	done
+	return $in
 }
 
-
 check_root.sh
 
-if [ "${cmd}" != "install" ]; then
+if [ "${function_selfname}" != "command_install.sh" ]; then
 	check_systemdir.sh
 fi
 
-no_check_logs=( debug details install map-compressor )
-fn_module_compare "${cmd}" "${no_check_logs[@]}"
-if [ $? != 0 ]; then
-	check_logs.sh
-fi
-
-check_ip=( debug )
-fn_module_compare "${cmd}" "${no_check_logs[@]}"
-if [ $? != 0 ]; then
-	check_ip.sh
-fi
-
-check_ip=( debug )
-fn_module_compare "${cmd}" "${no_check_logs[@]}"
-if [ $? != 0 ]; then
-	check_steamuser.sh
-	check_steamcmd.sh
-fi
-
-check_ip=( start )
-fn_module_compare "${cmd}" "${no_check_logs[@]}"
-if [ $? != 0 ]; then
-	check_tmux.sh
-fi
+local allowed_commands_array=( command_backup.sh command_console.sh command_debug.sh command_details.sh command_unreal2_maps.sh command_ut99_maps.sh command_monitor.sh command_start.sh command_stop.sh update_check.sh command_validate.sh update_functions.sh command_email_test.sh )
+for allowed_command in "${allowed_commands_array[@]}"
+do
+	if [ "${allowed_command}" == "${function_selfname}" ]; then
+		check_logs.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
+	if [ "${allowed_command}" == "${function_selfname}" ]; then
+		check_ip.sh
+	fi
+done
+
+local allowed_commands_array=( command_debug.sh command_start.sh command_stop.sh update_check.sh command_validate.sh )
+for allowed_command in "${allowed_commands_array[@]}"
+do
+	if [ "${allowed_command}" == "${function_selfname}" ]; then
+		if [ "${gamename}" == "Unreal Tournament 99" ]||[ "${gamename}" == "Unreal Tournament 2004" ]||[ "${gamename}" == "Mumble" ]||[ "${gamename}" == "Teamspeak 3" ]; then
+			: # These servers do not require SteamCMD. Check is skipped.
+		else
+			check_steamcmd.sh
+		fi
+	fi
+done
+
+local allowed_commands_array=( command_console.sh command_start.sh command_stop.sh )
+for allowed_command in "${allowed_commands_array[@]}"
+do
+	if [ "${allowed_command}" == "${function_selfname}" ]; then
+		check_tmux.sh
+	fi
+done

+ 23 - 19
functions/check_ip.sh

@@ -7,25 +7,29 @@ lgsm_version="271215"
 # Description: Automatically identifies the server interface IP.
 # If multiple interfaces are detected the user will need to manualy set using ip="0.0.0.0".
 
-if [ ! -f "/bin/ip" ]; then
-	ipcommand="/sbin/ip"
+if [ "${gamename}" == "Teamspeak 3" ]; then
+	:
 else
-	ipcommand="ip"
-fi
-getip=$(${ipcommand} -o -4 addr|awk '{print $4}'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0)
-getipwc=$(${ipcommand} -o -4 addr|awk '{print $4}'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -vc 127.0.0)
-
-if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then
-	if [ "${getipwc}" -ge "2" ]; then
-		fn_printwarn "Multiple active network interfaces found.\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"
-		echo -en ""
-		echo -en "http://gameservermanagers.com/network-interfaces"
-		echo -en ""
-		exit 1
+	if [ ! -f "/bin/ip" ]; then
+		ipcommand="/sbin/ip"
 	else
-		ip=${getip}
+		ipcommand="ip"
+	fi
+	getip=$(${ipcommand} -o -4 addr|awk '{print $4}'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0)
+	getipwc=$(${ipcommand} -o -4 addr|awk '{print $4}'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -vc 127.0.0)
+
+	if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then
+		if [ "${getipwc}" -ge "2" ]; then
+			fn_printwarn "Multiple active network interfaces found.\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"
+			echo -en ""
+			echo -en "http://gameservermanagers.com/network-interfaces"
+			echo -en ""
+			exit 1
+		else
+			ip=${getip}
+		fi
 	fi
-fi
+fi

+ 3 - 0
functions/check_root.sh

@@ -6,5 +6,8 @@ lgsm_version="271215"
 
 if [ $(whoami) = "root" ]; then
 	fn_printfailnl "Do NOT run this script as root!"
+	if [ -d "${scriptlogdir}" ]; then
+		fn_scriptlog "${selfname} attempted to run as root."
+	fi	
 	exit 1
 fi

+ 21 - 3
functions/check_steamcmd.sh

@@ -2,14 +2,32 @@
 # LGSM check_steamcmd.sh function
 # Author: Daniel Gibbs
 # Website: http://gameservermanagers.com
-lgsm_version="271215"
+lgsm_version="281215"
 
 # Description: Downloads SteamCMD on install and checks if missing before running functions that require SteamCMD
 
 
-if [ "${gamename}" == "Unreal Tournament 99" ]||[ "${gamename}" == "Unreal Tournament 2004" ]; then
+if [ "${gamename}" == "Unreal Tournament 99" ]||[ "${gamename}" == "Unreal Tournament 2004" ]||[ "${gamename}" == "Mumble" ]||[ "${gamename}" == "Teamspeak 3" ]; then
 	: # These servers do not require SteamCMD. Check is skipped.
-elif [ "${modulename}" == "Starting" ]||[ "${modulename}" == "Update" ]||[ "${modulename}" == "Validate" ]; then
+else
+	# Checks steamuser is setup. 
+	if [ "${steamuser}" == "username" ]; then
+	fn_printfailnl "Steam login not set. Update steamuser."	
+	echo "	* Change steamuser=\"username\" to a valid steam login."
+	if [ -d ${scriptlogdir} ]; then
+		fn_scriptlog "edit ${selfname}. change steamuser=\"username\" to a valid steam login."
+		exit 1
+	fi
+	fi
+	if [ -z "${steamuser}" ]; then
+		fn_printwarnnl "Steam login not set. Using anonymous login."
+		if [ -d "${scriptlogdir}" ]; then
+			fn_scriptlog "Steam login not set. Using anonymous login."
+		fi
+		steamuser="anonymous"
+		steampass=""
+		sleep 2
+	fi	
 	# Checks if SteamCMD exists when starting or updating a server.
 	# Re-installs if missing.
 	steamcmddir="${rootdir}/steamcmd"

+ 3 - 0
functions/check_systemdir.sh

@@ -6,5 +6,8 @@ lgsm_version="271215"
 
 if [ ! -d "${systemdir}" ]; then
 	fn_printfailnl "Cannot access ${systemdir}: No such directory"
+	if [ -d "${scriptlogdir}" ]; then
+		fn_scriptlog "Cannot access ${systemdir}: No such directory."
+	fi		
 	exit 1
 fi

+ 3 - 2
functions/command_backup.sh

@@ -7,8 +7,9 @@ lgsm_version="271215"
 # Description: Creates a .tar.gz file in the backup directory.
 
 local modulename="Backup"
-check_root.sh
-check_systemdir.sh
+function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+
+check.sh
 backupname="${servicename}-$(date '+%Y-%m-%d-%H%M%S')"
 echo ""
 echo "${gamename} Backup"

+ 3 - 3
functions/command_console.sh

@@ -7,8 +7,9 @@ lgsm_version="271215"
 # Description: Gives access to the server tmux console.
 
 local modulename="Console"
-check_root.sh
-check_systemdir.sh
+function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+
+check.sh
 echo ""
 echo "${gamename} Console"
 echo "============================"
@@ -26,7 +27,6 @@ esac
 done
 fn_printdots "Starting"
 sleep 1
-check_tmux.sh
 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -Ec "^${servicename}:")
 if [ "${tmuxwc}" -eq 1 ]; then
 	fn_printoknl "Starting"

+ 3 - 4
functions/command_debug.sh

@@ -7,10 +7,9 @@ lgsm_version="271215"
 # Description: Runs the server without tmux. Runs direct from the terminal.
 
 local modulename="Debug"
-check_root.sh
-check_systemdir.sh
-check_ip.sh
-check_logs.sh
+function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+
+check.sh
 info_distro.sh
 fn_parms
 echo ""

+ 25 - 148
functions/command_details.sh

@@ -6,6 +6,8 @@ lgsm_version="271215"
 
 # Description: Displays server infomation.
 
+function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+
 # Standard Details
 # This applies to all engines
 
@@ -106,7 +108,7 @@ printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
 	# online status
 	if [ "${gamename}" == "Teamspeak 3" ]; then
 		info_ts3status.sh
-		if [ "${ts3status}" = "Server seems to have died" ] || [ "${ts3status}"	= "No server running (ts3server.pid is missing)" ]; then
+		if [ "${ts3status}" = "Server seems to have died" ]||[ "${ts3status}"	= "No server running (ts3server.pid is missing)" ]; then
 			echo -e "\e[34mStatus:\t\e[0;31mOFFLINE\e[0m"
 		else
 			echo -e "\e[34mStatus:\t\e[0;32mONLINE\e[0m"
@@ -184,7 +186,7 @@ fn_details_backup(){
 echo -e ""
 echo -e "\e[92mBackups\e[0m"
 printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
-if [ ! -d "${backupdir}" ] || [ "${backupcount}" == "0" ]; then
+if [ ! -d "${backupdir}" ]||[ "${backupcount}" == "0" ]; then
 	echo -e "No Backups created"
 else
 	{
@@ -207,7 +209,7 @@ echo -e "${executable} ${parms}"
 fn_details_statusbottom(){
 echo -e ""
 if [ "${gamename}" == "Teamspeak 3" ]; then
-	if [ "${ts3status}" = "Server seems to have died" ] || [ "${ts3status}"	= "No server running (ts3server.pid is missing)" ]; then
+	if [ "${ts3status}" = "Server seems to have died" ]||[ "${ts3status}"	= "No server running (ts3server.pid is missing)" ]; then
         echo -e "\e[34mStatus: \e[0;31mOFFLINE\e[0m"
 	else
 		echo -e "\e[34mStatus: \e[0;32mONLINE\e[0m"
@@ -226,14 +228,6 @@ echo -e ""
 # Engine Specific details
 
 fn_details_avalanche(){
-check_ip.sh
-info_config.sh
-info_distro.sh
-fn_details_os
-fn_details_performance
-fn_details_disk
-fn_details_gameserver
-fn_details_backup
 echo -e ""
 echo -e "\e[92mPorts\e[0m"
 printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
@@ -252,14 +246,6 @@ fn_details_statusbottom
 }
 
 fn_details_dontstarve(){
-check_ip.sh
-info_config.sh
-info_distro.sh
-fn_details_os
-fn_details_performance
-fn_details_disk
-fn_details_gameserver
-fn_details_backup
 echo -e ""
 echo -e "\e[92mPorts\e[0m"
 printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
@@ -278,14 +264,6 @@ fn_details_statusbottom
 }
 
 fn_details_projectzomboid(){
-check_ip.sh
-info_config.sh
-info_distro.sh
-fn_details_os
-fn_details_performance
-fn_details_disk
-fn_details_gameserver
-fn_details_backup
 echo -e ""
 echo -e "\e[92mPorts\e[0m"
 printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
@@ -305,16 +283,6 @@ fn_details_statusbottom
 
 
 fn_details_realvirtuality(){
-check_ip.sh
-fn_parms
-info_config.sh
-info_distro.sh
-fn_details_os
-fn_details_performance
-fn_details_disk
-fn_details_gameserver
-fn_details_backup
-fn_details_commandlineparms
 echo -e ""
 echo -e "\e[92mPorts\e[0m"
 printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
@@ -324,7 +292,7 @@ echo -e ""
 echo -e "Useful port diagnostic command:"
 echo -e "netstat -atunp | grep arma3server"
 echo -e ""
-if [ -z "${port}" ] || [ -z "${queryport}" ] || [ -z "${masterport}" ]; then
+if [ -z "${port}" ]||[ -z "${queryport}" ]||[ -z "${masterport}" ]; then
 	echo -e "\e[0;31mERROR!\e[0m Missing/commented ports in ${servercfg}."
 	echo -e ""
 fi
@@ -339,16 +307,6 @@ fn_details_statusbottom
 }
 
 fn_details_seriousengine35(){
-check_ip.sh
-fn_parms
-info_config.sh
-info_distro.sh
-fn_details_os
-fn_details_performance
-fn_details_disk
-fn_details_gameserver
-fn_details_backup
-fn_details_commandlineparms
 echo -e ""
 echo -e "\e[92mPorts\e[0m"
 printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
@@ -368,16 +326,6 @@ fn_details_statusbottom
 }
 
 fn_details_source(){
-check_ip.sh
-fn_parms
-info_config.sh
-info_distro.sh
-fn_details_os
-fn_details_performance
-fn_details_disk
-fn_details_gameserver
-fn_details_backup
-fn_details_commandlineparms
 echo -e ""
 echo -e "\e[92mPorts\e[0m"
 printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
@@ -400,16 +348,6 @@ fn_details_statusbottom
 }
 
 fn_details_spark(){
-check_ip.sh
-fn_parms
-info_config.sh
-info_distro.sh
-fn_details_os
-fn_details_performance
-fn_details_disk
-fn_details_gameserver
-fn_details_backup
-fn_details_commandlineparms
 echo -e ""
 echo -e "\e[92mPorts\e[0m"
 printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
@@ -438,16 +376,6 @@ fn_details_statusbottom
 }
 
 fn_details_starbound(){
-check_ip.sh
-fn_parms
-info_config.sh
-info_distro.sh
-fn_details_os
-fn_details_performance
-fn_details_disk
-fn_details_gameserver
-fn_details_backup
-fn_details_commandlineparms
 echo -e ""
 echo -e "\e[92mPorts\e[0m"
 printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
@@ -469,14 +397,6 @@ fn_details_statusbottom
 }
 
 fn_details_teamspeak3(){
-info_config.sh
-info_distro.sh
-fn_details_os
-fn_details_performance
-fn_details_disk
-fn_details_gameserver
-fn_details_backup
-fn_details_commandlineparms
 echo -e ""
 echo -e "\e[92mPorts\e[0m"
 printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
@@ -497,16 +417,6 @@ fn_details_statusbottom
 }
 
 fn_details_teeworlds(){
-check_ip.sh
-fn_parms
-info_config.sh
-info_distro.sh
-fn_details_os
-fn_details_performance
-fn_details_disk
-fn_details_gameserver
-fn_details_backup
-fn_details_commandlineparms
 echo -e ""
 echo -e "\e[92mPorts\e[0m"
 printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
@@ -525,16 +435,6 @@ fn_details_statusbottom
 }
 
 fn_details_terraria(){
-check_ip.sh
-fn_parms
-info_config.sh
-info_distro.sh
-fn_details_os
-fn_details_performance
-fn_details_disk
-fn_details_gameserver
-fn_details_backup
-fn_details_commandlineparms
 echo -e ""
 echo -e "\e[92mPorts\e[0m"
 printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
@@ -555,16 +455,6 @@ fn_details_statusbottom
 }
 
 fn_details_sdtd(){
-fn_check_ip.sh
-fn_parms
-info_config.sh
-info_distro.sh
-fn_details_os
-fn_details_performance
-fn_details_disk
-fn_details_gameserver
-fn_details_backup
-fn_details_commandlineparms
 echo -e ""
 echo -e "\e[92mPorts\e[0m"
 printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
@@ -602,16 +492,6 @@ fn_details_statusbottom
 }
 
 fn_details_hurtworld(){
-check_ip.sh
-fn_parms
-fn_details_config
-fn_details_distro
-fn_details_os
-fn_details_performance
-fn_details_disk
-fn_details_gameserver
-fn_details_backup
-fn_details_commandlineparms
 echo -e ""
 echo -e "\e[92mPorts\e[0m"
 printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
@@ -633,16 +513,6 @@ fn_details_statusbottom
 }
 
 fn_details_unreal(){
-check_ip.sh
-fn_parms
-info_config.sh
-info_distro.sh
-fn_details_os
-fn_details_performance
-fn_details_disk
-fn_details_gameserver
-fn_details_backup
-fn_details_commandlineparms
 echo -e ""
 echo -e "\e[92mPorts\e[0m"
 printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
@@ -690,16 +560,6 @@ fn_details_statusbottom
 }
 
 fn_details_ark(){
-check_ip.sh
-fn_parms
-info_config.sh
-info_distro.sh
-fn_details_os
-fn_details_performance
-fn_details_disk
-fn_details_gameserver
-fn_details_backup
-fn_details_commandlineparms
 echo -e ""
 echo -e "\e[92mPorts\e[0m"
 printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
@@ -718,6 +578,10 @@ echo -e ""
 fn_details_statusbottom
 }
 
+
+# Run checks and gathers details to display.
+check.sh 
+
 if [ ! -e "${servercfgfullpath}" ]; then
 	if [ "${gamename}" != "Hurtworld" ]; then
 		echo ""
@@ -734,8 +598,21 @@ if [ ! -e "${servercfgfullpath}" ]; then
 	fi
 fi
 
+info_config.sh
+info_distro.sh
 info_glibc.sh
+fn_details_os
+fn_details_performance
+fn_details_gameserver
+fn_details_backup
+# Some game servers do not have parms.
+if [ "${gamename}" != "Teamspeak 3" ]||[ "${engine}" != "avalanche" ]||[ "${engine}" != "dontstarve" ]||[ "${engine}" == "projectzomboid" ]; then
+	fn_parms
+	fn_details_commandlineparms
+fi
+
 
+# Display details depending on game or engine.
 if [ "${engine}" == "avalanche" ]; then
 	fn_details_avalanche
 elif [ "${engine}" == "dontstarve" ]; then
@@ -746,7 +623,7 @@ elif [ "${engine}" == "realvirtuality" ]; then
 	fn_details_realvirtuality
 elif [ "${engine}" == "seriousengine35" ]; then
 	fn_details_seriousengine35
-elif [ "${engine}" == "source" ] || [ "${engine}" == "goldsource" ]; then
+elif [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]; then
 	fn_details_source
 elif [ "${engine}" == "spark" ]; then
 	fn_details_spark
@@ -756,7 +633,7 @@ elif [ "${engine}" == "teeworlds" ]; then
 	fn_details_teeworlds
 elif [ "${engine}" == "terraria" ]; then
 	fn_details_terraria
-elif [ "${engine}" == "unreal" ] || [ "${engine}" == "unreal2" ]; then
+elif [ "${engine}" == "unreal" ]||[ "${engine}" == "unreal2" ]; then
 	fn_details_unreal
 elif [ "${gamename}" == "ARK: Survivial Evolved" ]; then
 	fn_details_ark

+ 3 - 1
functions/dev_debug.sh → functions/command_dev_debug.sh

@@ -2,7 +2,9 @@
 # LGSM dev_debug.sh function
 # Author: Daniel Gibbs
 # Website: http://gameservermanagers.com
-lgsm_version="271215"
+lgsm_version="281215"
+
+function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 if [ -f ".dev-debug" ]; then
 	rm .dev-debug

+ 3 - 2
functions/dev_detect_deps.sh → functions/command_dev_detect_deps.sh

@@ -7,8 +7,9 @@ lgsm_version="271215"
 # Description: Detects dependencies the server binary requires.
 
 local modulename="Backup"
-check_root.sh
-check_systemdir.sh
+function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+
+check.sh
 cd "${executabledir}"
 if [ "${executable}" ==  "./hlds_run" ]; then
 	executable=hlds_linux

+ 3 - 3
functions/email_test.sh → functions/command_email_test.sh

@@ -1,5 +1,5 @@
 #!/bin/bash
-# LGSM email_test.sh function
+# LGSM command_email_test.sh function
 # Author: Daniel Gibbs
 # Website: http://gameservermanagers.com
 lgsm_version="271215"
@@ -7,8 +7,8 @@ lgsm_version="271215"
 # Description: Sends a test email notification.
 
 local modulename="Email"
-check_root.sh
-check_systemdir.sh
+function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+check.sh
 info_config.sh
 if [ "${emailnotification}" = "on" ]; then
 	fn_scriptlog "Sending test notification"

+ 3 - 1
functions/command_install.sh

@@ -4,7 +4,9 @@
 # Website: http://gameservermanagers.com
 lgsm_version="271215"
 
-check_root.sh
+function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+
+check.sh
 install_header.sh
 install_serverdir.sh
 

+ 3 - 5
functions/command_monitor.sh

@@ -8,10 +8,10 @@ lgsm_version="271215"
 # then passes to monitor_gsquery.sh.
 
 local modulename="Monitor"
+function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 fn_monitor_teamspeak3(){
-check_root.sh
-check_systemdir.sh
+check.sh
 logs.sh
 fn_printdots "${servername}"
 fn_scriptlog "${servername}"
@@ -54,9 +54,7 @@ fn_restart
 }
 
 fn_monitor_tmux(){
-check_root.sh
-check_systemdir.sh
-check_ip.sh
+check.sh
 info_config.sh
 fn_printdots "${servername}"
 fn_scriptlog "${servername}"

+ 7 - 15
functions/command_start.sh

@@ -7,11 +7,10 @@ lgsm_version="271215"
 # Description: Starts the server.
 
 local modulename="Starting"
+function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 fn_start_teamspeak3(){
-check_root.sh
-check_systemdir.sh
-check_logs.sh
+check.sh
 info_ts3status.sh
 
 if [ "${ts3status}" != "Server is running" ]; then
@@ -59,7 +58,7 @@ cd "${executabledir}"
 ./ts3server_startscript.sh start inifile="${servercfgfullpath}" > /dev/null 2>&1
 sleep 1
 info_ts3status.sh
-if [ "${ts3status}" = "Server seems to have died" ] || [ "${ts3status}"	= "No server running (ts3server.pid is missing)" ]; then
+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"
@@ -73,10 +72,8 @@ echo -en "\n"
 }
 
 fn_start_tmux(){
-check_root.sh
-check_systemdir.sh
-check_ip.sh
-check_logs.sh
+check.sh
+
 if [ "${gamename}" == "Counter Strike: Global Offensive" ]; then
 	startfix=1
 	fix_csgo.sh
@@ -101,11 +98,6 @@ fi
 fn_printdots "${servername}"
 fn_scriptlog "${servername}"
 sleep 1
-check_tmux.sh
-
-if [ "${gamename}" != "Mumble" ]; then
-	check_steamcmd.sh
-fi
 
 if [ "${tmuxwc}" -eq 0 ]; then
 	fn_scriptlog "Rotating log files"
@@ -145,11 +137,11 @@ sleep 1
 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -Ec "^${servicename}:")
 # If the server fails to start
 if [ "${tmuxwc}" -eq 0 ]; then
-	fn_printfail "Unable to start ${servername}"
+	fn_printfailnl "Unable to start ${servername}"
 	fn_scriptlog "Unable to start ${servername}"
 	sleep 1
 	if [ -s "${scriptlogdir}/.${servicename}-tmux-error.tmp" ]; then
-		fn_printfail "Unable to start ${servername}: Tmux error:"
+		fn_printfailnl "Unable to start ${servername}: Tmux error:"
 		fn_scriptlog "Tmux error"
 		sleep 1
 		echo -en "\n"

+ 3 - 6
functions/command_stop.sh

@@ -7,6 +7,7 @@ lgsm_version="271215"
 # Description: Stops the server.
 
 local modulename="Stopping"
+function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 sdtd_telnet(){
     sdtdshutdown=$( expect -c '
@@ -29,8 +30,7 @@ sdtd_telnet(){
 }
 
 fn_stop_teamspeak3(){
-check_root.sh
-check_systemdir.sh
+check.sh
 fn_printdots "${servername}"
 fn_scriptlog "${servername}"
 sleep 1
@@ -50,13 +50,11 @@ echo -en "\n"
 }
 
 fn_stop_tmux(){
-check_root.sh
-check_systemdir.sh
+check.sh
 info_config.sh
 fn_printdots "${servername}"
 fn_scriptlog "${servername}"
 sleep 1
-check_tmux.sh
 
 if [ "${gamename}" == "7 Days To Die" ] ; then
     # if game is 7 Days To Die, we need special, graceful shutdown via telnet connection.
@@ -70,7 +68,6 @@ if [ "${gamename}" == "7 Days To Die" ] ; then
     # If failed using localhost will use servers ip
     refused=$(echo -en "\n ${sdtdshutdown}"| grep "Timeout or EOF")
     if [ -n "${refused}" ]; then
-        check_ip.sh
         telnetip=${ip}
         fn_printwarn "Attempting graceful shutdown via telnet: localhost failed"
         fn_scriptlog "Warning! Attempting graceful shutdown failed using localhost"

+ 2 - 4
functions/command_validate.sh

@@ -7,10 +7,9 @@ lgsm_version="271215"
 # Description: Runs a server validation.
 
 local modulename="Validate"
+function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 fn_validation(){
-check_steamcmd.sh
-check_steamuser.sh	
 fn_printwarn "Validating may overwrite some customised files."
 sleep 1
 echo -en "\n"
@@ -42,8 +41,7 @@ fi
 fn_scriptlog "Checking complete"
 }
 
-check_root.sh
-check_systemdir.sh
+check.sh
 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -Ec "^${servicename}:")
 if [ "${tmuxwc}" -eq 1 ]; then
     command_stop.sh

+ 3 - 1
functions/compress_unreal2_maps.sh

@@ -4,7 +4,9 @@
 # Website: http://gameservermanagers.com
 lgsm_version="271215"
 
-check_root.sh
+function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+
+check.sh
 clear
 echo "${gamename} Map Compressor"
 echo "============================"

+ 3 - 1
functions/compress_ut99_maps.sh

@@ -4,7 +4,9 @@
 # Website: http://gameservermanagers.com
 lgsm_version="271215"
 
-check_root.sh
+function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+
+check.sh
 clear
 echo "${gamename} Map Compressor"
 echo "============================"

+ 7 - 8
functions/core_functions.sh

@@ -50,6 +50,11 @@ functionfile="${FUNCNAME}"
 fn_runfunction
 }
 
+command_email_test.sh(){
+functionfile="${FUNCNAME}"
+fn_runfunction
+}
+
 command_backup.sh(){
 functionfile="${FUNCNAME}"
 fn_runfunction
@@ -147,12 +152,12 @@ fn_runfunction
 
 # Dev
 
-dev_debug.sh(){
+command_dev_debug.sh(){
 functionfile="${FUNCNAME}"
 fn_runfunction
 }
 
-dev_detect_deps.sh(){
+command_dev_detect_deps.sh(){
 functionfile="${FUNCNAME}"
 fn_runfunction
 }
@@ -206,12 +211,6 @@ functionfile="${FUNCNAME}"
 fn_runfunction
 }
 
-email_test.sh(){
-functionfile="${FUNCNAME}"
-fn_runfunction
-}
-
-
 # Logs
 
 logs.sh(){

+ 23 - 26
functions/core_getopt.sh

@@ -26,7 +26,7 @@ case "$getopt" in
 	m|monitor)
 		command_monitor.sh;;
 	et|email-test)
-		email_test.sh;;
+		command_email_test.sh;;
 	d|details)
 		command_details.sh;;
 	b|backup)
@@ -36,13 +36,13 @@ case "$getopt" in
 	d|debug)
 		command_debug.sh;;
 	dev|dev-debug)
-		dev_debug.sh;;
+		command_dev_debug.sh;;
 	i|install)
 		command_install.sh;;
 	ai|auto-install)
 		fn_autoinstall;;
 	dd|depsdetect)
-		dev_detect_deps.sh;;
+		command_dev_detect_deps.sh;;
 	*)
 	echo "Usage: $0 [option]"
 	echo "${gamename} - Linux Game Server Manager - Version ${version}"
@@ -85,19 +85,19 @@ case "$getopt" in
 	m|monitor)
 		command_monitor.sh;;
 	et|email-test)
-		email_test.sh;;
+		command_email_test.sh;;
 	d|details)
 		command_details.sh;;
 	b|backup)
 		command_backup.sh;;
 	dev|dev-debug)
-		dev_debug.sh;;		
+		command_dev_debug.sh;;		
 	i|install)
 		command_install.sh;;
 	ai|auto-install)
 		fn_autoinstall;;
 	dd|depsdetect)
-		dev_detect_deps.sh;;
+		command_dev_detect_deps.sh;;
 	*)
 	echo "Usage: $0 [option]"
 	echo "${gamename} - Linux Game Server Manager - Version ${version}"
@@ -134,17 +134,17 @@ case "$getopt" in
 	m|monitor)
 		command_monitor.sh;;
 	et|email-test)
-		email_test.sh;;
+		command_email_test.sh;;
 	b|backup)
 		command_backup.sh;;
 	dev|dev-debug)
-		dev_debug.sh;;		
+		command_dev_debug.sh;;		
 	console)
 		command_console.sh;;
 	d|debug)
 		command_debug.sh;;
 	dd|depsdetect)
-		dev_detect_deps.sh;;
+		command_dev_detect_deps.sh;;
 	*)
 	echo "Usage: $0 [option]"
 	echo "${gamename} - Linux Game Server Manager - Version ${version}"
@@ -186,7 +186,7 @@ case "$getopt" in
 	m|monitor)
 		command_monitor.sh;;
 	et|email-test)
-		email_test.sh;;
+		command_email_test.sh;;
 	d|details)
 		command_details.sh;;
 	b|backup)
@@ -196,15 +196,13 @@ case "$getopt" in
 	d|debug)
 		command_debug.sh;;
 	dev|dev-debug)
-		dev_debug.sh;;		
+		command_dev_debug.sh;;		
 	i|install)
 		command_install.sh;;
 	ai|auto-install)
 		fn_autoinstall;;
 	dd|depsdetect)
-		dev_detect_deps.sh;;
-	gc|gmod-content)
-		fn_content_gmod;;
+		command_dev_detect_deps.sh;;
 	*)
 	echo "Usage: $0 [option]"
 	echo "${gamename} - Linux Game Server Manager - Version ${version}"
@@ -227,7 +225,6 @@ case "$getopt" in
 		echo -e "\e[34mdebug\t\e[0mSee the output of the server directly to your terminal."
 		echo -e "\e[34minstall\t\e[0mInstall the server."
 		echo -e "\e[34mauto-install\t\e[0mInstall the server, without prompts."
-		echo -e "\e[34mgmod-content\t\e[0mDownload gmod add-on content."
 	} | column -s $'\t' -t 
 	esac
 exit
@@ -246,7 +243,7 @@ case "$getopt" in
 	m|monitor)
 		command_monitor.sh;;
 	et|email-test)
-		email_test.sh;;
+		command_email_test.sh;;
 	d|details)
 		command_details.sh;;
 	b|backup)
@@ -256,13 +253,13 @@ case "$getopt" in
 	d|debug)
 		command_debug.sh;;
 	dev|dev-debug)
-		dev_debug.sh;;		
+		command_dev_debug.sh;;		
 	i|install)
 		command_install.sh;;
 	mc|map-compressor)
 		compress_ut99_maps.sh;;
 	dd|depsdetect)
-		dev_detect_deps.sh;;		
+		command_dev_detect_deps.sh;;		
 	*)
 	echo "Usage: $0 [option]"
 	echo "${gamename} - Linux Game Server Manager - Version ${version}"
@@ -308,7 +305,7 @@ case "$getopt" in
 	m|monitor)
 		command_monitor.sh;;
 	et|email-test)
-		email_test.sh;;
+		command_email_test.sh;;
 	d|details)
 		command_details.sh;;
 	b|backup)
@@ -318,13 +315,13 @@ case "$getopt" in
 	d|debug)
 		command_debug.sh;;
 	dev|dev-debug)
-		dev_debug.sh;;		
+		command_dev_debug.sh;;		
 	i|install)
 		command_install.sh;;
 	ai|auto-install)
 		fn_autoinstall;;
 	dd|depsdetect)
-		dev_detect_deps.sh;;
+		command_dev_detect_deps.sh;;
 	mc|map-compressor)
 		compress_unreal2_maps.sh;;
 	*)
@@ -369,7 +366,7 @@ case "$getopt" in
 	m|monitor)
 		command_monitor.sh;;
 	et|email-test)
-		email_test.sh;;
+		command_email_test.sh;;
 	d|details)
 		command_details.sh;;
 	b|backup)
@@ -379,13 +376,13 @@ case "$getopt" in
 	d|debug)
 		command_debug.sh;;
 	dev|dev-debug)
-		dev_debug.sh;;		
+		command_dev_debug.sh;;		
 	i|install)
 		command_install.sh;;
 	mc|map-compressor)
-		compress_ut99_maps.sh;;
+		compress_unreal2_maps.sh;;
 	dd|depsdetect)
-		dev_detect_deps.sh;;		
+		command_dev_detect_deps.sh;;		
 	*)
 	echo "Usage: $0 [option]"
 	echo "${gamename} - Linux Game Server Manager - Version ${version}"
@@ -411,7 +408,7 @@ exit
 }
 
 if [ "${gamename}" == "Mumble" ]; then
-	fn_getopt__mumble
+	fn_getopt_mumble
 elif [ "${gamename}" == "Teamspeak 3" ]; then
 	fn_getopt_teamspeak3
 elif [ "${engine}" == "unreal2" ]; then

+ 2 - 2
functions/info_config.sh

@@ -297,7 +297,7 @@ elif [ "${engine}" == "seriousengine35" ]; then
 	fn_servercfgfullpath
 
 # Source Engine Games
-elif [ "${engine}" == "source" ] || [ "${engine}" == "goldsource" ]; then
+elif [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]; then
 
 	# server name
 	if [ -f "${servercfgfullpath}" ]; then
@@ -635,7 +635,7 @@ elif [ "${gamename}" == "Hurtworld" ]; then
 	fi
 
 # Unreal Tournament 
-elif [ "${engine}" == "unreal" ] || [ "${engine}" == "unreal2" ]; then
+elif [ "${engine}" == "unreal" ]||[ "${engine}" == "unreal2" ]; then
 
 	# server name
 	if [ -f "${servercfgfullpath}" ]; then

+ 1 - 1
functions/install_serverfiles.sh

@@ -5,7 +5,7 @@
 lgsm_version="271215"
 
 fn_steaminstallcommand(){
-check_steamuser.sh
+check.sh
 counter="0"
 while [ "${counter}" == "0" ]||[ "$(grep -wc 0x402 .finstall_serverfiles.sh.tmp)" -ge "1" ]||[ "$(grep -wc 0x406 .finstall_serverfiles.sh.tmp)" -ge "1" ]||[ "$(grep -wc 0x6 .finstall_serverfiles.sh.tmp)" -ge "1" ]||[ "$(grep -wc 0x106 .finstall_serverfiles.sh.tmp)" -ge "1" ]; do
 	counter=$((counter+1))

+ 2 - 3
functions/update_check.sh

@@ -7,6 +7,7 @@ lgsm_version="271215"
 # Description: Checks if a server update is available.
 
 local modulename="Update"
+function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 ### SteamCMD Update Checker ###
 
@@ -102,8 +103,6 @@ fi
 }
 
 fn_steamcmdcheck(){
-check_steamcmd.sh
-check_steamuser.sh
 fn_appmanifestcheck
 # Checks for server update from SteamCMD
 fn_printdots "Checking for update: SteamCMD"
@@ -297,7 +296,7 @@ else
 fi
 }
 
-check_logs.sh
+check.sh
 fn_printdots "Checking for update"
 if [ "${gamename}" == "Teamspeak 3" ]; then
 	fn_teamspeak3_check

+ 8 - 17
functions/update_dl.sh

@@ -7,16 +7,9 @@ lgsm_version="271215"
 # Description: Runs a server update.
 
 local modulename="Update"
+function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
 
 fn_steamcmd_dl(){
-check_root.sh
-check_systemdir.sh
-info_config.sh
-fn_printdots "Updating ${servername}"
-sleep 1
-fn_printoknl "Updating ${servername}"
-fn_scriptlog "Updating ${servername}"
-sleep 1
 cd "${rootdir}"
 cd "steamcmd"
 
@@ -31,7 +24,6 @@ else
 	${unbuffer} ./steamcmd.sh +login "${steamuser}" "${steampass}" +force_install_dir "${filesdir}" +app_update "${appid}" +quit|tee -a "${scriptlog}"
 fi
 
-
 if [ "${gamename}" == "Counter Strike: Global Offensive" ]; then
 	echo -e '\n'
 	fix_csgo.sh
@@ -39,14 +31,6 @@ fi
 }
 
 fn_teamspeak3_dl(){
-check_root.sh
-check_systemdir.sh
-info_config.sh
-fn_printdots "Updating ${servername}"
-sleep 1
-fn_printoknl "Updating ${servername}"
-fn_scriptlog "Updating ${servername}"
-sleep 1
 cd "${rootdir}"
 echo -e "downloading teamspeak3-server_linux-${ts3arch}-${availablebuild}.tar.gz...\c"
 fn_scriptlog "Downloading teamspeak3-server_linux-${ts3arch}-${availablebuild}.tar.gz"
@@ -88,6 +72,13 @@ rm -f teamspeak3-server_linux-${ts3arch}-${availablebuild}.tar.gz
 rm -rf "${rootdir}/teamspeak3-server_linux-${ts3arch}"
 }
 
+check.sh
+info_config.sh
+fn_printdots "Updating ${servername}"
+sleep 1
+fn_printoknl "Updating ${servername}"
+fn_scriptlog "Updating ${servername}"
+sleep 1
 if [ "${gamename}" == "Teamspeak 3" ]; then
 	fn_teamspeak3_dl
 else

+ 2 - 0
functions/update_functions.sh

@@ -6,6 +6,8 @@ lgsm_version="271215"
 
 # Description: Deletes the functions dir to allow re-downloading of functions from GitHub.
 
+function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
+check.sh
 fn_printdots "Updating functions"
 fn_scriptlog "Updating functions"
 sleep 1