tmux support for Linux
**tmux Support for Linux**
The `run` script with `cos_117.cfg` spawns xterms for consoles, which works well on desktops but not on VPS/servers without X forwarding or for users preferring SSH/shell/mosh.
To resolve, this commit adds tmux support via:
+ run_tmux - Script that manages a cray simulator session.
+ cos_117_tmux.cfg - Modified config that spawns tmux windows instead of xterms.
Benefits:
- Organizes cray simulator and consoles as tmux windows in a tmux session.
- Allows attaching, detaching, and exiting without stopping the simulator.
- Console windows can be scripted to pass input / output for development.
Usage:
```
run_tmux start
run_tmux attach
or execute `run_tmux` and select from menu.
```
Full Usage:
```
Usage: run_tmux {start|stop|restart|kill|attach|status}
start - Start the Cray simulator session
stop - Stop the Cray simulator session
restart - Restart the Cray simulator session
kill - Kill the Cray simulator session (unsafe)
attach - Attach to the Cray simulator session
status - List running Cray simulator and consoles
Use keys 'Ctrl b <0 to ...>' to move to specific windows
Use keys 'Ctrl b n' to move to the next window
Use keys 'Ctrl b p' to move to the previous window
Use keys 'Ctrl b d' to detach from the simulator session.
```
Tests:
- The script was checked in shellcheck with minimal issues detected.
- Tested on Ubuntu 22.04.3 LTS (aarch64)
- Tested on Arch Linux (x86_64)
This commit is contained in:
parent
547be8ca89
commit
82b684e376
@ -169,7 +169,7 @@ IopClusters {
|
|||||||
Console {
|
Console {
|
||||||
TIChannelIdx 040
|
TIChannelIdx 040
|
||||||
TOChannelIdx 041
|
TOChannelIdx 041
|
||||||
NewTerminalCommand "tmux new-window -d -t cray -n cray_{port} '{cmd}'&"
|
NewTerminalCommand "tmux new-session -d -s cray_{port} -n cray_{port} '{cmd}'&"
|
||||||
ConsoleCommandLinux "telnet {host} {port}"
|
ConsoleCommandLinux "telnet {host} {port}"
|
||||||
ConsoleCommandWindows "putty.exe -load Unicos -telnet -P {port} {host}"
|
ConsoleCommandWindows "putty.exe -load Unicos -telnet -P {port} {host}"
|
||||||
MapBackspace yes
|
MapBackspace yes
|
||||||
@ -179,7 +179,7 @@ IopClusters {
|
|||||||
Console {
|
Console {
|
||||||
TIChannelIdx 042
|
TIChannelIdx 042
|
||||||
TOChannelIdx 043
|
TOChannelIdx 043
|
||||||
NewTerminalCommand "tmux new-window -d -t cray -n cray_{port} '{cmd}'&"
|
NewTerminalCommand "tmux new-session -d -s cray_{port} -n cray_{port} '{cmd}'&"
|
||||||
ConsoleCommandLinux "telnet {host} {port}"
|
ConsoleCommandLinux "telnet {host} {port}"
|
||||||
ConsoleCommandWindows "putty.exe -load Unicos -telnet -P {port} {host}"
|
ConsoleCommandWindows "putty.exe -load Unicos -telnet -P {port} {host}"
|
||||||
MapBackspace yes
|
MapBackspace yes
|
||||||
@ -189,7 +189,7 @@ IopClusters {
|
|||||||
Console {
|
Console {
|
||||||
TIChannelIdx 044
|
TIChannelIdx 044
|
||||||
TOChannelIdx 045
|
TOChannelIdx 045
|
||||||
NewTerminalCommand "tmux new-window -d -t cray -n cray_{port} '{cmd}'&"
|
NewTerminalCommand "tmux new-session -d -s cray_{port} -n cray_{port} '{cmd}'&"
|
||||||
ConsoleCommandLinux "telnet {host} {port}"
|
ConsoleCommandLinux "telnet {host} {port}"
|
||||||
ConsoleCommandWindows "putty.exe -load Unicos -telnet -P {port} {host}"
|
ConsoleCommandWindows "putty.exe -load Unicos -telnet -P {port} {host}"
|
||||||
MapBackspace yes
|
MapBackspace yes
|
||||||
@ -199,7 +199,7 @@ IopClusters {
|
|||||||
Console {
|
Console {
|
||||||
TIChannelIdx 046
|
TIChannelIdx 046
|
||||||
TOChannelIdx 047
|
TOChannelIdx 047
|
||||||
NewTerminalCommand "tmux new-window -d -t cray -n cray_{port} '{cmd}'&"
|
NewTerminalCommand "tmux new-session -d -s cray_{port} -n cray_{port} '{cmd}'&"
|
||||||
ConsoleCommandLinux "telnet {host} {port}"
|
ConsoleCommandLinux "telnet {host} {port}"
|
||||||
ConsoleCommandWindows "putty.exe -load Unicos -telnet -P {port} {host}"
|
ConsoleCommandWindows "putty.exe -load Unicos -telnet -P {port} {host}"
|
||||||
MapBackspace yes
|
MapBackspace yes
|
||||||
@ -275,7 +275,7 @@ IopClusters {
|
|||||||
Console {
|
Console {
|
||||||
TIChannelIdx 042
|
TIChannelIdx 042
|
||||||
TOChannelIdx 043
|
TOChannelIdx 043
|
||||||
NewTerminalCommand "tmux new-window -d -t cray -n cray_{port} '{cmd}'&"
|
NewTerminalCommand "tmux new-session -d -s cray_{port} -n cray_{port} '{cmd}'&"
|
||||||
ConsoleCommandLinux "telnet {host} {port}"
|
ConsoleCommandLinux "telnet {host} {port}"
|
||||||
ConsoleCommandWindows "putty.exe -load Unicos -telnet -P {port} {host}"
|
ConsoleCommandWindows "putty.exe -load Unicos -telnet -P {port} {host}"
|
||||||
MapBackspace yes
|
MapBackspace yes
|
||||||
@ -297,7 +297,7 @@ IopClusters {
|
|||||||
Console {
|
Console {
|
||||||
TIChannelIdx 042
|
TIChannelIdx 042
|
||||||
TOChannelIdx 043
|
TOChannelIdx 043
|
||||||
NewTerminalCommand "tmux new-window -d -t cray -n cray_{port} '{cmd}'&"
|
NewTerminalCommand "tmux new-session -d -s cray_{port} -n cray_{port} '{cmd}'&"
|
||||||
ConsoleCommandLinux "telnet {host} {port}"
|
ConsoleCommandLinux "telnet {host} {port}"
|
||||||
ConsoleCommandWindows "putty.exe -load Unicos -telnet -P {port} {host}"
|
ConsoleCommandWindows "putty.exe -load Unicos -telnet -P {port} {host}"
|
||||||
MapBackspace yes
|
MapBackspace yes
|
||||||
@ -441,7 +441,7 @@ IopClusters {
|
|||||||
Console {
|
Console {
|
||||||
TIChannelIdx 042
|
TIChannelIdx 042
|
||||||
TOChannelIdx 043
|
TOChannelIdx 043
|
||||||
NewTerminalCommand "tmux new-window -d -t cray -n cray_{port} '{cmd}'&"
|
NewTerminalCommand "tmux new-session -d -s cray_{port} -n cray_{port} '{cmd}'&"
|
||||||
ConsoleCommandLinux "telnet {host} {port}"
|
ConsoleCommandLinux "telnet {host} {port}"
|
||||||
ConsoleCommandWindows "putty.exe -load Unicos -telnet -P {port} {host}"
|
ConsoleCommandWindows "putty.exe -load Unicos -telnet -P {port} {host}"
|
||||||
MapBackspace yes
|
MapBackspace yes
|
||||||
|
|||||||
8
tmux_run → run_tmux
Normal file → Executable file
8
tmux_run → run_tmux
Normal file → Executable file
@ -1,7 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
PATH=$PATH:simulator/_bin/linux_release
|
PATH=$PATH:simulator/_bin/linux_release
|
||||||
|
|
||||||
# Usage message
|
|
||||||
usage() {
|
usage() {
|
||||||
cat << EOF
|
cat << EOF
|
||||||
|
|
||||||
@ -53,8 +52,10 @@ cray_is_up() {
|
|||||||
start_cray() {
|
start_cray() {
|
||||||
if cray_is_up; then msg "running"; else
|
if cray_is_up; then msg "running"; else
|
||||||
mkdir -p dump disk tape
|
mkdir -p dump disk tape
|
||||||
tmux new-session -d -s cray
|
tmux new-session -d -s cray
|
||||||
#space for future tmux hooks here
|
# Simplify the hooks, they could be error prone
|
||||||
|
tmux set-hook -t cray -g session-created 'run-shell "tmux list-sessions -F '#{session_name}' | grep '^cray_' | sort | while read -r session; do tmux move-window -s $session:0 -t cray:; done; tmux move-window -s cray:$(tmux list-windows -t cray | grep -n 'cray_sim' | cut -d: -f1) -t cray:0"'
|
||||||
|
tmux set-hook -t cray -g window-linked 'run-shell "tmux list-windows -t cray -F \"#{window_index}\" | awk '\''$1 != \"0\" {print \"tmux rename-window -t \" $1 \" console_\" NR-1}'\'' | bash"'
|
||||||
tmux send-keys -t cray 'cray_sim cos_117_tmux.cfg' C-m
|
tmux send-keys -t cray 'cray_sim cos_117_tmux.cfg' C-m
|
||||||
msg "started"
|
msg "started"
|
||||||
help
|
help
|
||||||
@ -96,7 +97,6 @@ restart_cray() {
|
|||||||
# Attach to the cray simulator session
|
# Attach to the cray simulator session
|
||||||
attach_cray() { if cray_is_up; then tmux attach-session -t cray; else msg "not_up"; fi }
|
attach_cray() { if cray_is_up; then tmux attach-session -t cray; else msg "not_up"; fi }
|
||||||
|
|
||||||
|
|
||||||
# Display status of cray simulator session and consoles
|
# Display status of cray simulator session and consoles
|
||||||
status_cray() {
|
status_cray() {
|
||||||
if cray_is_up; then
|
if cray_is_up; then
|
||||||
Loading…
x
Reference in New Issue
Block a user