osmith submitted this change.
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(-)
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 change 27033. To unsubscribe, or for help writing mail filters, visit settings.