Browse Source

sessionname port

pull/2921/head
Daniel Gibbs 5 years ago
parent
commit
2cfb7e296d
  1. 2
      lgsm/functions/command_console.sh
  2. 8
      lgsm/functions/command_start.sh
  3. 14
      lgsm/functions/command_stop.sh
  4. 2
      lgsm/functions/info_distro.sh

2
lgsm/functions/command_console.sh

@ -26,7 +26,7 @@ check_status.sh
if [ "${status}" != "0" ]; then if [ "${status}" != "0" ]; then
fn_print_ok_nl "Accessing console" fn_print_ok_nl "Accessing console"
fn_script_log_pass "Console accessed" fn_script_log_pass "Console accessed"
tmux attach-session -t "${sessionname}" tmux attach-session -t "${sessionname}${port}"
fn_print_ok_nl "Closing console" fn_print_ok_nl "Closing console"
fn_script_log_pass "Console closed" fn_script_log_pass "Console closed"
else else

8
lgsm/functions/command_start.sh

@ -64,7 +64,7 @@ fn_start_tmux(){
# Create lockfile # Create lockfile
date '+%s' > "${lockdir}/${selfname}.lock" date '+%s' > "${lockdir}/${selfname}.lock"
cd "${executabledir}" || exit 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. # Create logfile.
touch "${consolelog}" touch "${consolelog}"
@ -79,7 +79,7 @@ fn_start_tmux(){
fn_script_log "Tmux version: master (user compiled)" fn_script_log "Tmux version: master (user compiled)"
echo -e "Tmux version: master (user compiled)" >> "${consolelog}" echo -e "Tmux version: master (user compiled)" >> "${consolelog}"
if [ "${consolelogging}" == "on" ]||[ -z "${consolelogging}" ]; then 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 fi
elif [ "${tmuxversion}" ]; then elif [ "${tmuxversion}" ]; then
# Get the digit version of tmux. # Get the digit version of tmux.
@ -97,7 +97,7 @@ fn_start_tmux(){
Currently installed: $(tmux -V)" > "${consolelog}" Currently installed: $(tmux -V)" > "${consolelog}"
# Console logging enable or not set. # Console logging enable or not set.
elif [ "${consolelogging}" == "on" ]||[ -z "${consolelogging}" ]; then 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 fi
else else
echo -e "Unable to detect tmux version" >> "${consolelog}" echo -e "Unable to detect tmux version" >> "${consolelog}"
@ -122,7 +122,7 @@ fn_start_tmux(){
echo -e "" echo -e ""
echo -e "Command" echo -e "Command"
echo -e "=================================" 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 ""
echo -e "Error" echo -e "Error"
echo -e "=================================" echo -e "================================="

14
lgsm/functions/command_stop.sh

@ -14,7 +14,7 @@ fn_stop_graceful_ctrlc(){
fn_print_dots "Graceful: CTRL+c" fn_print_dots "Graceful: CTRL+c"
fn_script_log_info "Graceful: CTRL+c" fn_script_log_info "Graceful: CTRL+c"
# Sends quit. # 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. # Waits up to 30 seconds giving the server time to shutdown gracefuly.
for seconds in {1..30}; do for seconds in {1..30}; do
check_status.sh check_status.sh
@ -42,7 +42,7 @@ fn_stop_graceful_cmd(){
fn_print_dots "Graceful: sending \"${1}\"" fn_print_dots "Graceful: sending \"${1}\""
fn_script_log_info "Graceful: sending \"${1}\"" fn_script_log_info "Graceful: sending \"${1}\""
# Sends specific stop command. # 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. # Waits up to ${seconds} seconds giving the server time to shutdown gracefully.
for ((seconds=1; seconds<=${2}; seconds++)); do for ((seconds=1; seconds<=${2}; seconds++)); do
check_status.sh check_status.sh
@ -70,7 +70,7 @@ fn_stop_graceful_goldsrc(){
fn_print_dots "Graceful: sending \"quit\"" fn_print_dots "Graceful: sending \"quit\""
fn_script_log_info "Graceful: sending \"quit\"" fn_script_log_info "Graceful: sending \"quit\""
# sends 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. # Waits 3 seconds as goldsrc servers restart with the quit command.
for seconds in {1..3}; do for seconds in {1..3}; do
sleep 1 sleep 1
@ -183,10 +183,10 @@ fn_stop_graceful_avorion(){
fn_print_dots "Graceful: /save /stop" fn_print_dots "Graceful: /save /stop"
fn_script_log_info "Graceful: /save /stop" fn_script_log_info "Graceful: /save /stop"
# Sends /save. # 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 sleep 5
# Sends /quit. # 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. # Waits up to 30 seconds giving the server time to shutdown gracefuly.
for seconds in {1..30}; do for seconds in {1..30}; do
check_status.sh check_status.sh
@ -233,9 +233,9 @@ fn_stop_graceful_select(){
fn_stop_tmux(){ fn_stop_tmux(){
fn_print_dots "${servername}" 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. # 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 sleep 0.5
check_status.sh check_status.sh
if [ "${status}" == "0" ]; then if [ "${status}" == "0" ]; then

2
lgsm/functions/info_distro.sh

@ -9,7 +9,7 @@ functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
### Game Server pid ### Game Server pid
if [ "${status}" == "1" ]; then 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 fi
### Distro information ### Distro information

Loading…
Cancel
Save