Last active
August 29, 2015 14:05
-
-
Save neilellis/94d5edf1361092d781c7 to your computer and use it in GitHub Desktop.
Use cfcli to sync DigitalOcean host names with Cloudflare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To use this you'll need to install Tugboat:
Then cfcli:
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!!!!!!!