From c662972ebb8f3cd0c0894d74ad47c5432b366f0e Mon Sep 17 00:00:00 2001 From: root Date: Thu, 23 Jun 2022 15:04:59 +0000 Subject: [PATCH] init --- updateCloudDNS.sh | 63 +++++++++++++++++++++++++++++++++++++++++++++++ updateGit.sh | 63 +++++++++++++++++++++++++++++++++++++++++++++++ updateGotify.sh | 63 +++++++++++++++++++++++++++++++++++++++++++++++ updateLinks.sh | 63 +++++++++++++++++++++++++++++++++++++++++++++++ updateMusic.sh | 63 +++++++++++++++++++++++++++++++++++++++++++++++ updatedns.sh | 62 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 377 insertions(+) create mode 100755 updateCloudDNS.sh create mode 100755 updateGit.sh create mode 100755 updateGotify.sh create mode 100755 updateLinks.sh create mode 100755 updateMusic.sh create mode 100755 updatedns.sh diff --git a/updateCloudDNS.sh b/updateCloudDNS.sh new file mode 100755 index 0000000..982076f --- /dev/null +++ b/updateCloudDNS.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +#Variable Declaration - Change These +HOSTED_ZONE_ID="Z2LZR966I2PUGA" +NAME="cloud.xira.co.uk." +TYPE="A" +TTL=60 + +#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 + +#get current +/usr/local/bin/aws route53 list-resource-record-sets --hosted-zone-id $HOSTED_ZONE_ID | \ +jq -r '.ResourceRecordSets[] | select (.Name == "'"$NAME"'") | select (.Type == "'"$TYPE"'") | .ResourceRecords[0].Value' > /tmp/current_route53_value + +cat /tmp/current_route53_value + +#check if IP is different from Route 53 +if grep -Fxq "$IP" /tmp/current_route53_value; then + echo "IP Has Not Changed, Exiting" + curl -m 10 --retry 5 https://hc-ping.com/8683209a-cf95-48ff-9f57-b7f16b3885ea + exit 1 +fi + + +echo "IP Changed, Updating Records" + +#prepare route 53 payload +cat > /tmp/route53_cloud_changes.json << EOF + { + "Comment":"Updated From DDNS Shell Script", + "Changes":[ + { + "Action":"UPSERT", + "ResourceRecordSet":{ + "ResourceRecords":[ + { + "Value":"$IP" + } + ], + "Name":"$NAME", + "Type":"$TYPE", + "TTL":$TTL + } + } + ] + } +EOF + +#update records +/usr/local/bin/aws route53 change-resource-record-sets --hosted-zone-id $HOSTED_ZONE_ID --change-batch file:///tmp/route53_cloud_changes.json >> /dev/null + + +# if good + +curl -m 10 --retry 5 https://hc-ping.com/8683209a-cf95-48ff-9f57-b7f16b3885ea/99 + + diff --git a/updateGit.sh b/updateGit.sh new file mode 100755 index 0000000..69200af --- /dev/null +++ b/updateGit.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +#Variable Declaration - Change These +HOSTED_ZONE_ID="Z3KRROJ1JJ2ULP" +NAME="git.caliban.io." +TYPE="A" +TTL=60 + +#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 + +#get current +/usr/local/bin/aws route53 list-resource-record-sets --hosted-zone-id $HOSTED_ZONE_ID | \ +jq -r '.ResourceRecordSets[] | select (.Name == "'"$NAME"'") | select (.Type == "'"$TYPE"'") | .ResourceRecords[0].Value' > /tmp/current_route53_value + +cat /tmp/current_route53_value + +#check if IP is different from Route 53 +if grep -Fxq "$IP" /tmp/current_route53_value; then + echo "IP Has Not Changed, Exiting" + curl -m 10 --retry 5 https://hc-ping.com/0311e1b0-30eb-4503-88e2-b9e99a0b872a + exit 1 +fi + + +echo "IP Changed, Updating Records" + +#prepare route 53 payload +cat > /tmp/route53_changes.json << EOF + { + "Comment":"Updated From DDNS Shell Script", + "Changes":[ + { + "Action":"UPSERT", + "ResourceRecordSet":{ + "ResourceRecords":[ + { + "Value":"$IP" + } + ], + "Name":"$NAME", + "Type":"$TYPE", + "TTL":$TTL + } + } + ] + } +EOF + +#update records +/usr/local/bin/aws route53 change-resource-record-sets --hosted-zone-id $HOSTED_ZONE_ID --change-batch file:///tmp/route53_changes.json >> /dev/null + + +# if good + +curl -m 10 --retry 5 https://hc-ping.com/0311e1b0-30eb-4503-88e2-b9e99a0b872a/99 + + diff --git a/updateGotify.sh b/updateGotify.sh new file mode 100755 index 0000000..f69f2b3 --- /dev/null +++ b/updateGotify.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +#Variable Declaration - Change These +HOSTED_ZONE_ID="Z3KRROJ1JJ2ULP" +NAME="push.caliban.io." +TYPE="A" +TTL=60 + +#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 + +#get current +/usr/local/bin/aws route53 list-resource-record-sets --hosted-zone-id $HOSTED_ZONE_ID | \ +jq -r '.ResourceRecordSets[] | select (.Name == "'"$NAME"'") | select (.Type == "'"$TYPE"'") | .ResourceRecords[0].Value' > /tmp/current_route53_value + +cat /tmp/current_route53_value + +#check if IP is different from Route 53 +if grep -Fxq "$IP" /tmp/current_route53_value; then + echo "IP Has Not Changed, Exiting" + curl -m 10 --retry 5 https://hc-ping.com/a89477fc-2660-4bfc-baf4-ef330bcf1df5 + exit 1 +fi + + +echo "IP Changed, Updating Records" + +#prepare route 53 payload +cat > /tmp/route53_changes.json << EOF + { + "Comment":"Updated From DDNS Shell Script", + "Changes":[ + { + "Action":"UPSERT", + "ResourceRecordSet":{ + "ResourceRecords":[ + { + "Value":"$IP" + } + ], + "Name":"$NAME", + "Type":"$TYPE", + "TTL":$TTL + } + } + ] + } +EOF + +#update records +/usr/local/bin/aws route53 change-resource-record-sets --hosted-zone-id $HOSTED_ZONE_ID --change-batch file:///tmp/route53_changes.json >> /dev/null + + +# if good + +curl -m 10 --retry 5 https://hc-ping.com/a89477fc-2660-4bfc-baf4-ef330bcf1df5/99 + + diff --git a/updateLinks.sh b/updateLinks.sh new file mode 100755 index 0000000..b53a248 --- /dev/null +++ b/updateLinks.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +#Variable Declaration - Change These +HOSTED_ZONE_ID="Z2LZR966I2PUGA" +NAME="links.xira.co.uk." +TYPE="A" +TTL=60 + +#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 + +#get current +/usr/local/bin/aws route53 list-resource-record-sets --hosted-zone-id $HOSTED_ZONE_ID | \ +jq -r '.ResourceRecordSets[] | select (.Name == "'"$NAME"'") | select (.Type == "'"$TYPE"'") | .ResourceRecords[0].Value' > /tmp/current_route53_value + +cat /tmp/current_route53_value + +#check if IP is different from Route 53 +if grep -Fxq "$IP" /tmp/current_route53_value; then + echo "IP Has Not Changed, Exiting" + curl -m 10 --retry 5 https://hc-ping.com/db1e44d4-7975-4738-8805-01eba58ec826 + exit 1 +fi + + +echo "IP Changed, Updating Records" + +#prepare route 53 payload +cat > /tmp/route53_changes.json << EOF + { + "Comment":"Updated From DDNS Shell Script", + "Changes":[ + { + "Action":"UPSERT", + "ResourceRecordSet":{ + "ResourceRecords":[ + { + "Value":"$IP" + } + ], + "Name":"$NAME", + "Type":"$TYPE", + "TTL":$TTL + } + } + ] + } +EOF + +#update records +/usr/local/bin/aws route53 change-resource-record-sets --hosted-zone-id $HOSTED_ZONE_ID --change-batch file:///tmp/route53_changes.json >> /dev/null + + +# if good + +curl -m 10 --retry 5 https://hc-ping.com/db1e44d4-7975-4738-8805-01eba58ec826/99 + + diff --git a/updateMusic.sh b/updateMusic.sh new file mode 100755 index 0000000..b8fae41 --- /dev/null +++ b/updateMusic.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +#Variable Declaration - Change These +HOSTED_ZONE_ID="Z2LZR966I2PUGA" +NAME="music.xira.co.uk." +TYPE="A" +TTL=60 + +#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 + +#get current +/usr/local/bin/aws route53 list-resource-record-sets --hosted-zone-id $HOSTED_ZONE_ID | \ +jq -r '.ResourceRecordSets[] | select (.Name == "'"$NAME"'") | select (.Type == "'"$TYPE"'") | .ResourceRecords[0].Value' > /tmp/current_route53_value + +cat /tmp/current_route53_value + +#check if IP is different from Route 53 +if grep -Fxq "$IP" /tmp/current_route53_value; then + echo "IP Has Not Changed, Exiting" + curl -m 10 --retry 5 https://hc-ping.com/108bfbe9-3010-41a2-9196-d2bab5859f31 + exit 1 +fi + + +echo "IP Changed, Updating Records" + +#prepare route 53 payload +cat > /tmp/route53_changes.json << EOF + { + "Comment":"Updated From DDNS Shell Script", + "Changes":[ + { + "Action":"UPSERT", + "ResourceRecordSet":{ + "ResourceRecords":[ + { + "Value":"$IP" + } + ], + "Name":"$NAME", + "Type":"$TYPE", + "TTL":$TTL + } + } + ] + } +EOF + +#update records +/usr/local/bin/aws route53 change-resource-record-sets --hosted-zone-id $HOSTED_ZONE_ID --change-batch file:///tmp/route53_changes.json >> /dev/null + + +# if good + +curl -m 10 --retry 5 https://hc-ping.com/108bfbe9-3010-41a2-9196-d2bab5859f31/99 + + diff --git a/updatedns.sh b/updatedns.sh new file mode 100755 index 0000000..ac3c03f --- /dev/null +++ b/updatedns.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +#Variable Declaration - Change These +HOSTED_ZONE_ID="Z2LZR966I2PUGA" +NAME="wireguard.xira.co.uk." +TYPE="A" +TTL=60 + +#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 + +#get current +/usr/local/bin/aws route53 list-resource-record-sets --hosted-zone-id $HOSTED_ZONE_ID | \ +jq -r '.ResourceRecordSets[] | select (.Name == "'"$NAME"'") | select (.Type == "'"$TYPE"'") | .ResourceRecords[0].Value' > /tmp/current_route53_value + +cat /tmp/current_route53_value + +#check if IP is different from Route 53 +if grep -Fxq "$IP" /tmp/current_route53_value; then + echo "IP Has Not Changed, Exiting" + curl -m 10 --retry 5 https://hc-ping.com/b7d69a09-8e30-4685-875a-8fb451d75c1b + exit 1 +fi + + +echo "IP Changed, Updating Records" + +#prepare route 53 payload +cat > /tmp/route53_changes.json << EOF + { + "Comment":"Updated From DDNS Shell Script", + "Changes":[ + { + "Action":"UPSERT", + "ResourceRecordSet":{ + "ResourceRecords":[ + { + "Value":"$IP" + } + ], + "Name":"$NAME", + "Type":"$TYPE", + "TTL":$TTL + } + } + ] + } +EOF + +#update records +/usr/local/bin/aws route53 change-resource-record-sets --hosted-zone-id $HOSTED_ZONE_ID --change-batch file:///tmp/route53_changes.json >> /dev/null + + +# if all good +curl -m 10 --retry 5 https://hc-ping.com/b7d69a09-8e30-4685-875a-8fb451d75c1b/99 + +