add update-dns.sh script
This commit is contained in:
30
update-dns.sh
Normal file
30
update-dns.sh
Normal 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"
|
||||||
Reference in New Issue
Block a user