Browse Source

🚀

master
Jan Koppe 3 months ago
parent
commit
a036275ce4
Signed by: Jan Koppe <post@jankoppe.de> GPG Key ID: BE935B0735A2129B
1 changed files with 21 additions and 0 deletions
  1. 21
    0
      do-dyndns.sh

+ 21
- 0
do-dyndns.sh View File

@@ -0,0 +1,21 @@
1
+#!/bin/bash
2
+
3
+DOMAIN=${1}
4
+RECORD=${2}
5
+API_TOKEN=${3}
6
+
7
+[[ ! -z $DOMAIN ]] || exit 1;
8
+[[ ! -z $RECORD ]] || exit 1;
9
+[[ ! -z $API_TOKEN ]] || exit 1;
10
+
11
+IPV4=$(curl -s https://ip4.seeip.org)
12
+IPV6=$(curl -s https://ip6.seeip.org)
13
+
14
+[[ $IPV4 =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]] || exit 1;
15
+# TODO: validate ipv6 response
16
+
17
+ID_IPV4=$(doctl -t ${API_TOKEN} compute domain records list --no-header --format ID,Type,Name ${DOMAIN} | grep ${RECORD} | grep " A " | cut -d' ' -f 1)
18
+ID_IPV6=$(doctl -t ${API_TOKEN} compute domain records list --no-header --format ID,Type,Name ${DOMAIN} | grep ${RECORD} | grep " AAAA " | cut -d' ' -f 1)
19
+
20
+doctl -t ${API_TOKEN} compute domain records update ${DOMAIN} --record-id ${ID_IPV4} --record-data ${IPV4} --record-ttl 60
21
+doctl -t ${API_TOKEN} compute domain records update ${DOMAIN} --record-id ${ID_IPV6} --record-data ${IPV6} --record-ttl 60

Loading…
Cancel
Save