mirror of
https://github.com/thetechprepper/emcomm-tools-os-community.git
synced 2026-09-17 15:41:44 -04:00
Chat - Zero-configuration support to chattervox
This commit is contained in:
Executable
+105
@@ -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) <command>"
|
||||
echo " <command>"
|
||||
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 <<EOF > "${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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user