Introduce internal/pkg/cfgloader and configs/ for centralized configuration, refactor mototrbod/mototrboctl entrypoints and service wiring, and update protocol packages accordingly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
44 lines
1.2 KiB
Bash
44 lines
1.2 KiB
Bash
#!/usr/bin/env bash
|
|
#
|
|
# send-tms.sh — send a TMS text message to a radio via the mototrbod
|
|
# REST API. Defaults target a daemon running on the local box with
|
|
# REST in plain-HTTP mode (--rest-plain-http). Override with env vars
|
|
# for an mTLS deployment.
|
|
#
|
|
# Usage:
|
|
# ./scripts/send-tms.sh "hello from bash"
|
|
# RADIO_ID=24044 ./scripts/send-tms.sh "hi"
|
|
# MOTOTRBO_URL=https://mototrbo.lan:8443 \
|
|
# CA=./tls/ca.crt CERT=./tls/client.crt KEY=./tls/client.key \
|
|
# ./scripts/send-tms.sh "secured hi"
|
|
|
|
set -euo pipefail
|
|
|
|
RADIO_ID="${RADIO_ID:-24044}"
|
|
MOTOTRBO_URL="${MOTOTRBO_URL:-http://127.0.0.1:8443}"
|
|
TEXT="${*:-hello from send-tms.sh}"
|
|
|
|
CURL_ARGS=(--silent --show-error --fail-with-body)
|
|
if [[ -n "${CA:-}" ]]; then
|
|
CURL_ARGS+=(--cacert "$CA")
|
|
fi
|
|
if [[ -n "${CERT:-}" && -n "${KEY:-}" ]]; then
|
|
CURL_ARGS+=(--cert "$CERT" --key "$KEY")
|
|
fi
|
|
|
|
PAYLOAD=$(printf '{"radio_id":%s,"text":%s}' \
|
|
"$RADIO_ID" \
|
|
"$(printf '%s' "$TEXT" | python3 -c 'import json,sys; print(json.dumps(sys.stdin.read()))')")
|
|
|
|
echo "POST $MOTOTRBO_URL/api/v1/tms"
|
|
echo " radio_id: $RADIO_ID"
|
|
echo " text: $TEXT"
|
|
echo
|
|
|
|
curl "${CURL_ARGS[@]}" \
|
|
-H 'Content-Type: application/json' \
|
|
-X POST \
|
|
--data "$PAYLOAD" \
|
|
"$MOTOTRBO_URL/api/v1/tms"
|
|
echo
|