diff --git a/net/config_2g3g b/net/config_2g3g index ab6c2a2..95d8290 100644 --- a/net/config_2g3g +++ b/net/config_2g3g @@ -1,5 +1,5 @@ # Terminal for launching Osmocom programs -# Supported: auto, urxvt, xterm +# Supported: auto, urxvt, xterm, tmux TERMINAL="auto" ETH_DEV=eth0 diff --git a/net/templates/run.sh b/net/templates/run.sh index 19e7e9b..a611926 100755 --- a/net/templates/run.sh +++ b/net/templates/run.sh @@ -1,5 +1,13 @@ #!/usr/bin/env bash +# tmux: start this script inside a new session +tmux_session="CN" +if [ "${TERMINAL}" = "tmux" ] && [ "$1" != "inside-tmux" ]; then + echo "Starting tmux session '$tmux_session'" + unset TMUX + exec tmux new-session -s "$tmux_session" -n "RUN" "$0" "inside-tmux" +fi + if ! ../fill_config.py --check-stale; then echo echo "WARNING: STALE CONFIGS - your net configs are older than the templates they should be based on!" @@ -46,7 +54,7 @@ mkdir -p "$logdir" "$piddir" "$wrapperdir" find_term() { # Find a terminal program and write to the global "terminal" variable - local programs="urxvt xterm" + local programs="urxvt xterm tmux" if [ -n "${TERMINAL}" ] && [ "${TERMINAL}" != "auto" ]; then case " $programs " in @@ -122,12 +130,19 @@ done EOF chmod +x "$wrapper" - $terminal \ - -title "CN:$title" \ - -e sh -c "$wrapper" \ - & + case "$terminal" in + tmux) + tmux new-window -d -n "$title" "$wrapper &; echo \$! > $pidfile_term; fg; wait" + ;; + *) + $terminal \ + -title "CN:$title" \ + -e sh -c "$wrapper" \ + & - echo "$!" > "$pidfile_term" + echo "$!" > "$pidfile_term" + ;; + esac } kill_pids() {