Browse Source

Intial commit, if statement set up, api connect yet to be configured

master
Sean Clarke 1 year ago
commit
612ce840c4
2 changed files with 47 additions and 0 deletions
  1. +16
    -0
      README.md
  2. +31
    -0
      updatedns.sh

+ 16
- 0
README.md View File

@@ -0,0 +1,16 @@
# ddns-linode

Add a cron job with this script in order to automatically update the Linode DNS.

## Usage

Just bash the updatedns.sh

It must be run an inital time as it does not connect with the DNS record until the IP has been detected as a "Not Match".

## Requirements

- permission to create a 'current-ip' file (saves from updating all the time)
- a file named 'token' that stores your Linode token

[Buy me a ☕ or ☕☕](https://www.buymeacoffee.com/seanland)

+ 31
- 0
updatedns.sh View File

@@ -0,0 +1,31 @@
#!/bin/sh
IP="$(curl ipinfo.io/ip)"
OLDIP="$(more current-ip)"
TOKEN="$(more token)"

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

if [ "$IP" != "$OLDIP" ]
then
echo "DNS Requires Updating!"
echo $IP > current-ip
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

Loading…
Cancel
Save