mirror of
https://github.com/thetechprepper/emcomm-tools-os-community.git
synced 2026-09-17 15:41:44 -04:00
173 lines
4.8 KiB
Bash
Executable File
173 lines
4.8 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Author : Gaston Gonzalez
|
|
# Date : 12 May 2026
|
|
# Updated : 15 May 2026
|
|
# Purpose : Wrapper script for starting Reticulum with PnP support
|
|
#
|
|
# Preconditions:
|
|
# 1. Supported radio and audio interface are connected and properly detected
|
|
#
|
|
# Postconditions:
|
|
# 1. Reticulum configuration updated
|
|
# 2. Optional modem started
|
|
# 3. Reticulum started
|
|
. /opt/emcomm-tools/bin/et-common
|
|
|
|
APP="Reticulum"
|
|
RETICULUM_CONF_DIR="${HOME}/.reticulum"
|
|
RETICULUM_CONF_FILE="${RETICULUM_CONF_DIR}/config"
|
|
|
|
INTERFACE_RNODE_TXPOWER_DEFAULT=17
|
|
|
|
options=()
|
|
files=()
|
|
index=1
|
|
|
|
while IFS= read -r file; do
|
|
name=$(basename "$file")
|
|
files[$index]="$name"
|
|
options+=("$index" "$name")
|
|
((index++))
|
|
done < <(find "${HOME}/.reticulum" -type f -name 'config.blueprint.*')
|
|
|
|
choice=$(dialog \
|
|
--title "Reticulum Configuration" \
|
|
--menu "Choose a blueprint:" \
|
|
15 60 10 \
|
|
"${options[@]}" \
|
|
2>&1 >/dev/tty)
|
|
EXIT_STATUS=$?
|
|
|
|
tput sgr0 && clear
|
|
|
|
if [[ ${EXIT_STATUS} -ne 0 ]]; then
|
|
et-log "No blueprint configuration selected"
|
|
exit ${EXIT_STATUS}
|
|
fi
|
|
|
|
SELECTED_CONF="${files[$choice]}"
|
|
|
|
if [[ ! -e "${RETICULUM_CONF_DIR}" ]]; then
|
|
et-log "Creating missing configuration directory: ${RETICULUM_CONF_DIR}"
|
|
mkdir -p "${RETICULUM_CONF_DIR}"
|
|
fi
|
|
|
|
ACTIVE_CONF_FILE="${RETICULUM_CONF_DIR}/${SELECTED_CONF}"
|
|
if [[ ! -e ${ACTIVE_CONF_FILE} ]]; then
|
|
et-log "${ACTIVE_CONF_FILE} does not exist."
|
|
exit 1
|
|
fi
|
|
|
|
et-log "Using ${ACTIVE_CONF_FILE}"
|
|
|
|
if [[ -e "${RETICULUM_CONF_FILE}" ]]; then
|
|
et-log "Removing previous Reticulum configuration: ${RETICULUM_CONF_FILE}"
|
|
rm "${RETICULUM_CONF_FILE}"
|
|
fi
|
|
|
|
et-log "Linking new configuration..."
|
|
ln -v -s "${ACTIVE_CONF_FILE}" "${RETICULUM_CONF_FILE}"
|
|
|
|
############################################################
|
|
# Optionally, launch a modem if a radio is connected
|
|
############################################################
|
|
|
|
# If a supported radio is plugged in and detected, it will have the
|
|
# rigctld process running automatically.
|
|
IS_RADIO_CONNECTED=`ps -ef | grep [r]igctld`
|
|
if [[ $? -eq 0 ]]; then
|
|
|
|
et-log "Radio connected and detected."
|
|
|
|
modem_options=()
|
|
modem_options+=("1200" "1200 baud (VHF/UHF operation)")
|
|
modem_options+=("300" "300 baud (HF option)")
|
|
|
|
modem_choice=$(dialog \
|
|
--clear \
|
|
--title "Reticulum Configuration" \
|
|
--menu "Select a modem" \
|
|
13 60 10 \
|
|
"${modem_options[@]}" \
|
|
2>&1 >/dev/tty)
|
|
|
|
dialog \
|
|
--title "Note on Reticulum" \
|
|
--yesno "Reticulum uses end-to-end encryption. Check your local laws and regulations and ensure that you can legally run this mode! Are you sure that you want to run this?" \
|
|
0 0
|
|
EXIT_STATUS=$?
|
|
|
|
tput sgr 0 && clear
|
|
|
|
if [[ ${EXIT_STATUS} -ne 0 ]]; then
|
|
et-log "User canceled modem selection. Packet modem will not be started and interface will not be enabled."
|
|
else
|
|
case ${modem_choice} in
|
|
300)
|
|
et-log "Starting 300 baud packet modem"
|
|
start_and_wait_for_service et-service-direwolf-300
|
|
;;
|
|
1200)
|
|
et-log "Starting 1200 baud packet modem"
|
|
start_and_wait_for_service et-service-direwolf-simple
|
|
;;
|
|
*)
|
|
et-log "No modem specified"
|
|
;;
|
|
esac
|
|
fi
|
|
fi
|
|
|
|
et-log "Updating configuration for this session..."
|
|
|
|
############################################################
|
|
# AX.25 KISS (Packet Radio) interface updates
|
|
############################################################
|
|
|
|
# Enable/disable intereface based on PnP device detection
|
|
if [[ -e /tmp/kisstnc ]]; then
|
|
INTERFACE_AX25KISS_ENABLED="yes"
|
|
else
|
|
INTERFACE_AX25KISS_ENABLED="no"
|
|
fi
|
|
sed -i "s|{{ET_RETICULUM_INTERFACE_AX25KISS_ENABLED}}|${INTERFACE_AX25KISS_ENABLED}|g" ${RETICULUM_CONF_FILE}
|
|
|
|
# Update callsign
|
|
[[ -z "$ET_USER_CONFIG" ]] && ET_USER_CONFIG="${HOME}/.config/emcomm-tools/user.json"
|
|
CALLSIGN=$(cat ${ET_USER_CONFIG} | jq -r .callsign)
|
|
sed -i "s|{{ET_CALLSIGN}}|${CALLSIGN}|g" ${RETICULUM_CONF_FILE}
|
|
|
|
|
|
############################################################
|
|
# RNode (LoRA) interface updates
|
|
############################################################
|
|
|
|
# Enable/disable intereface based on PnP device detection
|
|
if [[ -e "${ET_DEVICE_LORA}" ]]; then
|
|
INTERFACE_RNODE_ENABLED="yes"
|
|
|
|
# Determine max power settings
|
|
et-log "Connecting to device to determine max power..."
|
|
|
|
INTERFACE_RNODE_TXPOWER=`rnodeconf -i ${ET_DEVICE_LORA} | awk -F': ' '/Max TX power/ {print $2}' | awk '{print $1}'`
|
|
if [[ $? -ne 0 ]]; then
|
|
INTERFACE_RNODE_TXPOWER=${INTERFACE_RNODE_TXPOWER_DEFAULT}
|
|
et-log "Can't determine max power. Using defaulting ${INTERFACE_RNODE_TXPOWER}."
|
|
fi
|
|
|
|
et-log "Setting max power to ${INTERFACE_RNODE_TXPOWER} dBm."
|
|
sed -i "s|{{ET_RETICULUM_INTERFACE_RNODE_TXPOWER}}|${INTERFACE_RNODE_TXPOWER}|g" ${RETICULUM_CONF_FILE}
|
|
|
|
else
|
|
INTERFACE_RNODE_ENABLED="no"
|
|
fi
|
|
|
|
sed -i "s|{{ET_RETICULUM_INTERFACE_RNODE_ENABLED}}|${INTERFACE_RNODE_ENABLED}|g" ${RETICULUM_CONF_FILE}
|
|
|
|
|
|
CMD="rnsd"
|
|
et-log "Starting Reticulum: ${CMD}"
|
|
|
|
${CMD}
|