add update-dns.sh script

This commit is contained in:
2019-12-02 07:10:53 +00:00
committed by Gitea
parent 4173aa96e2
commit b596ec2a0f

30
update-dns.sh Normal file
View File

@@ -0,0 +1,30 @@
#!/bin/sh
set -eux
ip=$(wget https://checkip.amazonaws.com/ -O - -q)
zone_id=$(aws route53 list-hosted-zones | jq -S '.HostedZones | .[] | select( .Name == "maxregan.me." ) | .Id' -r)
batch=$(cat <<EOM
{
"Changes": [
{
"Action": "UPSERT",
"ResourceRecordSet": {
"Name": "home.maxregan.me",
"Type": "A",
"TTL": $((30 * 60)),
"ResourceRecords": [
{
"Value": "${ip}"
}
]
}
}
]
}
EOM
)
aws route53 change-resource-record-sets --hosted-zone-id "${zone_id}" --change-batch "$batch"