Browse Source

service is working, set up as a batch script can execute and update to linode

master
Sean Clarke 1 year ago
parent
commit
52a4e3ad00
1 changed files with 25 additions and 16 deletions
  1. +25
    -16
      updatedns.sh

+ 25
- 16
updatedns.sh View File

@@ -2,30 +2,39 @@
IP="$(curl ipinfo.io/ip)"
OLDIP="$(more current-ip)"
TOKEN="$(more token)"
DOMAIN="$(more domain)"
RECORD="$(more record)"
NAME="$(more name)"

echo Current IP: $IP
echo Old IP: $OLDIP

# # Lists all the domains using a specific token
# curl -H "Authorization: Bearer $TOKEN" https://api.linode.com/v4/domains

# # List all the records for a specific domain
# curl -H "Authorization: Bearer $TOKEN" \
# https://api.linode.com/v4/domains/$DOMAIN/records

if [ "$IP" != "$OLDIP" ]
then
echo "DNS Requires Updating!"
echo $IP > current-ip
curl -H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-X PUT -d '{
"type": "A",
"name": "'"$NAME"'",
"target": "'"$IP"'",
"priority": 10,
"weight": 5,
"port": 80,
"service": null,
"protocol": null,
"ttl_sec": 0,
"tag": null
}' \
https://api.linode.com/v4/domains/$DOMAIN/records/$RECORD
else
echo "The IPs match, no need to update :)"
fi

# curl -H "Content-Type: application/json" \
# -H "Authorization: Bearer $TOKEN" \
# -X PUT -d '{
# "type": "A",
# "name": "test",
# "target": "12.34.56.78",
# "priority": 50,
# "weight": 50,
# "port": 80,
# "service": null,
# "protocol": null,
# "ttl_sec": 604800,
# "tag": null
# }' \
# https://api.linode.com/v4/domains/123/records/234