mirror of
https://github.com/GameServerManagers/LinuxGSM
synced 2026-08-18 20:23:04 -04:00
When connected to a server via ssh, and the server doesn't have the
proper terminfo, tmux will fail with 'unsupported terminal' errors.
These errors are not surfaced by the scripts, e.g. details, start,
stop, so they result in either silent failures or don't work at all.
e.g. `./mcserver details` on my server showed 0% CPU, 0% Memory,
and STOPPED for the server status when the server was
actually running. This was because the tmux calls to get
this info failed.
The root cause of this was that I was connected to my server
via kitty, a terminal emulator that my server did not have
terminfo for.
This can be resolved via running `infocmp -x xterm-kitty | ssh
YOUR-SERVER -- tic -x -` and replacing `xterm-kitty` with whatever
is appropriate, or by setting TERM=xterm-256color in the ssh config,
but that is not obvious to do when presented with silent failures.
This commit sets TERM=screen for all non-interactive tmux calls,
which resolves the issue. Note that the `console` command does not
set this, as that is an interactive shell, and the user's terminfo
should be passed.
Co-authored-by: Daniel Gibbs <me@danielgibbs.co.uk>
37 lines
1.1 KiB
Bash
Executable file
37 lines
1.1 KiB
Bash
Executable file
#!/bin/bash
|
|
# LinuxGSM command_send.sh module
|
|
# Author: Daniel Gibbs
|
|
# Contributors: https://linuxgsm.com/contrib
|
|
# Website: https://linuxgsm.com
|
|
# Description: Send command to the server tmux console.
|
|
|
|
commandname="SEND"
|
|
commandaction="Send"
|
|
moduleselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
|
|
fn_firstcommand_set
|
|
|
|
check.sh
|
|
if [ -z "${userinput2}" ]; then
|
|
fn_print_header
|
|
fn_print_information_nl "Send a command to the console."
|
|
fi
|
|
|
|
check_status.sh
|
|
if [ "${status}" != "0" ]; then
|
|
if [ -n "${userinput2}" ]; then
|
|
commandtosend="${userinput2}"
|
|
else
|
|
echo ""
|
|
commandtosend=$(fn_prompt_message "send: ")
|
|
fi
|
|
echo ""
|
|
fn_print_dots "Sending command to console: \"${commandtosend}\""
|
|
fn_print_ok_nl "Sending command to console: \"${commandtosend}\""
|
|
TERM=screen tmux -L "${socketname}" send-keys -t "${sessionname}" "${commandtosend}" ENTER
|
|
fn_script_log_pass "Command \"${commandtosend}\" sent to console"
|
|
else
|
|
fn_print_error_nl "Unable to send command to console. Server not running"
|
|
fn_script_log_error "Unable to send command to console. Server not running"
|
|
fi
|
|
|
|
core_exit.sh
|