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 <osmith(a)sysmocom.de>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-MessageType: merged
osmith has submitted this change. ( https://gerrit.osmocom.org/c/osmo-dev/+/27033 )
Change subject: net: require terminal to be configured
......................................................................
net: require terminal to be configured
Prepare to add "tmux" as new terminal. As discussed in code review, we
decided to drop support for auto-detection.
Change-Id: I0afb6b0242c399334a2c37f18a5d26d5beeabedc
---
M net/config_2g3g
M net/templates/run.sh
2 files changed, 24 insertions(+), 7 deletions(-)
Approvals:
osmith: Looks good to me, approved; Verified
diff --git a/net/config_2g3g b/net/config_2g3g
index c1498be..a46f55e 100644
--- a/net/config_2g3g
+++ b/net/config_2g3g
@@ -1,3 +1,7 @@
+# Terminal for launching Osmocom programs
+# Supported: urxvt, xterm
+TERMINAL="urxvt"
+
ETH_DEV=eth0
APN_DEV=apn0
diff --git a/net/templates/run.sh b/net/templates/run.sh
index 311cdd9..c2f42ee 100755
--- a/net/templates/run.sh
+++ b/net/templates/run.sh
@@ -44,14 +44,27 @@
find_term() {
# Find a terminal program and write to the global "terminal" variable
local programs="urxvt xterm"
- local program
- for program in $programs; do
- terminal="$(which $program)"
- [ -n "$terminal" ] && return
- done
- # No terminal found
- echo "ERROR: Couldn't find terminal program! Looked for: $programs"
+ if [ -z "${TERMINAL}" ]; then
+ echo "ERROR: TERMINAL is not defined in your osmo-dev net config file. Please add it."
+ exit 1
+ fi
+
+ case " $programs " in
+ *" ${TERMINAL} "*)
+ terminal="${TERMINAL}"
+
+ if command -v "$terminal" >/dev/null; then
+ echo "Terminal: ${TERMINAL}"
+ return
+ fi
+
+ echo "ERROR: Terminal '${TERMINAL}' is configured, but not installed"
+ exit 1
+ ;;
+ esac
+
+ echo "ERROR: Terminal '${TERMINAL}' is not in list of supported terminals ($programs)"
exit 1
}
--
To view, visit https://gerrit.osmocom.org/c/osmo-dev/+/27033
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-dev
Gerrit-Branch: master
Gerrit-Change-Id: I0afb6b0242c399334a2c37f18a5d26d5beeabedc
Gerrit-Change-Number: 27033
Gerrit-PatchSet: 2
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-MessageType: merged
osmith has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-dev/+/27267 )
Change subject: net/templates/run.sh: put log name in trace.pcap
......................................................................
Patch Set 1:
(1 comment)
Patchset:
PS1:
Neels said, let's merge. Here we go!
--
To view, visit https://gerrit.osmocom.org/c/osmo-dev/+/27267
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-dev
Gerrit-Branch: master
Gerrit-Change-Id: I7007d7c1e74aef46f1942f4f6f675adebb890955
Gerrit-Change-Number: 27267
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Comment-Date: Mon, 21 Feb 2022 13:01:43 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
osmith has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-dev/+/27267 )
Change subject: net/templates/run.sh: put log name in trace.pcap
......................................................................
Patch Set 1: Verified+1 Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/osmo-dev/+/27267
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-dev
Gerrit-Branch: master
Gerrit-Change-Id: I7007d7c1e74aef46f1942f4f6f675adebb890955
Gerrit-Change-Number: 27267
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Comment-Date: Mon, 21 Feb 2022 13:01:31 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
osmith has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-dev/+/27034 )
Change subject: net: run.sh: store all spawned pids in files
......................................................................
Patch Set 2: Verified+1 Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/osmo-dev/+/27034
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-dev
Gerrit-Branch: master
Gerrit-Change-Id: I379ef71de2f1ab0ac4a28064e5cf9e275c4c61e9
Gerrit-Change-Number: 27034
Gerrit-PatchSet: 2
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Comment-Date: Mon, 21 Feb 2022 13:01:13 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: neels.
osmith has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-dev/+/27033 )
Change subject: net: require terminal to be configured
......................................................................
Patch Set 2: Verified+1 Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/osmo-dev/+/27033
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-dev
Gerrit-Branch: master
Gerrit-Change-Id: I0afb6b0242c399334a2c37f18a5d26d5beeabedc
Gerrit-Change-Number: 27033
Gerrit-PatchSet: 2
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Attention: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Comment-Date: Mon, 21 Feb 2022 13:01:08 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment