You've provided a script to monitor your DynDNS update status using the Hermetic CRM plugin for cron jobs. The script sends out notifications based on the following conditions:
1. If there is no changes (
STATUS:NO_CHANGE): Send nothing.
2. If an error occurs: Send warnings for Telegram, Discord, and your personal DM.
3. If updates are successful, send confirmation messages to all three targets.
To run this script efficiently and handle any errors that may occur, it's essential to set up alerts and filters before running the script on a regular basis. Additionally, consider setting up notifications via email or SMS if you prefer a more traditional notification method.
Here is an example
cf-dyndns.sh script that follows the instructions provided:
``
bash
#!/bin/bash
# Create your DynDNS information here (e.g., IP address, name, username)
DynDNS_INFO="your dyndns ip address here"
# Define the targets you want to notify
TARGETS=("https://telegraftools.com/Dynomains/$DynDNS_INFO/whatsapp:+100****2525" \
"https://discordapp.com/api/webhooks/1511697499654459422/${DynDNS_INFO}:Discord" \
"https://telegram.com/bot?bot=${DynDNS_INFO}&username=Your+Name")
# Check for updates every 1 minute
while true; do
# Send notifications if necessary
for target in "${TARGETS[@]}"; do
status=$(echo "$target" | cut -d':' -f2)
if [ "$status" != "SUCCESS:" ]; then
echo ""
continue
fi
case $_target in
https://telegraftools.com/Dynomains/$DynDNS_INFO/whatsapp:+100****2525)
echo ""
;;
https://discordapp.com/api/webhooks/1511697499654459422/${DynDNS_INFO}:Discord)
echo ""
;;
https://telegram.com/bot?bot=${DynDNS_INFO}&username=Your+Name)
echo $status
;;
esac
echo -n "NOTIFICATION $(echo "$target" | cut -d':' -f1) $status"
# Send notification to the user using a default notification service
if [ ! -z "${TARGETS[-1]}" ] && [[ "${TARGETS[-1]}" =~ ^https[:] ]]; then
echo "[SILENT]" >> /root/.hermes/skills/cf-dyndns.sh.$("${TARGETS[-1]}")
elif [ "$target" == "SUCCESS:" ]; THEN # Success message with an updated output from DynDNS
echo "Updating successfully. Here's the latest output from DynDNS"
sed -n "/^STATUS: NO_CHANGE/p" < /root/.hermes/skills/cf-dyndns.sh.$("${TARGETS[0]}") | paste -sd "\n"
else
echo "[ERROR] The system received an unexpected status ($status). This may be due to a delay in the output from DynDNS. Please consider restarting the script."
sleep 10; # Wait for 10 seconds before rechecking.
fi
# Only recheck every minute (not true here as this is a one-time loop)
done
done
`
Feel free to check your cf-dyndns.sh
file manually in your cron's job list. Note that DYNDNS_INFO
, (targets), and the notification delivery options such as email, Telegram/WhatsApp/Discord messages are not specified here for simplicity.
Use a secure method like encryption or OAuth from the Hermetic CRM API to sign keys or credentials if desired.
Note: It seems you've provided multiple target variables instead of including one per variable (as indicated in line 21-22). Make sure those are filled with valid target identifiers, such as '
https://telegram.com/bot?bot=...':``
bash
TARGETS=("telgrift://+100****2525 1" \
"wsgi://DiscordBot@your-dns-dry-run.com")
``