Sfoglia il codice sorgente

improvements to tmux version detection

https://github.com/GameServerManagers/LinuxGSM/pull/1378#issuecomment-287954517
Daniel Gibbs 8 anni fa
parent
commit
88e20faa8f
1 ha cambiato i file con 40 aggiunte e 23 eliminazioni
  1. 40 23
      lgsm/functions/command_start.sh

+ 40 - 23
lgsm/functions/command_start.sh

@@ -100,30 +100,47 @@ fn_start_tmux(){
 	cd "${executabledir}"
 	tmux new-session -d -x "${sessionheight}" -y "${sessionwidth}" -s "${servicename}" "${executable} ${parms}" 2> "${lgsmlogdir}/.${servicename}-tmux-error.tmp"
 
-	# tmux pipe-pane not supported in tmux versions < 1.6
-	if [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd '[:digit:]')" -lt "16" ] 2>/dev/null; then # Tmux compiled from source will not return a number, therefore bypass this check and trash the error
-		echo "Console logging disabled: Tmux => 1.6 required
-		https://gameservermanagers.com/tmux-upgrade
-		Currently installed: $(tmux -V)" > "${consolelog}"
-
-	# Console logging disabled: Bug in tmux 1.8 breaks logging
-	elif [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd '[:digit:]')" -eq "18" ] 2>/dev/null; then
-		echo "Console logging disabled: Bug in tmux 1.8 breaks logging
-		https://gameservermanagers.com/tmux-upgrade
-		Currently installed: $(tmux -V)" > "${consolelog}"
-
-	# Console logging enable or not set
-	elif [ "${consolelogging}" == "on" ]||[ -z "${consolelogging}" ]; then
-		touch "${consolelog}"
-		tmux pipe-pane -o -t "${servicename}" "exec cat >> '${consolelog}'"
-
-	# Console logging disabled
-	elif [ "${consolelogging}" == "off" ]; then
-		touch "${consolelog}"
-		cat "Console logging disabled by user" >> "{consolelog}"
-		fn_script_log_info "Console logging disabled by user"
+	# Create logfile
+	touch "${consolelog}"
+
+	# Get tmux version
+	tmuxversion="$(tmux -V|sed "s/tmux //"|sed -n '1 p')"
+	# Tmux compiled from source will return "master", therefore ignore it
+	if [ "$(tmux -V|sed "s/tmux //"|sed -n '1 p')" == "master" ]; then
+		fn_script_log "Tmux version: master (user compiled)"
+		echo "Tmux version: master (user compiled)" >> "${consolelog}"
+		if [ "${consolelogging}" == "on" ]||[ -z "${consolelogging}" ]; then
+			tmux pipe-pane -o -t "${servicename}" "exec cat >> '${consolelog}'"
+		fi
+	elif [ -n "${tmuxversion}" ]; then
+		# Get the digit version of tmux
+		tmuxversion="$(tmux -V|sed "s/tmux //"|sed -n '1 p'|tr -cd '[:digit:]')"
+		# tmux pipe-pane not supported in tmux versions < 1.6
+		if [ "${tmuxversion}" -lt "16" ]; then
+			echo "Console logging disabled: Tmux => 1.6 required
+			https://gameservermanagers.com/tmux-upgrade
+			Currently installed: $(tmux -V)" > "${consolelog}"
+
+		# Console logging disabled: Bug in tmux 1.8 breaks logging
+		elif [ "${tmuxversion}" -eq "18" ]; then
+			echo "Console logging disabled: Bug in tmux 1.8 breaks logging
+			https://gameservermanagers.com/tmux-upgrade
+			Currently installed: $(tmux -V)" > "${consolelog}"
+		# Console logging enable or not set
+		elif [ "${consolelogging}" == "on" ]||[ -z "${consolelogging}" ]; then
+			tmux pipe-pane -o -t "${servicename}" "exec cat >> '${consolelog}'"
+		fi
+	else
+		echo "Unable to detect tmux version" >> "${consolelog}"
+		fn_script_log_warn "Unable to detect tmux version"
 	fi
-	sleep 1
+
+# Console logging disabled
+if [ "${consolelogging}" == "off" ]; then
+	echo "Console logging disabled by user" >> "${consolelog}"
+	fn_script_log_info "Console logging disabled by user"
+fi
+sleep 1
 
 	# If the server fails to start
 	check_status.sh