From 894f69f82f2cff5505e63c9c8915fbff7178f014 Mon Sep 17 00:00:00 2001 From: Timo Makinen Date: Sat, 26 Apr 2025 20:04:49 +0000 Subject: [PATCH] routeros: Add force option to mqtt publish script --- roles/routeros/files/routeros-poe-mqtt-publish.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/roles/routeros/files/routeros-poe-mqtt-publish.sh b/roles/routeros/files/routeros-poe-mqtt-publish.sh index 1b5afd5..d622f2a 100644 --- a/roles/routeros/files/routeros-poe-mqtt-publish.sh +++ b/roles/routeros/files/routeros-poe-mqtt-publish.sh @@ -23,12 +23,14 @@ snmp_get() { } # only run script if first vrrp interface is in master state -for state in /run/keepalived/*.state ; do - if [ "$(cat "$state")" != "MASTER" ]; then - exit 0 - fi - break -done +if [ "${1:-}" != "-f" ]; then + for state in /run/keepalived/*.state ; do + if [ "$(cat "$state")" != "MASTER" ]; then + exit 0 + fi + break + done +fi ldapsearch -Q -LLL "(&(objectClass=device)(description=MikroTik *))" cn | \ awk '{ if ($1 == "cn:") print $2 }' | while read -r name