#!/usr/bin/env sh
IP=$(dig ANY +short @resolver2.opendns.com myip.opendns.com)
echo "Current IP address is $IP"
update_record()
{
record=$(doctl compute domain records list $1 --context $2 --output json)
data=$(echo "$record" | jq -r ".[] | select(.type==\"A\") | select(.name==\"$3\") | .data")
if [ "$data" = "$IP" ]; then
echo "$1 is already up to date with IP address"
else
id=$(echo "$record" | jq ".[] | select(.type==\"A\") | select(.name==\"$3\") | .id")
doctl compute domain records update $1 --context $2 --record-id $id --record-data $IP
fi
}
update_record kellygravelyn.com personal @
update_record ohthesetrees.com personal @
update_record brushfire.games brushfiregames @
update_record brushfiregames.com brushfiregames @
update_record shipwreckgame.com brushfiregames @
update_record polychromaticgame.com brushfiregames @
made with @nex3's syntax highlighter
