From 17b5da11c21a65140fcd4b7419c9c11f9b88b155 Mon Sep 17 00:00:00 2001 From: Gaston Gonzalez Date: Thu, 5 Dec 2024 04:34:50 -0700 Subject: [PATCH 1/7] Chat - Initial installation of chattervox protocol --- scripts/install-chattervox.sh | 42 +++++++++++++++++++++++++++++++++++ scripts/install.sh | 3 ++- tests/test-chattervox.sh | 7 ++++++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100755 scripts/install-chattervox.sh create mode 100755 tests/test-chattervox.sh 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 $? From ef6dc91dcb47d157b4517f7b473123e845f4dd78 Mon Sep 17 00:00:00 2001 From: Gaston Gonzalez Date: Thu, 5 Dec 2024 04:46:01 -0700 Subject: [PATCH 2/7] Chat - Added chattervox to et-mode --- overlay/opt/emcomm-tools/bin/et-mode | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/overlay/opt/emcomm-tools/bin/et-mode b/overlay/opt/emcomm-tools/bin/et-mode index 91b3352..9e3681f 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" + chattervox chat + ;; ${MODE_ID_PACKET_DIGIPEATER}) systemctl --user start et-service-direwolf-packet-digipeater et-log "Packet digipeater now running." From 1c593841dd02a769f8623e1985db3d5e4d52147f Mon Sep 17 00:00:00 2001 From: Gaston Gonzalez Date: Thu, 5 Dec 2024 04:56:34 -0700 Subject: [PATCH 3/7] Chat - Added chattervox to system info --- overlay/opt/emcomm-tools/bin/et-system-info | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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" ;; From 2ae3c7a017213c4b6d3573c50e2dd5ca1e4357d1 Mon Sep 17 00:00:00 2001 From: Gaston Gonzalez Date: Thu, 5 Dec 2024 05:22:40 -0700 Subject: [PATCH 4/7] Chat - Zero-configuration support to chattervox --- overlay/opt/emcomm-tools/bin/et-chattervox | 105 +++++++++++++++++++++ overlay/opt/emcomm-tools/bin/et-mode | 2 +- 2 files changed, 106 insertions(+), 1 deletion(-) create mode 100755 overlay/opt/emcomm-tools/bin/et-chattervox diff --git a/overlay/opt/emcomm-tools/bin/et-chattervox b/overlay/opt/emcomm-tools/bin/et-chattervox new file mode 100755 index 0000000..a165c03 --- /dev/null +++ b/overlay/opt/emcomm-tools/bin/et-chattervox @@ -0,0 +1,105 @@ +#!/bin/bash +# +# Author : Gaston Gonzalez +# Date : 5 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. Callsign and KISS host updated +# 2. chattervox is started + +CHATTERVOX_CONF_DIR=${HOME}/.chattervox +CHATTERVOX_CONF_FILE=${CHATTERVOX_CONF_DIR}/config.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" +} + +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}..." + +cat < "${CHATTERVOX_CONF_FILE}" +{ + "version": 3, + "callsign": "${CALLSIGN}", + "ssid": 0, + "keystoreFile": "${HOME}/.chattervox/keystore.json", + "kissPort": "kiss://localhost:8001", + "kissBaud": 9600, + "feedbackDebounce": 20000 +} +EOF + + 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 9e3681f..9b3d988 100755 --- a/overlay/opt/emcomm-tools/bin/et-mode +++ b/overlay/opt/emcomm-tools/bin/et-mode @@ -105,7 +105,7 @@ if [ $exit_status -eq 0 ]; then ${MODE_ID_CHAT_CLIENT}) start_and_wait_for_service et-service-direwolf-simple et-log "Starting chattervox" - chattervox chat + et-chattervox start ;; ${MODE_ID_PACKET_DIGIPEATER}) systemctl --user start et-service-direwolf-packet-digipeater From b91d96ce8506ec06053a29ad062f74c82dcbd11f Mon Sep 17 00:00:00 2001 From: Gaston Gonzalez Date: Fri, 6 Dec 2024 06:37:22 -0700 Subject: [PATCH 5/7] Chat - Added support for adding the newly generated singing key to the chattervox configuration on first start --- overlay/opt/emcomm-tools/bin/et-chattervox | 24 +++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/overlay/opt/emcomm-tools/bin/et-chattervox b/overlay/opt/emcomm-tools/bin/et-chattervox index a165c03..762af2c 100755 --- a/overlay/opt/emcomm-tools/bin/et-chattervox +++ b/overlay/opt/emcomm-tools/bin/et-chattervox @@ -2,6 +2,7 @@ # # Author : Gaston Gonzalez # Date : 5 December 2024 +# Updated : 6 December 2024 # Purpose : Wrapper script for starting chattervox with PnP support # # Preconditions: @@ -9,11 +10,12 @@ # 2. Dire Wolf is started # # Postconditions: -# 1. Callsign and KISS host updated +# 1. On first start, configuration is created and signing key is generated. # 2. chattervox is started 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) " @@ -87,6 +89,26 @@ cat < "${CHATTERVOX_CONF_FILE}" } EOF + et-log "Generating signing key..." + chattervox genkey + + SIGNING_KEY=$(cat ${CHATTERVOX_KEYSTORE_FILE} | jq -e -r .${CALLSIGN}[0].public) + if [ $? -eq 0 ]; then + et-log "Adding signing key configuration..." + +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 + fi fi } From 802616de50f8b0dd2325bd26d8aa5d3bb178d53d Mon Sep 17 00:00:00 2001 From: Gaston Gonzalez Date: Fri, 6 Dec 2024 06:46:30 -0700 Subject: [PATCH 6/7] Chat - Added logic to detect if the callsign has changed since the configuration for chattervox was first generated --- overlay/opt/emcomm-tools/bin/et-chattervox | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/overlay/opt/emcomm-tools/bin/et-chattervox b/overlay/opt/emcomm-tools/bin/et-chattervox index 762af2c..c8f3175 100755 --- a/overlay/opt/emcomm-tools/bin/et-chattervox +++ b/overlay/opt/emcomm-tools/bin/et-chattervox @@ -109,6 +109,17 @@ cat < "${CHATTERVOX_CONF_FILE}" } EOF fi + + 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}" + fi + fi } From 30bc0729adb82dcb29499d84e6241d42f764408a Mon Sep 17 00:00:00 2001 From: Gaston Gonzalez Date: Fri, 6 Dec 2024 07:05:02 -0700 Subject: [PATCH 7/7] Chat - Refactored et-chattervox to include a generate method. Added support for updating the chattervox configuration following callsign changes using et-user --- overlay/opt/emcomm-tools/bin/et-chattervox | 83 +++++++++++++--------- 1 file changed, 49 insertions(+), 34 deletions(-) diff --git a/overlay/opt/emcomm-tools/bin/et-chattervox b/overlay/opt/emcomm-tools/bin/et-chattervox index c8f3175..d2c6886 100755 --- a/overlay/opt/emcomm-tools/bin/et-chattervox +++ b/overlay/opt/emcomm-tools/bin/et-chattervox @@ -11,7 +11,7 @@ # # Postconditions: # 1. On first start, configuration is created and signing key is generated. -# 2. chattervox is started +# 2. chattervox is started in chat mode CHATTERVOX_CONF_DIR=${HOME}/.chattervox CHATTERVOX_CONF_FILE=${CHATTERVOX_CONF_DIR}/config.json @@ -36,6 +36,52 @@ notify_user() { "$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 @@ -76,39 +122,7 @@ update-config () { if [ ! -e ${CHATTERVOX_CONF_FILE} ]; then et-log "chattervox configuration does not exist creating: ${CHATTERVOX_CONF_FILE}..." - -cat < "${CHATTERVOX_CONF_FILE}" -{ - "version": 3, - "callsign": "${CALLSIGN}", - "ssid": 0, - "keystoreFile": "${HOME}/.chattervox/keystore.json", - "kissPort": "kiss://localhost:8001", - "kissBaud": 9600, - "feedbackDebounce": 20000 -} -EOF - - et-log "Generating signing key..." - chattervox genkey - - SIGNING_KEY=$(cat ${CHATTERVOX_KEYSTORE_FILE} | jq -e -r .${CALLSIGN}[0].public) - if [ $? -eq 0 ]; then - et-log "Adding signing key configuration..." - -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 - fi + generate_config else et-log "Chattervox configuration already exists, checking for change in et-user..." @@ -118,6 +132,7 @@ EOF if [ "${CUR_CALLSIGN}" != "${CONFIGURED_CALLSIGN}" ]; then et-log "User callsign has changed from ${CUR_CALLSIGN} to ${CONFIGURED_CALLSIGN}" + generate_config fi fi