From 2cfb7e296d76acb164c93c2f0af8765365105e96 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Thu, 18 Jun 2020 22:07:43 +0100 Subject: [PATCH] sessionname port --- lgsm/functions/command_console.sh | 2 +- lgsm/functions/command_start.sh | 8 ++++---- lgsm/functions/command_stop.sh | 14 +++++++------- lgsm/functions/info_distro.sh | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lgsm/functions/command_console.sh b/lgsm/functions/command_console.sh index 18e674652..498d09d15 100644 --- a/lgsm/functions/command_console.sh +++ b/lgsm/functions/command_console.sh @@ -26,7 +26,7 @@ check_status.sh if [ "${status}" != "0" ]; then fn_print_ok_nl "Accessing console" fn_script_log_pass "Console accessed" - tmux attach-session -t "${sessionname}" + tmux attach-session -t "${sessionname}${port}" fn_print_ok_nl "Closing console" fn_script_log_pass "Console closed" else diff --git a/lgsm/functions/command_start.sh b/lgsm/functions/command_start.sh index ddcdadf2f..2ef56f77c 100644 --- a/lgsm/functions/command_start.sh +++ b/lgsm/functions/command_start.sh @@ -64,7 +64,7 @@ fn_start_tmux(){ # Create lockfile date '+%s' > "${lockdir}/${selfname}.lock" cd "${executabledir}" || exit - tmux new-session -d -x "${sessionwidth}" -y "${sessionheight}" -s "${sessionname} ${port}" "${executable} ${parms}" 2> "${lgsmlogdir}/.${selfname}-tmux-error.tmp" + tmux new-session -d -x "${sessionwidth}" -y "${sessionheight}" -s "${sessionname}${port}" "${executable} ${parms}" 2> "${lgsmlogdir}/.${selfname}-tmux-error.tmp" # Create logfile. touch "${consolelog}" @@ -79,7 +79,7 @@ fn_start_tmux(){ fn_script_log "Tmux version: master (user compiled)" echo -e "Tmux version: master (user compiled)" >> "${consolelog}" if [ "${consolelogging}" == "on" ]||[ -z "${consolelogging}" ]; then - tmux pipe-pane -o -t "${sessionname} ${port}" "exec cat >> '${consolelog}'" + tmux pipe-pane -o -t "${sessionname}${port}" "exec cat >> '${consolelog}'" fi elif [ "${tmuxversion}" ]; then # Get the digit version of tmux. @@ -97,7 +97,7 @@ fn_start_tmux(){ Currently installed: $(tmux -V)" > "${consolelog}" # Console logging enable or not set. elif [ "${consolelogging}" == "on" ]||[ -z "${consolelogging}" ]; then - tmux pipe-pane -o -t "${sessionname} ${port}" "exec cat >> '${consolelog}'" + tmux pipe-pane -o -t "${sessionname}${port}" "exec cat >> '${consolelog}'" fi else echo -e "Unable to detect tmux version" >> "${consolelog}" @@ -122,7 +122,7 @@ fn_start_tmux(){ echo -e "" echo -e "Command" echo -e "=================================" - echo -e "tmux new-session -d -s \"${sessionname} ${port}\" \"${executable} ${parms}\"" | tee -a "${lgsmlog}" + echo -e "tmux new-session -d -s \"${sessionname}${port}\" \"${executable} ${parms}\"" | tee -a "${lgsmlog}" echo -e "" echo -e "Error" echo -e "=================================" diff --git a/lgsm/functions/command_stop.sh b/lgsm/functions/command_stop.sh index 1ce7cc6bb..58a1e35d8 100644 --- a/lgsm/functions/command_stop.sh +++ b/lgsm/functions/command_stop.sh @@ -14,7 +14,7 @@ fn_stop_graceful_ctrlc(){ fn_print_dots "Graceful: CTRL+c" fn_script_log_info "Graceful: CTRL+c" # Sends quit. - tmux send-keys -t "${sessionname} ${port}" C-c > /dev/null 2>&1 + tmux send-keys -t "${sessionname}${port}" C-c > /dev/null 2>&1 # Waits up to 30 seconds giving the server time to shutdown gracefuly. for seconds in {1..30}; do check_status.sh @@ -42,7 +42,7 @@ fn_stop_graceful_cmd(){ fn_print_dots "Graceful: sending \"${1}\"" fn_script_log_info "Graceful: sending \"${1}\"" # Sends specific stop command. - tmux send -t "${sessionname} ${port}" "${1}" ENTER > /dev/null 2>&1 + tmux send -t "${sessionname}${port}" "${1}" ENTER > /dev/null 2>&1 # Waits up to ${seconds} seconds giving the server time to shutdown gracefully. for ((seconds=1; seconds<=${2}; seconds++)); do check_status.sh @@ -70,7 +70,7 @@ fn_stop_graceful_goldsrc(){ fn_print_dots "Graceful: sending \"quit\"" fn_script_log_info "Graceful: sending \"quit\"" # sends quit - tmux send -t "${sessionname} ${port}" quit ENTER > /dev/null 2>&1 + tmux send -t "${sessionname}${port}" quit ENTER > /dev/null 2>&1 # Waits 3 seconds as goldsrc servers restart with the quit command. for seconds in {1..3}; do sleep 1 @@ -183,10 +183,10 @@ fn_stop_graceful_avorion(){ fn_print_dots "Graceful: /save /stop" fn_script_log_info "Graceful: /save /stop" # Sends /save. - tmux send-keys -t "${sessionname} ${port}" /save ENTER > /dev/null 2>&1 + tmux send-keys -t "${sessionname}${port}" /save ENTER > /dev/null 2>&1 sleep 5 # Sends /quit. - tmux send-keys -t "${sessionname} ${port}" /stop ENTER > /dev/null 2>&1 + tmux send-keys -t "${sessionname}${port}" /stop ENTER > /dev/null 2>&1 # Waits up to 30 seconds giving the server time to shutdown gracefuly. for seconds in {1..30}; do check_status.sh @@ -233,9 +233,9 @@ fn_stop_graceful_select(){ fn_stop_tmux(){ fn_print_dots "${servername}" - fn_script_log_info "tmux kill-session: ${sessionname} ${port}: ${servername}" + fn_script_log_info "tmux kill-session: ${sessionname}${port}: ${servername}" # Kill tmux session. - tmux kill-session -t "${sessionname} ${port}" > /dev/null 2>&1 + tmux kill-session -t "${sessionname}${port}" > /dev/null 2>&1 sleep 0.5 check_status.sh if [ "${status}" == "0" ]; then diff --git a/lgsm/functions/info_distro.sh b/lgsm/functions/info_distro.sh index 1e2a519f4..78d12ad72 100644 --- a/lgsm/functions/info_distro.sh +++ b/lgsm/functions/info_distro.sh @@ -9,7 +9,7 @@ functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")" ### Game Server pid if [ "${status}" == "1" ]; then - gameserverpid=$(tmux list-sessions -F "#{session_name} #{pane_pid}" | grep "^${sessionname} " | awk '{print $2}') + gameserverpid=$(tmux list-sessions -F "#{session_name} #{pane_pid}" | grep "^${sessionname}${port} " | awk '{print $2}') fi ### Distro information