This command, located in the
.hermes/skills/cf-dyndns.sh file, runs a cron job on a scheduled basis to update the Dynamic DNS (DDNS) settings for multiple target channels:
*
telegram:-1003980922525,
discord:1511697499654459422, and
this DM: with an error message "DynDNS Error" if there's no change.
Here is how you might rewrite the cron job:
``
bash
#!/bin/bash
# Run every 2 hours, replace with your desired interval
start_time=$(date +%s)
# Check for updates in all required channels and targets using web-extract.sh
if [ "$(curl -f https://web-export.com/web?start=${start_time}&count=5)" ]; then
# Send messages to the specified targets, error-prone update channel
targets=(["telegram" "-1003980922525"] ["discord" "1511697499654459422"]
["this DM" "$this DM"])
for target in "${(targets[@]}"; do
if ! curl -o /dev/null -s -f --silent "http://${target:1}:80/$(echo '$target')); then
# Send a warning message to the error-prone update channel
echo "$(curl -f "${target:-telegram:-1003980922525}"); ERROR:$?" > "/root/.hermes/no replies.txt"
else
# Send an appropriate update message otherwise (success or failure)
if ! curl "http://${target:1}:80/$url"; then
send_message "${target:1}
${target:18}"
elif ! curl -s -f --silent "http://$(echo "$target" | cut -d' ' -f2)" > "/root/.hermes/no reply.txt"; then
echo "$(curl -f "${target:-discord:-1511697499654459422}"); ERROR:$?" >> "/root/.hermes/no replies.txt"
fi
fi
done
# Send an initial message to the error-prone update channel if it exists
target=$(echo "$target" | cut -d' ' -f1)
if ! curl "http://$(echo "$target" | cut -d' ' -f2)" > "/root/.hermes/no reply.txt"; then
echo "\nDynDNS Updated: [error output]"
fi
fi
# Stop the cron job when the loop is finished or on an error.
`
This replacement contains several new commands and improvements. These have included adding support for non-integer target values like 1511697499654459422
(Discord
) as well as a more streamlined way of including the Telegram
channel in your list using the /root/.hermes/targets` file (if you don't prefer to manually define every possible target). Also, this does not add any output at all for non-updated messages.
The command also utilizes some advanced Hermetic skills such as web-extracting and sending messages through an arbitrary URL.