Update DuckDNS subdomain with dynamic IP
This commit is contained in:
20
roles/base/templates/duckdns.sh.j2
Normal file
20
roles/base/templates/duckdns.sh.j2
Normal 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
|
Reference in New Issue
Block a user