Update DuckDNS subdomain with dynamic IP

This commit is contained in:
2020-08-26 20:26:05 -04:00
parent 97d920d09d
commit 10a39235bb
3 changed files with 35 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
#!/bin/bash
domains="{{ duckdns.domains }}"
token="{{ duckdns.token }}"
{% if duckdns.logfile is undefined -%}
log="/var/log/duckdns.log"
{% else -%}
log="{{ duckdns.logfile }}"
{% endif %}
url="https://www.duckdns.org/update?domains=$domains&token=$token&ip="
time=$(date '+%Y%m%d-%H%M%S')
result=$(curl $url)
if [ "$result" = "OK" ]; then
echo "[$time] OK" >> $log
else
echo "[$time] ERROR: $result" >> $log
fi