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
This commit is contained in:
Oliver Smith 2022-01-17 15:59:02 +01:00
parent 3ffaca828f
commit b28a9100ed
2 changed files with 24 additions and 7 deletions

View File

@ -1,3 +1,7 @@
# Terminal for launching Osmocom programs
# Supported: urxvt, xterm
TERMINAL="urxvt"
ETH_DEV=eth0
APN_DEV=apn0

View File

@ -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
}