123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- #!/bin/sh
- HOSTNAME='myrouter.mydomain.com'
- HOSTEDZONE='myhostedzoneID'
- function update {
- logger "Route53 UPDATE: ${1} -> ${2}"
-
- . $HOME/awscli/bin/activate
- cat << _EOF > /tmp/${1}
- {
- "Changes": [
- {
- "Action": "UPSERT",
- "ResourceRecordSet": {
- "Name": "${1}",
- "Type": "A",
- "TTL": 60,
- "ResourceRecords": [
- {
- "Value": "${2}"
- }
- ]
- }
- }
- ]
- }
- _EOF
- aws route53 change-resource-record-sets --hosted-zone-id $HOSTEDZONE --change-batch file:///tmp/${1}
- rm /tmp/${1}
- }
- [ -f $HOME/old_ip ] && export old_ip=$(cat $HOME/old_ip) || export old_ip='X'
- myip=$(dig +short @208.67.222.222 myip.opendns.com)
- [ -z $myip ] || echo $myip > $HOME/old_ip
- [ $myip = $old_ip ] || update $HOSTNAME $myip
|