summaryrefslogtreecommitdiff
path: root/scripts/run-max25-terminal.sh
diff options
context:
space:
mode:
authorinfo@mode42.com <info@mode42.com>2026-08-07 18:25:13 +0000
committerinfo@mode42.com <info@mode42.com>2026-08-07 18:25:13 +0000
commit04d965d67a7264a1c7c211494aebda1953df7603 (patch)
tree0ebd700a6e219f84a26a656f4bee8778bc75da7b /scripts/run-max25-terminal.sh
Initial push
Diffstat (limited to 'scripts/run-max25-terminal.sh')
-rwxr-xr-xscripts/run-max25-terminal.sh62
1 files changed, 62 insertions, 0 deletions
diff --git a/scripts/run-max25-terminal.sh b/scripts/run-max25-terminal.sh
new file mode 100755
index 0000000..adb0cca
--- /dev/null
+++ b/scripts/run-max25-terminal.sh
@@ -0,0 +1,62 @@
+#!/usr/bin/env bash
+# Canonical max25-terminal launcher — tree or PREFIX/bin.
+set -euo pipefail
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
+
+pick() {
+ local c
+ # Prefer installed binary beside this script
+ if [[ -x "${SCRIPT_DIR}/max25-terminal" && ! -d "${SCRIPT_DIR}/../stacks/terminal" ]]; then
+ c="${SCRIPT_DIR}/max25-terminal"
+ if "$c" -h 2>&1 | grep -q -- '-d, --device'; then
+ echo "$c"
+ return 0
+ fi
+ fi
+ local TREE=""
+ if [[ -d "${SCRIPT_DIR}/../stacks/terminal" ]]; then
+ TREE="$(cd "${SCRIPT_DIR}/.." && pwd)"
+ fi
+ for c in \
+ ${TREE:+"${TREE}/build/bin/max25-terminal"} \
+ ${TREE:+"${TREE}/build-max25-bcpr/bin/max25-terminal"} \
+ "${ROOT}/build-max25-bcpr/bin/max25-terminal" \
+ "${ROOT}/build/bin/max25-terminal" \
+ /usr/local/bin/max25-terminal
+ do
+ [[ -n "$c" && -x "$c" ]] || continue
+ if "$c" -h 2>&1 | grep -q -- '-d, --device'; then
+ echo "$c"
+ return 0
+ fi
+ done
+ if command -v max25-terminal >/dev/null 2>&1; then
+ c="$(command -v max25-terminal)"
+ if "$c" -h 2>&1 | grep -q -- '-d, --device'; then
+ echo "$c"
+ return 0
+ fi
+ fi
+ return 1
+}
+
+BIN="$(pick)" || {
+ echo "run-max25-terminal: no current max25-terminal with -d/--device" >&2
+ echo " cmake -B build-max25-bcpr -DMAX25_BUILD_MAX25_BCPR=ON && cmake --build build-max25-bcpr" >&2
+ echo " install: scripts/install-max25.sh or cmake --install build" >&2
+ echo " Do not run stacks/terminal/max25-terminal leftovers." >&2
+ exit 127
+}
+
+SOCK="${MAX25_UNIX:-/run/max25/modem.sock}"
+if [[ ! -S "$SOCK" ]] && [[ "${1:-}" != "-h" ]] && [[ "${1:-}" != "--help" ]]; then
+ if [[ " $* " != *" -T "* ]] && [[ " $* " != *" --tcp-only "* ]]; then
+ echo "run-max25-terminal: no socket $SOCK — start max25d first:" >&2
+ echo " run-max25d # or: ${SCRIPT_DIR}/run-max25d.sh" >&2
+ exit 1
+ fi
+fi
+
+exec "$BIN" "$@"
git clone -b <branch> https://cgit.mode42.com/<repo>.git
git clone -b <branch> git://cgit.mode42.com/<repo>.git

info@mode42.com