#!/usr/bin/env bashset -euo pipefailif [ $( sysctl -a | awk '/net.inet.carp.allow/ {print $2}' ) -ne 1 ];then echo "Carp is not enabled"; exit 0;fiif [ ! -f /conf/config.xml ];then echo "Unable to find Opnsense config"; exit 1; fiDEMOTE=$( sysctl -a | awk '/net.inet.carp.demotion/ {print $2}' );PREEMPT=$( sysctl -a | awk '/net.inet.carp.preempt/ {print $2}' );if [ ${DEMOTE} -gt 0 ];then echo "Stopping MDNS Repeater on demoted CARP member"; service mdns-repeater stopelse if [ ${PREEMPT} -eq 0 ]; then echo "Stopping MDNS Repeater on non-primary CARP member"; service mdns-repeater stop fifi