From dfca1ff29304404af7c632b735a9b7e49e3ed151 Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Mon, 17 Jan 2022 15:59:02 +0100 Subject: [PATCH] net: make terminal configurable in config file Change-Id: I0afb6b0242c399334a2c37f18a5d26d5beeabedc --- net/config_2g3g | 4 ++++ net/templates/run.sh | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/net/config_2g3g b/net/config_2g3g index c1498be..ab6c2a2 100644 --- a/net/config_2g3g +++ b/net/config_2g3g @@ -1,3 +1,7 @@ +# Terminal for launching Osmocom programs +# Supported: auto, urxvt, xterm +TERMINAL="auto" + ETH_DEV=eth0 APN_DEV=apn0 diff --git a/net/templates/run.sh b/net/templates/run.sh index 311cdd9..af7bc36 100755 --- a/net/templates/run.sh +++ b/net/templates/run.sh @@ -44,10 +44,27 @@ mkdir -p "$logdir" find_term() { # Find a terminal program and write to the global "terminal" variable local programs="urxvt xterm" + + if [ -n "${TERMINAL}" ] && [ "${TERMINAL}" != "auto" ]; then + case " $programs " in + *" ${TERMINAL} "*) + echo "Terminal: ${TERMINAL} (from config)" + terminal="${TERMINAL}" + return + ;; + esac + + echo "ERROR: Terminal '${TERMINAL}' is not in list of supported terminals ($programs)" + exit 1 + fi + local program for program in $programs; do terminal="$(which $program)" - [ -n "$terminal" ] && return + if [ -n "$terminal" ]; then + echo "Terminal: $program (auto)" + return + fi done # No terminal found