MADD/monitor.sh

15 lines
436 B
Bash
Raw Normal View History

2025-08-09 23:10:49 +02:00
#!/usr/bin/env bash
interface="${MADD_INTERFACE:-"eth0"}"
interface="wlp0s20f3"
2025-08-09 23:10:49 +02:00
client_script="${MADD_CLIENT_SCRIPT:-"./client.sh"}"
ip -4 monitor address label dev "$interface" | while read event; do
2025-08-09 23:10:49 +02:00
if [[ $event == \[ADDR\]* ]]; then
ipv4=$(ip -4 addr show dev "$interface" | grep -Po 'inet \K[\d.]+')
2025-08-09 23:10:49 +02:00
if [ -n "$ipv4" ]; then
export MADD_IP="$ipv4"
$client_script
fi
fi
done