Przeglądaj źródła

Merge pull request #1138 from GameServerManagers/development

tmuxception and mumble fixes + cleaning
UltimateByte 9 lat temu
rodzic
commit
2f2c370ce2

+ 1 - 1
Mumble/mumbleserver

@@ -59,7 +59,7 @@ filesdir="${rootdir}/serverfiles"
 systemdir="${filesdir}"
 executabledir="${filesdir}"
 executable="./murmur.x86"
-servercfg="murmur.ini"
+servercfg="${servicename}.ini"
 servercfgdefault="murmur.ini"
 servercfgdir="${filesdir}"
 servercfgfullpath="${servercfgdir}/${servercfg}"

+ 1 - 0
lgsm/functions/check.sh

@@ -11,6 +11,7 @@ local commandname="CHECK"
 # check.sh selects which checks to run by using arrays
 
 check_root.sh
+check_tmuxception.sh
 check_permissions.sh
 
 if [ "${function_selfname}" != "command_install.sh" ]&&[ "${function_selfname}" != "command_update_functions.sh" ]; then

+ 48 - 4
lgsm/functions/check_permissions.sh

@@ -3,7 +3,7 @@
 # Author: Daniel Gibbs
 # Contributor: UltimateByte
 # Website: https://gameservermanagers.com
-# Description: Checks ownership & permissions of scripts, files and folders.
+# Description: Checks ownership & permissions of scripts, files and directories.
 
 local commandname="CHECK"
 local function_selfname="$(basename $(readlink -f "${BASH_SOURCE[0]}"))"
@@ -66,7 +66,7 @@ fn_check_permissions(){
 
 	# Check rootdir permissions
 	if [ -n "${rootdir}" ]; then
-		# Get permission numbers on folder under the form 775
+		# Get permission numbers on directory under the form 775
 		rootdirperm="$(stat -c %a "${rootdir}")"
 		# Grab the first and second digit for user and group permission
 		userrootdirperm="${rootdirperm:0:1}"
@@ -74,12 +74,56 @@ fn_check_permissions(){
 		if [ "${userrootdirperm}" != "7" ] && [ "${grouprootdirperm}" != "7" ]; then
 			fn_print_fail_nl "Permissions issues found"
 			fn_script_log_fatal "Permissions issues found"
-			fn_print_information_nl "The following directorys does not have the correct permissions:"
-			fn_script_log_info "The following directorys does not have the correct permissions:"
+			fn_print_information_nl "The following directory does not have the correct permissions:"
+			fn_script_log_info "The following directory does not have the correct permissions:"
+			fn_script_log_info "${rootdir}"
 			ls -l "${rootdir}"
 			core_exit.sh
 		fi
 	fi
+	# Check if executable is executable and attempt to fix it
+	# First get executable name
+	execname="$(basename "${executable}")"
+	if [ -f "${executabledir}/${execname}" ]; then
+		# Get permission numbers on file under the form 775
+		execperm="$(stat -c %a "${executabledir}/${execname}")"
+		# Grab the first and second digit for user and group permission
+		userexecperm="${execperm:0:1}"
+		groupexecperm="${execperm:1:1}"
+		# Check for invalid user permission
+		if [ "${userexecperm}" == "0" ] || [ "${userexecperm}" == "2" ] || [ "${userexecperm}" == "4" ]  || [ "${userexecperm}" == "6" ]; then
+			# If user permission is invalid, then check for invalid group permissions
+			if [ "${groupexecperm}" == "0" ] || [ "${groupexecperm}" == "2" ] || [ "${groupexecperm}" == "4" ]  || [ "${groupexecperm}" == "6" ]; then
+				# If permission issues are found
+				fn_print_warn_nl "Permissions issue found"
+				fn_script_log_warn "Permissions issue found"
+				fn_print_information_nl "The following file is not executable:"
+				ls -l "${executabledir}/${execname}"
+				fn_script_log_info "The following file is not executable:"
+				fn_script_log_info "${executabledir}/${execname}"
+				fn_print_information_nl "Applying chmod u+x,g+x ${executabledir}/${execname}"
+				fn_script_log_info "Applying chmod u+x,g+x ${execperm}"
+				# Make the executable executable
+				chmod u+x,g+x "${executabledir}/${execname}"
+				# Second check to see if it's been successfully applied
+				# Get permission numbers on file under the form 775
+				execperm="$(stat -c %a "${executabledir}/${execname}")"
+				# Grab the first and second digit for user and group permission
+				userexecperm="${execperm:0:1}"
+				groupexecperm="${execperm:1:1}"
+				if [ "${userexecperm}" == "0" ] || [ "${userexecperm}" == "2" ] || [ "${userexecperm}" == "4" ]  || [ "${userexecperm}" == "6" ]; then
+					if [ "${groupexecperm}" == "0" ] || [ "${groupexecperm}" == "2" ] || [ "${groupexecperm}" == "4" ]  || [ "${groupexecperm}" == "6" ]; then
+					# If errors are still found
+					fn_print_fail_nl "The following file could not be set executable:"
+					ls -l "${executabledir}/${execname}"
+					fn_script_log_warn "The following file could not be set executable:"
+					fn_script_log_info "${executabledir}/${execname}"
+					core_exit.sh
+					fi
+				fi
+			fi
+		fi
+	fi
 }
 
 fn_check_ownership

+ 3 - 1
lgsm/functions/check_status.sh

@@ -21,9 +21,11 @@ if [ "${gamename}" == "TeamSpeak 3" ]; then
 	fi
 	
 elif [ "${gamename}" == "Mumble" ]; then
+	# Get config info
+	info_config.sh
 	# 1: Server is listening
 	# 0: Server is not listening, considered closed
-	mumblepid=$(netstat -nap  2>/dev/null | grep udp | grep 64738 | grep murmur | awk '{ print $6 }' | awk -F'/' '{ print $1 }')
+	mumblepid=$(netstat -nap  2>/dev/null | grep udp | grep ${port} | grep murmur | awk '{ print $6 }' | awk -F'/' '{ print $1 }')
 	if [ -z "${mumblepid}" ]; then
 		status=0
 	else

+ 32 - 0
lgsm/functions/check_tmuxception.sh

@@ -0,0 +1,32 @@
+#!/bin/bash
+# LGSM check_config.sh function
+# Author: Daniel Gibbs
+# Contributor: UltimateByte
+# Website: https://gameservermanagers.com
+# Description: Checks if run from tmux or screen
+
+local commandname="check"
+
+fn_check_is_in_tmux(){
+  if [ -n "${TMUX}" ];then
+		fn_print_fail_nl "tmuxception error: Sorry Cobb you cannot start a tmux session inside of a tmux session."
+		fn_script_log_fatal "tmuxception error: Attempted to start a tmux session inside of a tmux session."
+		fn_print_information_nl "LGSM creates a tmux session when starting the server."
+		echo "It is not possible to run a tmux session inside another tmux session"
+		echo "https://github.com/GameServerManagers/LinuxGSM/wiki/Tmux#tmuxception"
+		core_exit.sh
+	fi
+}
+fn_check_is_in_screen(){
+	if [ "$TERM" == "screen" ];then
+		fn_print_fail_nl "tmuxception error: Sorry Cobb you cannot start a tmux session inside of a screen session."
+		fn_script_log_fatal "tmuxception error: Attempted to start a tmux session inside of a screen session."
+		fn_print_information_nl "LGSM creates a tmux session when starting the server."
+		echo "It is not possible to run a tmux session inside screen session"
+		echo "https://github.com/GameServerManagers/LinuxGSM/wiki/Tmux#tmuxception"
+		core_exit.sh
+	fi
+}
+
+fn_check_is_in_tmux
+fn_check_is_in_screen

+ 12 - 12
lgsm/functions/command_fastdl.sh

@@ -3,7 +3,7 @@
 # Author: Daniel Gibbs
 # Contributor: UltimateByte
 # Website: https://gameservermanagers.com
-# Description: Creates a FastDL folder.
+# Description: Creates a FastDL directory.
 
 local commandname="FASTDL"
 local commandaction="FastDL"
@@ -52,7 +52,7 @@ fn_fastdl_init(){
 	done
 	fn_script_log "Initiating FastDL creation"
 
-	# Check and create folders
+	# Check and create directories
 	if [ ! -d "${webdir}" ]; then
 		echo ""
 		fn_print_info "Creating FastDL directories"
@@ -67,7 +67,7 @@ fn_fastdl_init(){
 		echo -en "\n"
 	fi
 	if [ ! -d "${fastdldir}" ]; then
-		# No folder, won't ask for removing old ones
+		# No directory, won't ask for removing old ones
 		newfastdl=1
 		fn_print_dots "Creating fastdl directory"
 		sleep 0.5
@@ -88,7 +88,7 @@ fn_fastdl_config(){
 	fn_script_log "Configuration"
 	sleep 2
 	echo -en "\n"
-	# Prompt for clearing old files if folder was already here
+	# Prompt for clearing old files if directory was already here
 	if [ -n "${newfastdl}" ] && [ "${newfastdl}" == "0" ]; then
 		fn_print_dots
 		while true; do
@@ -133,12 +133,12 @@ fn_fastdl_gmod_config(){
 fn_clear_old_fastdl(){
 	# Clearing old FastDL if user answered yes
 	if [ "${clearoldfastdl}" == "on" ]; then
-		fn_print_info "Clearing existing FastDL folder"
-		fn_script_log "Clearing existing FastDL folder"
+		fn_print_info "Clearing existing FastDL directory"
+		fn_script_log "Clearing existing FastDL directory"
 		sleep 0.5
 		rm -R "${fastdldir:?}"/*
-		fn_print_ok "Old FastDL folder cleared"
-		fn_script_log "Old FastDL folder cleared"
+		fn_print_ok "Old FastDL directory cleared"
+		fn_script_log "Old FastDL directory cleared"
 		sleep 1
 		echo -en "\n"
 	fi
@@ -152,7 +152,7 @@ fn_gmod_fastdl(){
 	sleep 1
 	echo -en "\n"
 
-	# No choice to cd to the directory, as find can't then display relative folder
+	# No choice to cd to the directory, as find can't then display relative directory
 	cd "${systemdir}"
 
 	# Map Files
@@ -221,7 +221,7 @@ fn_gmod_fastdl(){
 	# Going back to rootdir in order to prevent mistakes
 	cd "${rootdir}"
 
-	# Correct addons folder structure for FastDL
+	# Correct addons directory structure for FastDL
 	if [ -d "${fastdldir}/addons" ]; then
 		fn_print_info "Adjusting addons' file structure"
 		fn_script_log "Adjusting addon's file structure"
@@ -233,7 +233,7 @@ fn_gmod_fastdl(){
 		echo -en "\n"
 	fi
 
-	# Correct content that may be into a lua folder by mistake like some darkrpmodification addons
+	# Correct content that may be into a lua directory by mistake like some darkrpmodification addons
 	if [ -d "${fastdldir}/lua" ]; then
 		fn_print_dots "Typical DarkRP shit detected, fixing"
 		sleep 2
@@ -244,7 +244,7 @@ fn_gmod_fastdl(){
 	fi
 }
 
-# Generate lua file that will force download any file into the FastDL folder
+# Generate lua file that will force download any file into the FastDL directory
 fn_lua_fastdl(){
 	# Remove lua file if luaressource is turned off and file exists
 	echo ""

+ 3 - 1
lgsm/functions/command_stop.sh

@@ -245,8 +245,10 @@ fn_stop_teamspeak3(){
 }
 
 fn_stop_mumble(){
+	# Get needed port info
+	info_config.sh
 	fn_print_dots "Stopping ${servername}"
-	mumblepid=$(netstat -nap  2>/dev/null | grep udp | grep 64738 | grep murmur | awk '{ print $6 }' | awk -F'/' '{ print $1 }')
+	mumblepid=$(netstat -nap  2>/dev/null | grep udp | grep "${port}" | grep murmur | awk '{ print $6 }' | awk -F'/' '{ print $1 }')
 	kill ${mumblepid}
 	sleep 1
 	check_status.sh

+ 3 - 7
lgsm/functions/core_functions.sh

@@ -116,7 +116,7 @@ fn_fetch_core_dl
 }
 
 
-# Command
+# Commands
 
 command_console.sh(){
 functionfile="${FUNCNAME}"
@@ -258,7 +258,7 @@ functionfile="${FUNCNAME}"
 fn_fetch_function
 }
 
-check_tmux.sh(){
+check_tmuxception.sh(){
 functionfile="${FUNCNAME}"
 fn_fetch_function
 }
@@ -299,6 +299,7 @@ functionfile="${FUNCNAME}"
 fn_fetch_function
 }
 
+
 # Fix
 
 fix.sh(){
@@ -543,11 +544,6 @@ functionfile="${FUNCNAME}"
 fn_fetch_function
 }
 
-fix_ut99.sh(){
-functionfile="${FUNCNAME}"
-fn_fetch_function
-}
-
 # Calls the global Ctrl-C trap
 core_trap.sh
 

+ 4 - 1
lgsm/functions/core_getopt.sh

@@ -300,6 +300,8 @@ case "${getopt}" in
 		command_backup.sh;;
 	dev|dev-debug)
 		command_dev_debug.sh;;
+	c|console)
+		command_console.sh;;
 	i|install)
 		command_install.sh;;
 	dd|detect-deps)
@@ -329,6 +331,7 @@ case "${getopt}" in
 		echo -e "${blue}details\t${default}dt |Displays useful information about the server."
 		echo -e "${blue}postdetails\t${default}pd |Post stripped details to pastebin (for support)"
 		echo -e "${blue}backup\t${default}b  |Create archive of the server."
+		echo -e "${blue}debug\t${default}d  |See the output of the server directly to your terminal."
 		echo -e "${blue}install\t${default}i  |Install the server."
 	} | column -s $'\t' -t
 	esac
@@ -405,7 +408,7 @@ case "${getopt}" in
 		echo -e "${blue}debug\t${default}d  |See the output of the server directly to your terminal."
 		echo -e "${blue}install\t${default}i  |Install the server."
 		echo -e "${blue}auto-install\t${default}ai |Install the server, without prompts."
-		echo -e "${blue}fastdl\t${default}fd |Generates or update a FastDL folder for your server."
+		echo -e "${blue}fastdl\t${default}fd |Generates or update a FastDL directory for your server."
 	} | column -s $'\t' -t
 	esac
 }

+ 7 - 3
lgsm/functions/install_config.sh

@@ -39,8 +39,8 @@ fn_set_config_vars(){
 # Checks if cfg dir exists, creates it if it doesn't
 fn_check_cfgdir(){
 	if [ ! -d "${servercfgdir}" ]; then
-		echo "creating ${servercfgdir} config folder."
-		fn_script_log_info "creating ${servercfgdir} config folder."
+		echo "creating ${servercfgdir} config directory."
+		fn_script_log_info "creating ${servercfgdir} config directory."
 		mkdir -pv "${servercfgdir}"
 	fi
 }
@@ -270,7 +270,11 @@ elif [ "${gamename}" == "No More Room in Hell" ]; then
 	fn_default_config_remote
 	fn_set_config_vars
 elif [ "${gamename}" == "Mumble" ]; then
-	:
+	gamedirname="Mumble"
+	array_configs+=( murmur.ini )
+	fn_fetch_default_config
+	fn_default_config_remote
+	fn_set_config_vars
 elif [ "${gamename}" == "Natural Selection 2" ]; then
 	:
 elif [ "${gamename}" == "NS2: Combat" ]; then

+ 2 - 2
lgsm/functions/logs.sh

@@ -15,7 +15,7 @@ if [ -n "${consolelog}" ]; then
 	fi
 fi
 
-# For games not displaying a console, and having logs into their game folder
+# For games not displaying a console, and having logs into their game directory
 if [ "${function_selfname}" == "command_start.sh" ] && [ -n "${gamelogfile}" ]; then
 	if [ -n "$(find "${systemdir}" -name "gamelog*.log")" ]; then
 		fn_print_info "Moving game logs to ${gamelogdir}"
@@ -86,7 +86,7 @@ if [ $(find "${scriptlogdir}"/ -type f -mtime +"${logdays}"|wc -l) -ne "0" ]; th
 		find "${legacyserverlogdir}"/ -type f -mtime +"${logdays}"| tee >> "${scriptlog}"
 		legacycount=$(find "${legacyserverlogdir}"/ -type f -mtime +"${logdays}"|wc -l)
 		find "${legacyserverlogdir}"/ -mtime +"${logdays}" -type f -exec rm -f {} \;
-		# Remove folder if empty
+		# Remove directory if empty
 		if [ ! "$(ls -A "${legacyserverlogdir}")" ]; then
 		rm -rf "${legacyserverlogdir}"
 		fi