diff --git a/overlay/opt/emcomm-tools/bin/et-chattervox b/overlay/opt/emcomm-tools/bin/et-chattervox new file mode 100755 index 0000000..d2c6886 --- /dev/null +++ b/overlay/opt/emcomm-tools/bin/et-chattervox @@ -0,0 +1,153 @@ +#!/bin/bash +# +# Author : Gaston Gonzalez +# Date : 5 December 2024 +# Updated : 6 December 2024 +# Purpose : Wrapper script for starting chattervox with PnP support +# +# Preconditions: +# 1. Supported radio and audio interface are connected and properly detected +# 2. Dire Wolf is started +# +# Postconditions: +# 1. On first start, configuration is created and signing key is generated. +# 2. chattervox is started in chat mode + +CHATTERVOX_CONF_DIR=${HOME}/.chattervox +CHATTERVOX_CONF_FILE=${CHATTERVOX_CONF_DIR}/config.json +CHATTERVOX_KEYSTORE_FILE=${CHATTERVOX_CONF_DIR}/keystore.json + +usage() { + echo "usage: $(basename $0) " + echo " " + echo " start - Start chat" + 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" +} + +generate_config() { + + CALLSIGN=$(cat ${ET_USER_CONFIG} | jq -r .callsign) + +cat < "${CHATTERVOX_CONF_FILE}" +{ + "version": 3, + "callsign": "${CALLSIGN}", + "ssid": 0, + "keystoreFile": "${HOME}/.chattervox/keystore.json", + "kissPort": "kiss://localhost:8001", + "kissBaud": 9600, + "feedbackDebounce": 20000 +} +EOF + + # Generate keystore file if it does not exist + if [ ! -e ${CHATTERVOX_KEYSTORE_FILE} ]; then + chattervox genkey + fi + + # Grab existing or newly generated signing key if available + SIGNING_KEY=$(cat ${CHATTERVOX_KEYSTORE_FILE} | jq -e -r .${CALLSIGN}[0].public) + if [ $? -ne 0 ]; then + et-log "Generating signing key for ${CALLSIGN}..." + chattervox genkey + SIGNING_KEY=$(cat ${CHATTERVOX_KEYSTORE_FILE} | jq -e -r .${CALLSIGN}[0].public) + else + et-log "Signing key already exits for ${CALLSIGN}." + fi + + +cat < "${CHATTERVOX_CONF_FILE}" +{ + "version": 3, + "callsign": "${CALLSIGN}", + "ssid": 0, + "keystoreFile": "${HOME}/.chattervox/keystore.json", + "kissPort": "kiss://localhost:8001", + "kissBaud": 9600, + "feedbackDebounce": 20000, + "signingKey": "${SIGNING_KEY}" +} +EOF +} + +start() { + update-config + + if [ $? -eq 0 ]; then + + RIGCTLD_OUT=$(ps -ef | grep [d]irewolf) + if [ $? -ne 0 ]; then + et-log "Can't start chattervox. Dire Wolf not running." + notify_user "Can't start chattervox. Dire Wolf not running." + exit 1 + fi + + CWD_DIR=$(pwd) + + CMD="chattervox chat" + et-log "Starting chattervox with: ${CMD}" + + ${CMD} + + else + et-log "Error updating configuration. Can't start chattervox" + 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 chattervox. No callsign set. Run: et-user." + exit 1 + fi + + [ ! -e ${CHATTERVOX_CONF_DIR} ] && mkdir ${CHATTERVOX_CONF_DIR} + + if [ ! -e ${CHATTERVOX_CONF_FILE} ]; then + et-log "chattervox configuration does not exist creating: ${CHATTERVOX_CONF_FILE}..." + generate_config + + else + et-log "Chattervox configuration already exists, checking for change in et-user..." + + CUR_CALLSIGN=$(cat ${ET_USER_CONFIG} | jq -r .callsign) + CONFIGURED_CALLSIGN=$(cat ${CHATTERVOX_CONF_FILE} | jq -r .callsign) + + if [ "${CUR_CALLSIGN}" != "${CONFIGURED_CALLSIGN}" ]; then + et-log "User callsign has changed from ${CUR_CALLSIGN} to ${CONFIGURED_CALLSIGN}" + generate_config + fi + + fi +} + +case $1 in + start) + start + ;; + update-config) + update-config + ;; + *) + echo "Invalid command." + usage + exit 1 + ;; +esac diff --git a/overlay/opt/emcomm-tools/bin/et-mode b/overlay/opt/emcomm-tools/bin/et-mode index 91b3352..9b3d988 100755 --- a/overlay/opt/emcomm-tools/bin/et-mode +++ b/overlay/opt/emcomm-tools/bin/et-mode @@ -2,7 +2,7 @@ # # Author : Gaston Gonzalez # Date : 6 November 2024 -# Updated : 3 December 2024 +# Updated : 5 December 2024 # Purpose : Configures the system for a specific mode of operation # Use a simple text file to save the state of the last mode selected @@ -13,6 +13,7 @@ MODE_ID_NONE="none" MODE_ID_APRS_DIGIPEATER="aprs-digipeater" MODE_ID_APRS_CLIENT="aprs-client" MODE_ID_BBS_CLIENT="bbs-client" +MODE_ID_CHAT_CLIENT="chat-chattervox" MODE_ID_PACKET_DIGIPEATER="packet-digipeater" MODE_ID_WINLINK_ARDOP="winlink-ardop" MODE_ID_WINLINK_PACKET="winlink-packet" @@ -66,13 +67,14 @@ options=() options+=("${MODE_ID_NONE}" "No mode selected") options+=("${MODE_ID_APRS_CLIENT}" "APRS Client (YAAC)") options+=("${MODE_ID_BBS_CLIENT}" "BBS Client (Paracon)") +options+=("${MODE_ID_CHAT_CLIENT}" "Chat (chattervox)") options+=("${MODE_ID_APRS_DIGIPEATER}" "APRS Digipeater") options+=("${MODE_ID_PACKET_DIGIPEATER}" "Packet Digipeater") options+=("${MODE_ID_WINLINK_ARDOP}" "Winlink over HF (ARDOP)") options+=("${MODE_ID_WINLINK_PACKET}" "Winlink over VHF/UHF (AX.25 Packet)") # Prompt user for option and save exit status -SELECTED_MODE=$(dialog --clear --menu "Select a mode:" 15 65 10 "${options[@]}" 3>&1 1>&2 2>&3) +SELECTED_MODE=$(dialog --clear --menu "Select a mode:" 16 65 10 "${options[@]}" 3>&1 1>&2 2>&3) exit_status=$? tput sgr 0 && clear @@ -100,6 +102,11 @@ if [ $exit_status -eq 0 ]; then et-log "Starting Paracon." et-paracon start ;; + ${MODE_ID_CHAT_CLIENT}) + start_and_wait_for_service et-service-direwolf-simple + et-log "Starting chattervox" + et-chattervox start + ;; ${MODE_ID_PACKET_DIGIPEATER}) systemctl --user start et-service-direwolf-packet-digipeater et-log "Packet digipeater now running." diff --git a/overlay/opt/emcomm-tools/bin/et-system-info b/overlay/opt/emcomm-tools/bin/et-system-info index 6b1f5e8..5a2329a 100755 --- a/overlay/opt/emcomm-tools/bin/et-system-info +++ b/overlay/opt/emcomm-tools/bin/et-system-info @@ -2,7 +2,7 @@ # # Author : Gaston Gonzalez # Date : 6 October 2024 -# Updated : 3 December 2024 +# Updated : 5 December 2024 # Purpose : Utility script for dumping system information function usage() { @@ -177,6 +177,7 @@ case $1 in MODE_ID_NONE="none" MODE_ID_APRS_DIGIPEATER="aprs-digipeater" MODE_ID_BBS_CLIENT="bbs-client" + MODE_ID_CHAT_CLIENT="chat-chattervox" MODE_ID_PACKET_DIGIPEATER="packet-digipeater" MODE_ID_APRS_CLIENT="aprs-client" MODE_ID_WINLINK_ARDOP="winlink-ardop" @@ -201,6 +202,9 @@ case $1 in ${MODE_ID_BBS_CLIENT}) echo "BBS Client" ;; + ${MODE_ID_CHAT_CLIENT}) + echo "Chat (chattervox)" + ;; ${MODE_ID_PACKET_DIGIPEATER}) echo "Packet Digipeater" ;; diff --git a/scripts/install-chattervox.sh b/scripts/install-chattervox.sh new file mode 100755 index 0000000..b73ec18 --- /dev/null +++ b/scripts/install-chattervox.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# +# Author : Gaston Gonzalez +# Date : 4 December 2024 +# Purpose : Install chattervox protocol +set -e +trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG +trap 'et-log "\"${last_command}\" command failed with exit code $?."' ERR + +. ./env.sh + +NAME=chattervox +VERSION=0.7.0 +TARBALL=chattervox-linux-x64.tar.gz +INSTALL_DIR="/opt/${NAME}-${VERSION}" +LINK_PATH="/opt/${NAME}" + +et-log "Installing ${NAME} ${VERSION}..." + +URL=https://github.com/brannondorsey/chattervox/releases/download/v${VERSION}/chattervox-linux-x64.tar.gz + +et-log "Downloading: ${URL}" +curl -s -L -o ${TARBALL} --fail ${URL} + +CWD_DIR=`pwd` + +tar -xzf ${TARBALL} + +if [ -e chattervox-linux-x64 ]; then + mv chattervox-linux-x64 ${INSTALL_DIR} + mkdir -p ${INSTALL_DIR}/bin + mv ${INSTALL_DIR}/chattervox ${INSTALL_DIR}/bin/ + mv ${INSTALL_DIR}/serialport.node ${INSTALL_DIR}/bin/ + rm -v ${TARBALL} +fi + +[ -e ${LINK_PATH} ] && rm ${LINK_PATH} +ln -s ${INSTALL_DIR} ${LINK_PATH} + +stow -v -d /opt ${NAME} -t /usr/local + +cd $CWD_DIR diff --git a/scripts/install.sh b/scripts/install.sh index 8ba3757..b5fb71a 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -2,7 +2,7 @@ # # Author : Gaston Gonzalez # Date : 16 March 2024 -# Updated : 28 November 2024 +# Updated : 4 December 2024 # Purpose : Main installer for EmComm Tools OS Community . ./env.sh @@ -40,6 +40,7 @@ exitIfNotRoot ./install-yaac.sh ./install-bbs-client.sh ./install-bbs-server.sh +./install-chattervox.sh # Install modems ./install-ardop.sh diff --git a/tests/test-chattervox.sh b/tests/test-chattervox.sh new file mode 100755 index 0000000..13f1d4d --- /dev/null +++ b/tests/test-chattervox.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# Author : Gaston Gonzalez +# Date : 4 December 2024 +# Purpose : Test chattervox installation + +OUT=$(chattervox -v | grep "0.7.0") +exit $?