#!/usr/bin/env bash # Telltale club-device provisioner — turns a fresh Raspberry Pi into a shore AIS station # or a boat instrument device, feeding Telltale, auto-starting on boot. # # curl -fsSL https://telltaleracing.com/provision.sh | sudo bash -s -- shore "LBYC clubhouse" # curl -fsSL https://telltaleracing.com/provision.sh | sudo bash -s -- boat "Laissez Faire" [--serial /dev/serial/by-id/XXX] [--baud 4800] # # Options: --telltale URL (default https://telltaleracing.com) · --race NAME (default "open") # --serial DEV (boat, the by-id path — recommended) · --baud N (boat, 4800 instruments / 38400 AIS) # # Run once per device on the bench. Idempotent-ish; safe to re-run. set -euo pipefail TELLTALE="https://telltaleracing.com"; RACE="open"; SERIAL=""; BAUD="4800" MODE="${1:-}"; NAME="${2:-}"; KEY="${3:-}" shift 3 2>/dev/null || true while [ $# -gt 0 ]; do case "$1" in --telltale) TELLTALE="$2"; shift 2;; --race) RACE="$2"; shift 2;; --serial) SERIAL="$2"; shift 2;; --baud) BAUD="$2"; shift 2;; *) echo "unknown option: $1"; exit 1;; esac; done [ "$(id -u)" = 0 ] || { echo "Please run with sudo."; exit 1; } case "$MODE" in boat|shore) ;; *) echo "Usage: provision.sh \"\" [opts]"; exit 1;; esac [ -n "$NAME" ] && [ -n "$KEY" ] || { echo "Need a name and a station key."; exit 1; } RUNUSER="${SUDO_USER:-pi}" CONNDIR="/opt/telltale-device" echo "== Telltale $MODE device: '$NAME' -> $TELLTALE ==" apt-get update -y apt-get install -y python3 curl if [ "$MODE" = shore ]; then # ---------- SHORE STATION: RTL-SDR + AIS-catcher -> Telltale (+ AISHub) ---------- apt-get install -y rtl-sdr echo 'blacklist dvb_usb_rtl28xxu' > /etc/modprobe.d/blacklist-rtl.conf # free the SDR from the TV driver if ! command -v AIS-catcher >/dev/null 2>&1; then echo "-- installing AIS-catcher --" bash -c "$(curl -fsSL https://raw.githubusercontent.com/jvde-github/AIS-catcher/main/scripts/aiscatcher-install)" fi AISCATCHER="$(command -v AIS-catcher || echo /usr/local/bin/AIS-catcher)" cat > /etc/systemd/system/telltale-ais.service </dev/null 2>&1; then echo "-- installing Node.js + Signal K (a few minutes) --" curl -fsSL https://deb.nodesource.com/setup_18.x | bash - apt-get install -y nodejs npm install -g signalk-server fi SKBIN="$(command -v signalk-server || echo /usr/bin/signalk-server)" # Signal K: a serial NMEA-0183 provider (prefer the stable /dev/serial/by-id/... path) SKDIR="/home/$RUNUSER/.signalk"; mkdir -p "$SKDIR" DEV="${SERIAL:-/dev/ttyUSB0}" cat > "$SKDIR/settings.json" < /etc/systemd/system/signalk.service < /etc/systemd/system/telltale-connector.service <:3000 Connector: journalctl -u telltale-connector -f ==" echo " No data? Check the wire pair + baud: ls -l /dev/serial/by-id/ then re-run with --serial --baud <4800|38400>" fi echo "== '$NAME' will feed $TELLTALE automatically on every boot. =="