Fix incomplete MQTT_HOST patch logic for casesensitive creds PR#249 (#251)

* Fix incomplete MQTT_HOST patch logic for casesensitive credentials from PR#249

* minor efficiency improvement

---------

Co-authored-by: renini <renini@local>
Co-authored-by: kx1t <15090643+kx1t@users.noreply.github.com>
This commit is contained in:
renini
2025-08-05 16:07:49 +02:00
committed by GitHub
parent fd9193fb23
commit 0d0d234edc
2 changed files with 2 additions and 2 deletions

View File

@@ -483,7 +483,7 @@ if [[ "$(cat /tmp/pa-diff.csv | wc -l)" != "0" ]]; then
# prep the MQTT host, port, etc
unset MQTT_TOPIC MQTT_PORT MQTT_USERNAME MQTT_PASSWORD MQTT_HOST
MQTT_HOST="${MQTT_URL,,}"
MQTT_HOST="${MQTT_URL}"
MQTT_HOST="${MQTT_HOST##*:\/\/}" # strip protocol header (mqtt:// etc)
while [[ "${MQTT_HOST: -1}" == "/" ]]; do MQTT_HOST="${MQTT_HOST:0: -1}"; done # remove any trailing / from the HOST
if [[ $MQTT_HOST == *"/"* ]]; then MQTT_TOPIC="${MQTT_TOPIC:-${MQTT_HOST#*\/}}"; fi # if there's no explicitly defined topic, then use the URL's topic if that exists

View File

@@ -416,7 +416,7 @@ if [ -f "$CSVFILE" ]; then
# prep the MQTT host, port, etc
unset MQTT_TOPIC MQTT_PORT MQTT_USERNAME MQTT_PASSWORD MQTT_HOST
MQTT_HOST="${MQTT_HOST##*:\/\/}" # strip protocol header (mqtt:// etc)
MQTT_HOST="${MQTT_URL##*:\/\/}" # strip protocol header (mqtt:// etc)
while [[ "${MQTT_HOST: -1}" == "/" ]]; do MQTT_HOST="${MQTT_HOST:0:-1}"; done # remove any trailing / from the HOST
if [[ $MQTT_HOST == *"/"* ]]; then MQTT_TOPIC="${MQTT_TOPIC:-${MQTT_HOST#*\/}}"; fi # if there's no explicitly defined topic, then use the URL's topic if that exists
MQTT_TOPIC="${MQTT_TOPIC:-$(hostname)/planefence}" # add default topic if there is still none defined