mirror of
https://github.com/thetechprepper/emcomm-tools-os-community.git
synced 2026-09-17 15:41:44 -04:00
Chat - Refactored et-chattervox to include a generate method. Added support for updating the chattervox configuration following callsign changes using et-user
This commit is contained in:
@@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
# Postconditions:
|
# Postconditions:
|
||||||
# 1. On first start, configuration is created and signing key is generated.
|
# 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_DIR=${HOME}/.chattervox
|
||||||
CHATTERVOX_CONF_FILE=${CHATTERVOX_CONF_DIR}/config.json
|
CHATTERVOX_CONF_FILE=${CHATTERVOX_CONF_DIR}/config.json
|
||||||
@@ -36,6 +36,52 @@ notify_user() {
|
|||||||
"$1"
|
"$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
generate_config() {
|
||||||
|
|
||||||
|
CALLSIGN=$(cat ${ET_USER_CONFIG} | jq -r .callsign)
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
# 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 <<EOF > "${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() {
|
start() {
|
||||||
update-config
|
update-config
|
||||||
|
|
||||||
@@ -76,39 +122,7 @@ update-config () {
|
|||||||
|
|
||||||
if [ ! -e ${CHATTERVOX_CONF_FILE} ]; then
|
if [ ! -e ${CHATTERVOX_CONF_FILE} ]; then
|
||||||
et-log "chattervox configuration does not exist creating: ${CHATTERVOX_CONF_FILE}..."
|
et-log "chattervox configuration does not exist creating: ${CHATTERVOX_CONF_FILE}..."
|
||||||
|
generate_config
|
||||||
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
|
|
||||||
|
|
||||||
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 <<EOF > "${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
|
|
||||||
|
|
||||||
else
|
else
|
||||||
et-log "Chattervox configuration already exists, checking for change in et-user..."
|
et-log "Chattervox configuration already exists, checking for change in et-user..."
|
||||||
@@ -118,6 +132,7 @@ EOF
|
|||||||
|
|
||||||
if [ "${CUR_CALLSIGN}" != "${CONFIGURED_CALLSIGN}" ]; then
|
if [ "${CUR_CALLSIGN}" != "${CONFIGURED_CALLSIGN}" ]; then
|
||||||
et-log "User callsign has changed from ${CUR_CALLSIGN} to ${CONFIGURED_CALLSIGN}"
|
et-log "User callsign has changed from ${CUR_CALLSIGN} to ${CONFIGURED_CALLSIGN}"
|
||||||
|
generate_config
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user