Update monitor_interface

This commit is contained in:
bergware
2025-06-09 03:58:08 +02:00
parent 0ac54ef534
commit 68885c93ec
+7 -4
View File
@@ -58,10 +58,11 @@ while :; do
for i in ${!TASK[@]}; do
ADDR=(${TASK[$i]})
PORT=${ADDR[0]}
ADDR=${ADDR[1]%/*}
[[ $LAST != ${PORT%.*} ]] && STATE=$(state ${PORT%.*})
case $STATE in
1) # up
case ${ADDR[1]} in
case $ADDR in
GW4)
# no existing default and new default is defined?
IPV4=$(ip -4 -br addr show scope global primary dev $PORT | awk '{print $3;exit}')
@@ -79,7 +80,7 @@ while :; do
fi
;;
*)
IPA=$(ip -br addr show to ${ADDR[1]} dev $PORT)
IPA=$(ip -br addr show to $ADDR dev $PORT)
if [[ -f /var/tmp/$PORT.down ]]; then
# Special treatment for shim and vhost interfaces
[[ -n $IPA ]] && ip addr del dev ${TASK[$i]}
@@ -91,8 +92,10 @@ while :; do
esac
;;
0) # down
# IP address present, remove it
[[ -n $(ip -br addr show to ${ADDR[1]} dev $PORT) ]] && ip addr del dev ${TASK[$i]}
if [[ $ADDR != GW4 && $ADDR != GW6 ]]; then
# IP address present, remove it
[[ -n $(ip -br addr show to $ADDR dev $PORT) ]] && ip addr del dev ${TASK[$i]}
fi
;;
esac
LAST=${PORT%.*}