#!/bin/bash # # Author : Gaston Gonzalez # Date : 3 November 2024 # Updated : 13 October 2025 # Purpose : Wrapper script for starting YAAC with PnP support # # Preconditions: # 1. Supported radio and audio interface are connected and properly detected # 2. Dire Wolf is started or Bluetooth TNC is connected # # Postconditions: # 1. Callsign is updated in YAAC # 2. YAAC is started YAAC_CONF_DIR=${HOME}/.java/.userPrefs/org/ka2ddo/yaac YAAC_CONF_FILE_PORTS=${YAAC_CONF_DIR}/Ports/prefs.xml YAAC_CONF_FILE_PORTS_TEMPLATE=/etc/skel/.java/.userPrefs/org/ka2ddo/yaac/Ports/prefs.xml usage() { echo "usage: $(basename $0) " echo " " echo " start - Start YAAC" echo " update-config - Update configuration for selected mode" } if [ $# -ne 1 ]; then usage exit 1 fi notify_user() { notify-send \ -t 5000 \ --app-name="EmComm Tools" \ "$1" } start() { update-config if [[ $? -eq 0 ]]; then CMD="java -Xms2g -Xmx6g -XX:+UseG1GC -jar /opt/yaac/YAAC.jar" PS_OUT=$(ps -ef | grep "[r]fcomm0") if [[ $? -eq 0 ]]; then et-log "Starting YAAC in Bluetooth mode with: ${CMD}" ${CMD} fi PS_OUT=$(ps -ef | grep [d]irewolf) if [[ $? -eq 0 ]]; then et-log "Starting YAAC in Dire Wolf mode with: ${CMD}" ${CMD} else et-log "Can't start YAAC. Dire Wolf or Bluetooth TNC services not running." exit 1 fi else et-log "Error updating configuration. Can't start YAAC" exit 1 fi } update-config () { [ -z "$ET_USER_CONFIG" ] && ET_USER_CONFIG="${HOME}/.config/emcomm-tools/user.json" CALLSIGN=$(cat ${ET_USER_CONFIG} | jq -r .callsign) if [ "${CALLSIGN}" = "N0CALL" ]; then notify_user "Can't start YAAC. No callsign set. Run: et-user." exit 1 fi et-log "Updating YAAC ports file: ${YAAC_CONF_FILE_PORTS}..." cp -v ${YAAC_CONF_FILE_PORTS_TEMPLATE} ${YAAC_CONF_FILE_PORTS} sed -i "s|{{ET_CALLSIGN}}|${CALLSIGN}|g" ${YAAC_CONF_FILE_PORTS} # Add GPS port only if it is available systemctl status gpsd --no-pager > /dev/null if [[ $? -ne 0 ]]; then et-log "GPS not connected. Removing GPS port from configuration." sed -i '/GPSD/d' ${YAAC_CONF_FILE_PORTS} fi PS_OUT=$(ps -ef | grep "[r]fcomm0") if [[ $? -ne 0 ]]; then et-log "Bluetooth TNC not connected. Removing rfcomm port from configuration." sed -i '/Serial_TNC/d' ${YAAC_CONF_FILE_PORTS} fi PS_OUT=$(ps -ef | grep "[d]irewolf") if [[ $? -ne 0 ]]; then et-log "Dire Wolf not running. Removing KISS over TCP port from configuration." sed -i '/KISS-over-TCP/d' ${YAAC_CONF_FILE_PORTS} fi echo "Generated the configuration below..." echo cat ${YAAC_CONF_FILE_PORTS} echo } case $1 in start) start ;; update-config) update-config ;; *) echo "Invalid command." usage exit 1 ;; esac