homelab/roles/base/templates/duckdns.sh.j2

21 lines
435 B
Plaintext
Raw Normal View History

#!/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')
2020-08-27 01:00:08 +00:00
result=$(curl --silent $url)
if [ "$result" = "OK" ]; then
echo "[$time] OK" >> $log
else
echo "[$time] ERROR: $result" >> $log
fi