Skip to content

Instantly share code, notes, and snippets.

@neilellis
Last active August 29, 2015 14:05
Show Gist options
  • Save neilellis/94d5edf1361092d781c7 to your computer and use it in GitHub Desktop.
Save neilellis/94d5edf1361092d781c7 to your computer and use it in GitHub Desktop.
Use cfcli to sync DigitalOcean host names with Cloudflare
#!/bin/bash -eu
convert() {
while read line
do
mc=$(echo $line | cut -d' ' -f1)
if echo $mc | grep $1
then
ip=$(echo $line | cut -d':' -f2 | cut -d',' -f1)
cfcli addrecord -t A $mc $ip || cfcli editrecord -t A $mc $ip
fi
done
}
[[ -n $1 ]] || (echo "Please supply a regex to match the hostnames you want to copy" && exit 1)
tugboat droplets | convert $1
@neilellis
Copy link
Author

To use this you'll need to install Tugboat:

      gem install tugboat

Then cfcli:

    npm install cloudflare-cli

Follow the instructions to set up Tugboat here: https://github.com/pearkes/tugboat and cfcli here : https://github.com/danielpigott/cloudflare-cli

I'm @neilellis on Twitter so ping me if you need more info.

For <Deity>'s sake USE WITH CAUTION!!!!!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment