routeros: Add verbose option to PoE MQTT script

This commit is contained in:
Timo Makinen 2025-07-15 17:32:23 +00:00
parent 8c99bb1323
commit df5ecb1a04

View file

@ -3,6 +3,11 @@
set -eu
umask 077
_verbose=false
if [ "${1:-}" = "-v" ]; then
_verbose=true
fi
community="public"
tlsdir="$(openssl version -d | sed -e 's/^OPENSSLDIR: "\(.\+\)"$/\1/')"
cafile="${tlsdir}/certs/ca.crt"
@ -15,6 +20,7 @@ export LDAPTLS_CERT="$certfile"
mqtt_send() {
topic="$1"
value="$2"
[ $_verbose ] && echo "Publishing data for ${topic}"
mosquitto_pub -h mqtt02.home.foo.sh -t "$topic" -m "$value" \
--cafile "$cafile" --key "$keyfile" --cert "$certfile"
}
@ -29,6 +35,7 @@ snmp_get() {
if [ "${1:-}" != "-f" ]; then
for state in /run/keepalived/*.state ; do
if [ "$(cat "$state")" != "MASTER" ]; then
[ $_verbose ] && echo "Not running as master, skipping run"
exit 0
fi
break