48 lines
1.1 KiB
Bash
Executable File
48 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
# Script Version: 07
|
|
# Description: Monitor SOA for dynproxy.net and play a sound when it changes to ns1.dynproxy.net.
|
|
|
|
# Set variables
|
|
# ========
|
|
DOMAIN="dynproxy.net"
|
|
EXPECTED_NS="ns1.dynproxy.net."
|
|
SOUND_CMD="paplay /usr/share/sounds/freedesktop/stereo/alarm-clock-elapsed.oga"
|
|
CHECK_INTERVAL=60 # Interval in seconds
|
|
|
|
# Functions
|
|
# ========
|
|
get_soa() {
|
|
dig "$DOMAIN" SOA +short | awk '{print $1}'
|
|
}
|
|
|
|
play_sound() {
|
|
$SOUND_CMD
|
|
}
|
|
|
|
# Main Process
|
|
# ========
|
|
echo "Monitoring SOA for $DOMAIN. Expected NS: $EXPECTED_NS"
|
|
LAST_SOA=""
|
|
|
|
while true; do
|
|
CURRENT_SOA=$(get_soa)
|
|
|
|
if [[ -z "$CURRENT_SOA" ]]; then
|
|
echo "Error fetching SOA record. Network issue or domain unreachable."
|
|
sleep $CHECK_INTERVAL
|
|
continue
|
|
fi
|
|
|
|
if [[ "$CURRENT_SOA" != "$LAST_SOA" ]]; then
|
|
echo "SOA changed! New SOA: $CURRENT_SOA"
|
|
LAST_SOA="$CURRENT_SOA"
|
|
|
|
if [[ "$CURRENT_SOA" == "$EXPECTED_NS" ]]; then
|
|
echo "SOA matches expected NS. Playing sound..."
|
|
play_sound
|
|
fi
|
|
fi
|
|
sleep $CHECK_INTERVAL
|
|
done
|
|
|