summaryrefslogtreecommitdiff
path: root/scripts/install-freebsd.sh
blob: 3cc89ed39d580a6a5ca4c930624d76096989d1fc (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
#!/usr/bin/env bash
# install-freebsd.sh — MAX25-Stack-Lite FreeBSD build + install (daemon, max25-bcpr, terminal, CRDOP/OSS)
set -euo pipefail

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

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

Usage: $0 [options]

Options:
  --deps         Install pkg build/runtime 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

Build (default): max25d, max25-bcpr, max25-terminal, CRDOP (OSS audio)

After install:
  sudo mkdir -p /var/run/max25 ${ETC}
  sudo cp ${PREFIX}/share/max25/max25d.lite.bcpr.ini.example ${ETC}/max25d.ini
  sudo cp ${PREFIX}/share/max25-bcpr/max25-bcpr.freebsd.ini.example ${ETC}/max25-bcpr.ini
  sudo max25-bcpr-ctl start --ini ${ETC}/max25-bcpr.ini
  sudo ${ROOT}/scripts/run-max25d.sh ${ETC}/max25d.ini

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)" != "FreeBSD" ]]; then
  echo "install-freebsd.sh: FreeBSD only" >&2
  exit 1
fi

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

if [[ "$INSTALL_DEPS" -eq 1 ]]; then
  pkgs=(cmake python3 ncurses sox git gmake pkgconf)
  echo "Installing packages: ${pkgs[*]}"
  pkg install -y "${pkgs[@]}"
fi

BUILD_DIR="${BUILD_DIR}" "${ROOT}/scripts/build-freebsd.sh"

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 "${ROOT}/${BUILD_DIR}" --prefix "${PREFIX}"
else
  sudo cmake --install "${ROOT}/${BUILD_DIR}" --prefix "${PREFIX}"
fi

_install_ini() {
  local src="$1" dst="$2"
  if [[ ! -f "$dst" ]] && [[ -f "$src" ]]; then
    mkdir -p "$(dirname "$dst")"
    if [[ "$(id -u)" -eq 0 ]]; then
      cp "$src" "$dst"
    else
      sudo cp "$src" "$dst"
    fi
    echo "  installed $dst (from example)"
  fi
}

if [[ "$(id -u)" -eq 0 ]] || sudo -n true 2>/dev/null; then
  _install_ini "${ROOT}/share/max25-bcpr/max25-bcpr.freebsd.ini.example" "${ETC}/max25-bcpr.ini"
  _install_ini "${ROOT}/share/max25/max25d.lite.bcpr.ini.example" "${ETC}/max25d.ini"
fi

echo ""
echo "== MAX25-Stack-Lite installed to ${PREFIX} =="
echo "  max25d, max25-terminal → ${PREFIX}/bin"
echo "  max25-bcpr-ctl, max25-bcprd-init → ${PREFIX}/sbin"
echo "  examples → ${PREFIX}/share/max25/"
echo ""
echo "Next steps (PC-COM / ExSys cuau2 — edit INI before live RF):"
echo "  pw groupmod dialer -m \$USER"
echo "  sudo mkdir -p /var/run/max25 ${ETC}"
echo "  sudo chown \$USER:dialer /var/run/max25"
echo "  # ${ETC}/max25-bcpr.ini: serial=/dev/cuau2 iobase=0xd090 irq=36"
echo "  # ${ETC}/max25d.ini: [daemon] user=… group=dialer"
echo "  sudo max25-bcpr-ctl start --ini ${ETC}/max25-bcpr.ini"
echo "  sudo ${ROOT}/scripts/run-max25d.sh ${ETC}/max25d.ini"
echo "  max25-terminal -H 127.0.0.1 -p 7325 -d max25e0"
echo ""
echo "Optional: CRDOP/OSS → ${PREFIX}/share/crdop/crdop.freebsd.ini.example"
echo ""
git clone -b <branch> https://cgit.mode42.com/<repo>.git
git clone -b <branch> git://cgit.mode42.com/<repo>.git

info@mode42.com