aboutsummaryrefslogtreecommitdiffstats
path: root/templates/usr_local_bin_do_dyndns.sh.j2
diff options
context:
space:
mode:
authorJan Tuomi <jan@jantuomi.fi>2025-10-06 09:55:22 +0300
committerJan Tuomi <jan@jantuomi.fi>2025-10-06 10:42:16 +0300
commit5adcc04e4c3441de8258b29216411bb53a709c0f (patch)
tree5ccc8ad26eb5f632f79ccdc6f8d0190190ccde07 /templates/usr_local_bin_do_dyndns.sh.j2
parentae9be6373428471dd4c95f64741b990638c272c0 (diff)
Work on Hetzner DDNS
Diffstat (limited to 'templates/usr_local_bin_do_dyndns.sh.j2')
-rw-r--r--templates/usr_local_bin_do_dyndns.sh.j242
1 files changed, 0 insertions, 42 deletions
diff --git a/templates/usr_local_bin_do_dyndns.sh.j2 b/templates/usr_local_bin_do_dyndns.sh.j2
deleted file mode 100644
index f23d635..0000000
--- a/templates/usr_local_bin_do_dyndns.sh.j2
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/bin/sh
-set -eu
-
-DOMAIN="jan.systems"
-HOSTNAME="pursotin"
-AUTH_FILE="/usr/local/etc/do_dyndns_auth"
-IF4="$(jexec ingress ifconfig epw1b)"
-
-# END OF CONFIG
-
-info() {
- echo "$(date) [INFO]" $@
-}
-
-err() {
- >&2 echo "$(date) [ERROR]" $@
-}
-
-if [ ! -r "$AUTH_FILE" ]; then
- err "Auth file '$AUTH_FILE' not readable"
- exit 1
-fi
-
-IP4=$(echo "$IF4" | awk '/inet / { print $2 }' | head -n1)
-DIGITALOCEAN_TOKEN=$(awk '{$1=$1; print}' "$AUTH_FILE")
-
-info "Updating A record for hostname $HOSTNAME in domain $DOMAIN → $IP4"
-
-RECORD_ID=$(curl -s -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
-"https://api.digitalocean.com/v2/domains/$DOMAIN/records?per_page=999999" |
-jq -r ".domain_records[] | select(.type==\"A\" and .name==\"$HOSTNAME\") | .id")
-
-if [ -n "$RECORD_ID" ]; then
- curl -s -X PUT \
- -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
- -H "Content-Type: application/json" \
- -d "{\"data\":\"$IP4\"}" \
- "https://api.digitalocean.com/v2/domains/$DOMAIN/records/$RECORD_ID" > /dev/null
- info "Record $RECORD_ID updated"
-else
- err "No A record found for hostname \"$HOSTNAME\" in domain \"$DOMAIN\". Skipping."
-fi