2026-05-12 07:40:35 -07:00
#!/bin/bash
#
# Author : Gaston Gonzalez
# Date : 12 May 2026
2026-06-30 11:59:53 -07:00
# Updated : 30 June 2026
2026-05-12 07:40:35 -07:00
# 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
2026-06-14 18:02:28 -07:00
# 2. Optional modem started
2026-05-12 07:40:35 -07:00
# 3. Reticulum started
2026-06-30 11:59:53 -07:00
# The current version of modem73 does not alway exit.
cleanup( ) {
pkill -9 modem73 2>/dev/null || true
}
trap cleanup EXIT INT TERM
2026-05-12 07:40:35 -07:00
. /opt/emcomm-tools/bin/et-common
2026-06-28 13:00:23 -07:00
# Ensure that no other modes are running
et-kill-all
2026-05-12 07:40:35 -07:00
APP = "Reticulum"
2026-05-13 07:39:59 -07:00
RETICULUM_CONF_DIR = " ${ HOME } /.reticulum "
RETICULUM_CONF_FILE = " ${ RETICULUM_CONF_DIR } /config "
2026-05-12 07:40:35 -07:00
2026-06-15 07:48:32 -07:00
INTERFACE_RNODE_TXPOWER_DEFAULT = 17
2026-06-14 18:02:28 -07:00
options = ( )
files = ( )
index = 1
2026-05-12 07:40:35 -07:00
2026-06-14 18:02:28 -07:00
while IFS = read -r file; do
name = $( basename " $file " )
files[ $index ] = " $name "
options += ( " $index " " $name " )
( ( index++) )
2026-06-15 12:57:13 -07:00
done < <( find " ${ HOME } /.reticulum " -type f -name 'config.blueprint.*' | sort)
2026-06-14 18:02:28 -07:00
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 }
2026-05-12 07:40:35 -07:00
fi
2026-06-14 18:02:28 -07:00
SELECTED_CONF = " ${ files [ $choice ] } "
2026-05-12 07:40:35 -07:00
2026-05-13 07:39:59 -07:00
if [ [ ! -e " ${ RETICULUM_CONF_DIR } " ] ] ; then
2026-06-14 18:02:28 -07:00
et-log " Creating missing configuration directory: ${ RETICULUM_CONF_DIR } "
mkdir -p " ${ RETICULUM_CONF_DIR } "
2026-05-13 07:39:59 -07:00
fi
2026-06-14 18:02:28 -07:00
ACTIVE_CONF_FILE = " ${ RETICULUM_CONF_DIR } / ${ SELECTED_CONF } "
if [ [ ! -e ${ ACTIVE_CONF_FILE } ] ] ; then
et-log " ${ ACTIVE_CONF_FILE } does not exist. "
2026-05-12 07:40:35 -07:00
exit 1
fi
2026-06-14 18:02:28 -07:00
et-log " Using ${ ACTIVE_CONF_FILE } "
2026-05-12 07:40:35 -07:00
2026-06-14 18:02:28 -07:00
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 } "
2026-06-14 19:26:29 -07:00
############################################################
# 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 = ( )
2026-06-28 16:22:28 -07:00
HAS_PACKET_CONFIG = ` grep AX25KISSInterface ~/.reticulum/config`
if [ [ $? -eq 0 ] ] ; then
modem_options += ( "1200-packet" "1200 baud packet (VHF/UHF)" )
modem_options += ( "300-packet" "300 baud packet (HF)" )
fi
HAS_MODEM73_CONFIG = ` grep Modem73Interface ~/.reticulum/config`
if [ [ $? -eq 0 ] ] ; then
2026-06-30 13:55:50 -07:00
modem_options += ( "modem73-reliability" "Max reliability (Slower Speed) [BPSK]" )
modem_options += ( "modem73-balanced" "Balanced (Reliability and Speed) [QPSK] RECOMENDED" )
modem_options += ( "modem73-fast" "Fast (Low Reliability) [8PSK]" )
modem_options += ( "modem73-faster" "Faster (Lower Reliability) [QAM16]" )
modem_options += ( "modem73-fastest" "Fastest (Lowest Reliability) [QAM64]" )
2026-06-28 16:22:28 -07:00
fi
2026-06-14 19:26:29 -07:00
modem_choice = $( dialog \
--clear \
--title "Reticulum Configuration" \
--menu "Select a modem" \
2026-06-30 14:00:46 -07:00
13 70 10 \
2026-06-14 19:26:29 -07:00
" ${ 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
2026-06-28 13:00:23 -07:00
300-packet)
2026-06-14 19:26:29 -07:00
et-log "Starting 300 baud packet modem"
start_and_wait_for_service et-service-direwolf-300
; ;
2026-06-28 13:00:23 -07:00
1200-packet)
2026-06-14 19:26:29 -07:00
et-log "Starting 1200 baud packet modem"
start_and_wait_for_service et-service-direwolf-simple
; ;
2026-06-30 13:55:50 -07:00
modem73-reliability)
et-log "Starting modem73 in reliability mode"
start_and_wait_for_service et-service-modem73-reliability
; ;
modem73-balanced)
et-log "Starting modem73 in balanced mode"
2026-06-28 13:00:23 -07:00
start_and_wait_for_service et-service-modem73-default
; ;
2026-06-30 13:55:50 -07:00
modem73-fast)
et-log "Starting modem73 in fast mode"
start_and_wait_for_service et-service-modem73-fast
; ;
modem73-faster)
et-log "Starting modem73 in faster mode"
start_and_wait_for_service et-service-modem73-faster
; ;
modem73-fastest)
et-log "Starting modem73 in fastest mode"
start_and_wait_for_service et-service-modem73-fastest
; ;
2026-06-14 19:26:29 -07:00
*)
et-log "No modem specified"
; ;
esac
fi
fi
2026-06-14 18:02:28 -07:00
2026-06-14 18:35:14 -07:00
et-log "Updating configuration for this session..."
2026-06-28 16:46:46 -07:00
############################################################
# MODEM73 interface updates
############################################################
# Enable/disable intereface based on PnP device detection
IS_MODEM73_RUNNING = ` ps -ef | grep [ m] odem73`
if [ [ $? -eq 0 ] ] ; then
INTERFACE_MODEM73_ENABLED = "yes"
else
INTERFACE_MODEM73_ENABLED = "no"
fi
sed -i " s|{{ET_RETICULUM_INTERFACE_MODEM73_ENABLED}}| ${ INTERFACE_MODEM73_ENABLED } |g " ${ RETICULUM_CONF_FILE }
2026-06-14 18:35:14 -07:00
############################################################
# 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
2026-06-14 18:02:28 -07:00
[ [ -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 }
2026-06-14 18:35:14 -07:00
############################################################
2026-06-14 18:24:55 -07:00
# RNode (LoRA) interface updates
2026-06-14 18:35:14 -07:00
############################################################
2026-06-15 08:22:42 -07:00
# Enable/disable intereface based on PnP device detection
2026-06-15 08:14:44 -07:00
if [ [ -e " ${ ET_DEVICE_LORA } " ] ] ; then
2026-06-14 18:24:55 -07:00
INTERFACE_RNODE_ENABLED = "yes"
2026-06-15 08:22:42 -07:00
# 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 }
2026-06-14 18:24:55 -07:00
else
INTERFACE_RNODE_ENABLED = "no"
fi
2026-06-15 08:22:42 -07:00
2026-06-14 18:24:55 -07:00
sed -i " s|{{ET_RETICULUM_INTERFACE_RNODE_ENABLED}}| ${ INTERFACE_RNODE_ENABLED } |g " ${ RETICULUM_CONF_FILE }
2026-05-12 07:40:35 -07:00
2026-06-14 18:02:28 -07:00
CMD = "rnsd"
et-log " Starting Reticulum: ${ CMD } "
2026-05-12 07:40:35 -07:00
2026-06-14 18:02:28 -07:00
${ CMD }