From 88bc3c5fa5790c8ac6f526636d3818aa44fbaab3 Mon Sep 17 00:00:00 2001 From: Martin Donnelly Date: Fri, 24 Jun 2022 23:51:01 +0100 Subject: [PATCH] Added xira domains --- linode/updateCloud.sh | 51 +++++++++++++++++++++++++++++++++++++++ linode/updateLinks.sh | 51 +++++++++++++++++++++++++++++++++++++++ linode/updateMusic.sh | 51 +++++++++++++++++++++++++++++++++++++++ linode/updateWireguard.sh | 51 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 204 insertions(+) create mode 100755 linode/updateCloud.sh create mode 100755 linode/updateLinks.sh create mode 100755 linode/updateMusic.sh create mode 100755 linode/updateWireguard.sh diff --git a/linode/updateCloud.sh b/linode/updateCloud.sh new file mode 100755 index 0000000..6661045 --- /dev/null +++ b/linode/updateCloud.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +#Variable Declaration - Change These +ACCESS_TOKEN="f16b8a3fe210f45008b8fec192432ca85b2765c2dac7e5bcd214de242272449b" +PINGID="8683209a-cf95-48ff-9f57-b7f16b3885ea" +DOMAINID="1851504" +RECORDID="21565305" +NAME="cloud" +TYPE="A" +TTL=300 + +#get current IP address +IP=$(curl http://checkip.amazonaws.com/) + +#validate IP address (makes sure Route 53 doesn't get updated with a malformed payload) +if [[ ! $IP =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then + exit 1 +fi + +curl -H "Authorization: Bearer $ACCESS_TOKEN" https://api.linode.com/v4/domains/$DOMAINID/records/$RECORDID | \ +jq -r 'select (.name="'"tester"'")|(.type="'"A"'")|.target' > /tmp/linode_${NAME}_value + +cat /tmp/linode_${NAME}_value + +#check if IP is different from Route 53 +if grep -Fxq "$IP" /tmp/linode_${NAME}_value; then + echo "IP Has Not Changed, Exiting" + curl -m 10 --retry 5 https://hc-ping.com/${PINGID} + exit 1 +fi + + curl -H "Content-Type: application/json" \ + -H "Authorization: Bearer $ACCESS_TOKEN" \ + -X PUT -d '{ + "type": "'$TYPE'", + "name": "'$NAME'", + "target": "'$IP'", + "priority": 50, + "weight": 50, + "port": 80, + "service": null, + "protocol": null, + "ttl_sec": 300, + "tag": null + }' \ + https://api.linode.com/v4/domains/$DOMAINID/records/$RECORDID + + +# if good + +curl -m 10 --retry 5 https://hc-ping.com/${PINGID}/99 diff --git a/linode/updateLinks.sh b/linode/updateLinks.sh new file mode 100755 index 0000000..4ecb376 --- /dev/null +++ b/linode/updateLinks.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +#Variable Declaration - Change These +ACCESS_TOKEN="f16b8a3fe210f45008b8fec192432ca85b2765c2dac7e5bcd214de242272449b" +PINGID="db1e44d4-7975-4738-8805-01eba58ec826" +DOMAINID="1851504" +RECORDID="21565306" +NAME="links" +TYPE="A" +TTL=300 + +#get current IP address +IP=$(curl http://checkip.amazonaws.com/) + +#validate IP address (makes sure Route 53 doesn't get updated with a malformed payload) +if [[ ! $IP =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then + exit 1 +fi + +curl -H "Authorization: Bearer $ACCESS_TOKEN" https://api.linode.com/v4/domains/$DOMAINID/records/$RECORDID | \ +jq -r 'select (.name="'"tester"'")|(.type="'"A"'")|.target' > /tmp/linode_${NAME}_value + +cat /tmp/linode_${NAME}_value + +#check if IP is different from Route 53 +if grep -Fxq "$IP" /tmp/linode_${NAME}_value; then + echo "IP Has Not Changed, Exiting" + curl -m 10 --retry 5 https://hc-ping.com/${PINGID} + exit 1 +fi + + curl -H "Content-Type: application/json" \ + -H "Authorization: Bearer $ACCESS_TOKEN" \ + -X PUT -d '{ + "type": "'$TYPE'", + "name": "'$NAME'", + "target": "'$IP'", + "priority": 50, + "weight": 50, + "port": 80, + "service": null, + "protocol": null, + "ttl_sec": 300, + "tag": null + }' \ + https://api.linode.com/v4/domains/$DOMAINID/records/$RECORDID + + +# if good + +curl -m 10 --retry 5 https://hc-ping.com/${PINGID}/99 diff --git a/linode/updateMusic.sh b/linode/updateMusic.sh new file mode 100755 index 0000000..09bd175 --- /dev/null +++ b/linode/updateMusic.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +#Variable Declaration - Change These +ACCESS_TOKEN="f16b8a3fe210f45008b8fec192432ca85b2765c2dac7e5bcd214de242272449b" +PINGID="0311e1b0-30eb-4503-88e2-b9e99a0b872a" +DOMAINID="1851003" +RECORDID="21559701" +NAME="push" +TYPE="A" +TTL=300 + +#get current IP address +IP=$(curl http://checkip.amazonaws.com/) + +#validate IP address (makes sure Route 53 doesn't get updated with a malformed payload) +if [[ ! $IP =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then + exit 1 +fi + +curl -H "Authorization: Bearer $ACCESS_TOKEN" https://api.linode.com/v4/domains/$DOMAINID/records/$RECORDID | \ +jq -r 'select (.name="'"tester"'")|(.type="'"A"'")|.target' > /tmp/linode_${NAME}_value + +cat /tmp/linode_${NAME}_value + +#check if IP is different from Route 53 +if grep -Fxq "$IP" /tmp/linode_${NAME}_value; then + echo "IP Has Not Changed, Exiting" + curl -m 10 --retry 5 https://hc-ping.com/${PINGID} + exit 1 +fi + + curl -H "Content-Type: application/json" \ + -H "Authorization: Bearer $ACCESS_TOKEN" \ + -X PUT -d '{ + "type": "'$TYPE'", + "name": "'$NAME'", + "target": "'$IP'", + "priority": 50, + "weight": 50, + "port": 80, + "service": null, + "protocol": null, + "ttl_sec": 300, + "tag": null + }' \ + https://api.linode.com/v4/domains/$DOMAINID/records/$RECORDID + + +# if good + +curl -m 10 --retry 5 https://hc-ping.com/${PINGID}/99 diff --git a/linode/updateWireguard.sh b/linode/updateWireguard.sh new file mode 100755 index 0000000..5da8a5e --- /dev/null +++ b/linode/updateWireguard.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +#Variable Declaration - Change These +ACCESS_TOKEN="f16b8a3fe210f45008b8fec192432ca85b2765c2dac7e5bcd214de242272449b" +PINGID="b7d69a09-8e30-4685-875a-8fb451d75c1b" +DOMAINID="1851504" +RECORDID="21565308" +NAME="wireguard" +TYPE="A" +TTL=300 + +#get current IP address +IP=$(curl http://checkip.amazonaws.com/) + +#validate IP address (makes sure Route 53 doesn't get updated with a malformed payload) +if [[ ! $IP =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then + exit 1 +fi + +curl -H "Authorization: Bearer $ACCESS_TOKEN" https://api.linode.com/v4/domains/$DOMAINID/records/$RECORDID | \ +jq -r 'select (.name="'"tester"'")|(.type="'"A"'")|.target' > /tmp/linode_${NAME}_value + +cat /tmp/linode_${NAME}_value + +#check if IP is different from Route 53 +if grep -Fxq "$IP" /tmp/linode_${NAME}_value; then + echo "IP Has Not Changed, Exiting" + curl -m 10 --retry 5 https://hc-ping.com/${PINGID} + exit 1 +fi + + curl -H "Content-Type: application/json" \ + -H "Authorization: Bearer $ACCESS_TOKEN" \ + -X PUT -d '{ + "type": "'$TYPE'", + "name": "'$NAME'", + "target": "'$IP'", + "priority": 50, + "weight": 50, + "port": 80, + "service": null, + "protocol": null, + "ttl_sec": 300, + "tag": null + }' \ + https://api.linode.com/v4/domains/$DOMAINID/records/$RECORDID + + +# if good + +curl -m 10 --retry 5 https://hc-ping.com/${PINGID}/99