osmith has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-dev/+/27036 )

Change subject: net: run.sh: support tmux as terminal
......................................................................

net: run.sh: support tmux as terminal

Create one tmux session, with each Osmocom program in one window, if
tmux is chosen as "terminal". This allows using osmo-dev's run.sh over
ssh without X forwarding. Also the existing supported terminals
automatically scroll to the bottom as soon as there is new output,
making it hard to read logs.

Change-Id: Iaef08fb3cb3c6f58cd8490a631e177a03af9c974
---
M net/config_2g3g
M net/templates/run.sh
2 files changed, 22 insertions(+), 7 deletions(-)

Approvals:
  osmith: Looks good to me, approved; Verified



diff --git a/net/config_2g3g b/net/config_2g3g
index a46f55e..e50d13c 100644
--- a/net/config_2g3g
+++ b/net/config_2g3g
@@ -1,5 +1,5 @@
 # Terminal for launching Osmocom programs
-# Supported: urxvt, xterm
+# Supported: urxvt, xterm, tmux
 TERMINAL="urxvt"

 ETH_DEV=eth0
diff --git a/net/templates/run.sh b/net/templates/run.sh
index 332b168..1d78db5 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 @@

 find_term() {
   # Find a terminal program and write to the global "terminal" variable
-  local programs="urxvt xterm"
+  local programs="urxvt xterm tmux"

   if [ -z "${TERMINAL}" ]; then
     echo "ERROR: TERMINAL is not defined in your osmo-dev net config file. 
Please add it."
@@ -118,12 +126,19 @@
 EOF
   chmod +x "$launcher"

-  $terminal \
-    -title "CN:$title" \
-    -e sh -c "$launcher" \
-    &
+  case "$terminal" in
+    tmux)
+      tmux new-window -d -n "$title" "$launcher &; echo \$! > $pidfile_term; 
fg; wait"
+      ;;
+    *)
+      $terminal \
+        -title "CN:$title" \
+        -e sh -c "$launcher" \
+        &

-  echo "$!" > "$pidfile_term"
+      echo "$!" > "$pidfile_term"
+      ;;
+  esac
 }

 kill_pids() {

--
To view, visit https://gerrit.osmocom.org/c/osmo-dev/+/27036
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-dev
Gerrit-Branch: master
Gerrit-Change-Id: Iaef08fb3cb3c6f58cd8490a631e177a03af9c974
Gerrit-Change-Number: 27036
Gerrit-PatchSet: 2
Gerrit-Owner: osmith <osm...@sysmocom.de>
Gerrit-Reviewer: neels <nhofm...@sysmocom.de>
Gerrit-Reviewer: osmith <osm...@sysmocom.de>
Gerrit-CC: fixeria <vyanits...@sysmocom.de>
Gerrit-MessageType: merged

Reply via email to