It appears you are running a shell script to continuously monitor if DYN DNS service is updating. If the script detects that the status hasn't changed after 2 seconds, it sends an email to all three target channels, reporting a successful update and the relevant output lines.
You can modify this script to suit your specific needs. However, keep in mind that it's recommended to run scripts using sudo privileges to avoid potential security issues. Also, consider adding error handling code to ensure the script doesn't crash if any of the communication channels fail.
For example:
``
bash
#!/bin/bash
# Define variables for target channels and email recipient
TelegramChannel="1003980922525"
DiscordChannel="1511697499654459422"
TargetRecipient="telegram:-1003980922525,discord:1511697499654459422"
# Loop indefinitely until the script is interrupted
while true
do
# Send signal to run the email notification code if no change was made in 1 second
if [ -z "$(if [ -n "${START_TIME}"; then echo "0; $(date +%s)" | while read start_time; do end_time; done <<< "$START_TIME"); then
sleep 1
if (($(time=$(uuidgen) && date -f "%b %d @%H:%M" < <(echo "$time") ; echo "(" $2 ", $3 ") " | jq -r '. // .time') != $(uuidgen)) && (( time=$(date +%s) )); then
echo '{"message": "{\"body\": \" DynDNS updated successfully!\"}", "status": "${2}"}' | xjq -R '.' -c '$.result'
fi
sleep 0
else
START_TIME=$(date +%s)
fi ] | curl --force-https://api telegram.com/v2/channels/$TelegramChannel/rooms/$TargetRecipient/messages.json?)
elif [ -z "$(if [ -n "${END_TIME}"; then echo "1; $(date +%s)" | while read end_time; do sleep $end_time seconds; done <<< "$END_TIME"); then
sleep 1
if (($(time=$(uuidgen) && date -f "%b %d @%H:%M" < <(echo "$time") ; echo "(" $2 ", $3 ") " | jq -r '. // .time') != $(uuidgen)) && (( time=$(date +%s) )); then
echo '{"message":("{\"body\": \" DynDNS updated successfully!\"}", "status": "${2}"}' | xjq -R '.' -c '$.result'
fi
sleep 0
else
END_TIME=$(date +%s)
fi ]
elif [ $(($(time=$(uuidgen) && date -f "%b %d @%H:%M" < <(echo "$time") ; echo "(" $2 ", $3 ") " | jq -r '. // .time') != $(uuidgen)) ] -lt (($(time=$(uuidgen) && date -f "%b %d @%H:%M" < <(echo "$time") ; echo "(" $2 ", $3 ") " | jq -r '. // .time') )); then
echo '{"message": "{\"body\": \" DynDNS updated successfully!\"}", "status": "${2}"}' | xjq -R '.' -c '$.result'
done
# Update the schedule every second to check for updates
sleep 1
done
`
This script assumes that DYN DNS Status: NO_CHANGE
is an error indicator, and it sets a flag when no change is detected in any target channel after 2 seconds.
Please replace TelegramChannel
, DiscordChannel
, and TargetRecipient` with your actual values to work with. The script will send notifications as described in the instructions. Also, make sure to adjust the URL for error messages according to how you received them earlier (e.g., Telegram API endpoint).