summaryrefslogtreecommitdiff
path: root/scripts/install-max25.sh
blob: 44e3eb4386049d5d1d6fdda85af31c029e402764 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/bin/env bash
# install-max25.sh — MAX25-Stack-Lite build and install on Linux (daemon, bcpr, terminal, tests).
set -euo pipefail

ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
PREFIX="${PREFIX:-/usr/local}"
INSTALL_DEPS=0
BUILD_ONLY=0
BUILD_DIR="${BUILD_DIR:-build}"

usage() {
  cat <<EOF
MAX25-Stack-Lite install — Linux

Usage: $0 [options]

Options:
  --deps         Install apt build dependencies
  --build-only   Build only, do not install
  --prefix DIR   Install prefix (default: /usr/local)
  --build-dir D  CMake build dir (default: build)
  -h, --help     This help

After install:
  run-max25d
  ./scripts/tx-rx-test.sh --device modem --live   # from the source tree; RX before TX (§0.20)
  run-max25-terminal -U /run/max25/modem.sock

Doc index: docs/README.md (stub — depth docs live in the research vault)
EOF
}

while [[ $# -gt 0 ]]; do
  case "$1" in
    --deps) INSTALL_DEPS=1; shift ;;
    --build-only) BUILD_ONLY=1; shift ;;
    --prefix) PREFIX="$2"; shift 2 ;;
    --build-dir) BUILD_DIR="$2"; shift 2 ;;
    -h|--help) usage; exit 0 ;;
    *) echo "Unknown option: $1" >&2; usage; exit 1 ;;
  esac
done

if [[ "$(uname -s)" != "Linux" ]]; then
  echo "install-max25.sh: Linux only" >&2
  exit 1
fi

echo "== MAX25 install: $(uname -s) $(uname -m) → ${PREFIX} =="

if [[ "$INSTALL_DEPS" -eq 1 ]]; then
  if command -v apt-get >/dev/null 2>&1; then
    sudo apt-get update
    pkgs=(build-essential make cmake pkg-config git python3 libncurses-dev libasound2-dev)
    sudo apt-get install -y "${pkgs[@]}" || true
  fi
fi

cd "$ROOT"
echo "-- cmake (BCPR+TERMINAL+DAEMON ON — max25-bcpr default)"
cmake -B "${BUILD_DIR}" \
  -DCMAKE_BUILD_TYPE=Release \
  -DMAX25_BUILD_MAX25_BCPR=ON \
  -DMAX25_BUILD_TERMINAL=ON \
  -DMAX25_BUILD_DAEMON=ON \
  -DMAX25_BUNDLE_AX25=OFF
cmake --build "${BUILD_DIR}" -j"$(nproc 2>/dev/null || echo 2)"

if [[ "$BUILD_ONLY" -eq 1 ]]; then
  echo "== build done (no install) =="
  exit 0
fi

echo "-- install to ${PREFIX}"
if [[ "$(id -u)" -eq 0 ]]; then
  cmake --install "${BUILD_DIR}" --prefix "$PREFIX"
else
  sudo cmake --install "${BUILD_DIR}" --prefix "$PREFIX"
fi

echo ""
echo "== MAX25 installed to ${PREFIX} =="
echo "  max25d, kiss_bridge.py, max25-terminal, max25-ctl -> ${PREFIX}/bin"
echo "  max25-bcpr-ctl -> ${PREFIX}/sbin (when MAX25_BUILD_MAX25_BCPR=ON)"
echo "  examples -> ${PREFIX}/share/max25/"
echo ""

echo ""
echo "Next steps (serial TNC / USB KISS):"
echo "  sudo usermod -aG dialout \$USER   # serial access"
echo "  sudo cp share/max25/max25d.lite.ini.example /etc/max25/max25d.ini"
echo "  sudo max25d -c /etc/max25/max25d.ini"
echo "  max25-terminal -U /run/max25/modem.sock"
echo ""
echo "BayCom/based (max25-bcpr): built by default (MAX25_BUILD_MAX25_BCPR=ON)."
echo "  See stacks/max25-bcpr/README.md · share/max25-bcpr/max25-bcpr.ini.example"
echo ""
ETC="${ETC:-/etc/max25}"
if [[ "$(id -u)" -eq 0 ]] || sudo -n true 2>/dev/null; then
  _install_ini() {
    local src="$1" dst="$2"
    if [[ ! -f "$dst" ]] && [[ -f "$src" ]]; then
      mkdir -p "$ETC"
      if [[ "$(id -u)" -eq 0 ]]; then
        cp "$src" "$dst"
      else
        sudo cp "$src" "$dst"
      fi
      echo "  installed $dst (from example)"
    fi
  }
  _install_ini "$ROOT/share/max25-bcpr/max25-bcpr.ini.example" "$ETC/max25-bcpr.ini"
  if [[ -f "$ETC/bcpr.ini" ]] && [[ ! -L "$ETC/max25-bcpr.ini" ]]; then
    echo "  note: legacy $ETC/bcpr.ini kept — paths /tmp/bcpr auto-map to /tmp/max25-bcpr at runtime"
  fi
fi
git clone -b <branch> https://cgit.mode42.com/<repo>.git
git clone -b <branch> git://cgit.mode42.com/<repo>.git

info@mode42.com