From b28a9100ed188419a18aca73af4f37b505cfe8d6 Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Mon, 17 Jan 2022 15:59:02 +0100 Subject: [PATCH] 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 --- net/config_2g3g | 4 ++++ net/templates/run.sh | 27 ++++++++++++++++++++------- 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 @@ mkdir -p "$logdir" 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 }