Switch the lab reflector to jayReflector and harden local station use.
Build DJ1JAY’s fork with an optional Satellite/Trunk stub, allow -c/--config, open capture and playback as separate devices, and add a lab start helper. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Executable
+124
@@ -0,0 +1,124 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build (if needed) and start funknetz against the local svxlink-docker lab.
|
||||
# Does not start Docker — run: (cd svxlink-docker && docker compose up -d)
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")" && pwd)"
|
||||
LAB="$ROOT/svxlink-docker"
|
||||
ENV_FILE="$LAB/.env"
|
||||
CONF="$LAB/config/svxreflector.conf"
|
||||
GENERATED="$LAB/.funknetz.generated.json"
|
||||
LOG_DIR="$LAB/logs"
|
||||
LOG_FILE="$LOG_DIR/funknetz-lab.log"
|
||||
APP_BIN="$ROOT/build/bin/funknetz.app/Contents/MacOS/funknetz"
|
||||
|
||||
die() {
|
||||
echo "teststart: $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
[[ -f "$ENV_FILE" ]] || die "missing $ENV_FILE (copy from .env.example and edit; this script will not copy it)"
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
set -a
|
||||
# shellcheck source=/dev/null
|
||||
source "$ENV_FILE"
|
||||
set +a
|
||||
|
||||
missing=()
|
||||
[[ -n "${FUNKNETZ_HOST:-}" ]] || missing+=(FUNKNETZ_HOST)
|
||||
[[ -n "${FUNKNETZ_PORT:-}" ]] || missing+=(FUNKNETZ_PORT)
|
||||
[[ -n "${FUNKNETZ_CALLSIGN:-}" ]] || missing+=(FUNKNETZ_CALLSIGN)
|
||||
[[ -n "${FUNKNETZ_AUTH_KEY:-}" ]] || missing+=(FUNKNETZ_AUTH_KEY)
|
||||
[[ -n "${FUNKNETZ_TALK_GROUP:-}" ]] || missing+=(FUNKNETZ_TALK_GROUP)
|
||||
if ((${#missing[@]})); then
|
||||
die "missing in .env: ${missing[*]}"
|
||||
fi
|
||||
|
||||
[[ -f "$CONF" ]] || die "missing $CONF"
|
||||
|
||||
# Resolve FUNKNETZ_CALLSIGN → password group in [USERS], then secret in [PASSWORDS].
|
||||
callsign_upper="$(printf '%s' "$FUNKNETZ_CALLSIGN" | tr '[:lower:]' '[:upper:]')"
|
||||
section=""
|
||||
password_group=""
|
||||
auth_secret=""
|
||||
while IFS= read -r line || [[ -n "$line" ]]; do
|
||||
line="${line%%#*}"
|
||||
line="$(printf '%s' "$line" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
|
||||
[[ -z "$line" ]] && continue
|
||||
if [[ "$line" =~ ^\[(.+)\]$ ]]; then
|
||||
section="${BASH_REMATCH[1]}"
|
||||
continue
|
||||
fi
|
||||
case "$section" in
|
||||
USERS)
|
||||
key="${line%%=*}"
|
||||
val="${line#*=}"
|
||||
key="$(printf '%s' "$key" | sed -e 's/[[:space:]]*$//' | tr '[:lower:]' '[:upper:]')"
|
||||
val="$(printf '%s' "$val" | sed -e 's/^[[:space:]]*//')"
|
||||
if [[ "$key" == "$callsign_upper" ]]; then
|
||||
password_group="$val"
|
||||
fi
|
||||
;;
|
||||
PASSWORDS)
|
||||
key="${line%%=*}"
|
||||
val="${line#*=}"
|
||||
key="$(printf '%s' "$key" | sed -e 's/[[:space:]]*$//')"
|
||||
val="$(printf '%s' "$val" | sed -e 's/^[[:space:]]*//' -e 's/^"//' -e 's/"$//')"
|
||||
if [[ -n "$password_group" && "$key" == "$password_group" ]]; then
|
||||
auth_secret="$val"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done <"$CONF"
|
||||
|
||||
[[ -n "$password_group" ]] || die "callsign $FUNKNETZ_CALLSIGN is not in [USERS] in $CONF"
|
||||
[[ -n "$auth_secret" ]] || die "password group $password_group has no [PASSWORDS] entry in $CONF"
|
||||
[[ "$FUNKNETZ_AUTH_KEY" == "$auth_secret" ]] || die "FUNKNETZ_AUTH_KEY does not match [PASSWORDS] for $FUNKNETZ_CALLSIGN"
|
||||
|
||||
mkdir -p "$LOG_DIR"
|
||||
|
||||
# JSON-escape a string value.
|
||||
json_str() {
|
||||
python3 -c 'import json,sys; print(json.dumps(sys.argv[1]))' "$1"
|
||||
}
|
||||
|
||||
host_json="$(json_str "$FUNKNETZ_HOST")"
|
||||
call_json="$(json_str "$callsign_upper")"
|
||||
key_json="$(json_str "$FUNKNETZ_AUTH_KEY")"
|
||||
log_json="$(json_str "$LOG_FILE")"
|
||||
|
||||
umask 077
|
||||
cat >"$GENERATED" <<EOF
|
||||
{
|
||||
"host": $host_json,
|
||||
"port": $FUNKNETZ_PORT,
|
||||
"callsign": $call_json,
|
||||
"authKey": $key_json,
|
||||
"talkGroup": $FUNKNETZ_TALK_GROUP,
|
||||
"enableLogging": true,
|
||||
"logFile": $log_json
|
||||
}
|
||||
EOF
|
||||
chmod 600 "$GENERATED"
|
||||
|
||||
needs_build=0
|
||||
if [[ ! -x "$APP_BIN" ]]; then
|
||||
needs_build=1
|
||||
else
|
||||
newer="$(find "$ROOT" \
|
||||
\( -path "$ROOT/build" -o -path "$ROOT/svxlink-docker" -o -path "$ROOT/.git" \) -prune -o \
|
||||
\( -name '*.go' -o -name 'go.mod' -o -name 'go.sum' -o -name 'wails.json' \) -newer "$APP_BIN" -print \
|
||||
-o -path "$ROOT/frontend/dist/*" -newer "$APP_BIN" -print \
|
||||
2>/dev/null | head -n 1 || true)"
|
||||
[[ -n "$newer" ]] && needs_build=1
|
||||
fi
|
||||
|
||||
if ((needs_build)); then
|
||||
echo "teststart: building funknetz.app…"
|
||||
(cd "$ROOT" && GOWORK=off wails build)
|
||||
[[ -x "$APP_BIN" ]] || die "build finished but binary missing: $APP_BIN"
|
||||
fi
|
||||
|
||||
echo "teststart: starting with -c $GENERATED"
|
||||
exec "$APP_BIN" -c "$GENERATED"
|
||||
Reference in New Issue
Block a user