routeros: Add verbose option to PoE MQTT script
This commit is contained in:
parent
8c99bb1323
commit
df5ecb1a04
1 changed files with 7 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue