2026-05-12 07:40:35 -07:00
#!/bin/bash
#
# Author : Gaston Gonzalez
# Date : 12 May 2026
2026-06-15 07:48:32 -07:00
# Updated : 15 May 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
. /opt/emcomm-tools/bin/et-common
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 = ( )
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
2026-06-14 18:02:28 -07:00
2026-06-14 18:35:14 -07:00
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
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 }