Last active
January 2, 2016 00:49
-
-
Save bhauman/8225787 to your computer and use it in GitHub Desktop.
Zerigo's recent rate increase will raise my yearly cost 5000% so I created this lovely little script to help you leave Zerigo behind. It relies on the excellent fog library http://fog.io/dns/ It is currently targeting DNSimple but fog supports many other providers. Using it is very satisfying. After setting the correct connection settings just t…
This file contains 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
require 'rubygems' | |
require 'fog' | |
require 'zerigo_dns' | |
# A simple script to help you leave zerigo behind | |
# it relies on the excellent fog library http://fog.io/dns/ | |
# It copies all of your Zerigo zones to DNSimple | |
# It is currently targeting DNSimple but fog supports many other | |
# providers. | |
# Using it is very satisfying | |
# after setting the correct connection settings | |
# just type | |
# ScrewYouZerigo.im_fucking.outa_here | |
class ScrewYouZerigo | |
attr_accessor :source, :destination | |
def initialize(source, destination) | |
@source = source | |
@destination = destination | |
end | |
def create_zone_hash(zone) | |
{ :domain => zone.domain, | |
:ttl => zone.ttl } | |
end | |
def create_record_hash(record) | |
[:value, :domain, :name, :ttl, :type ].inject({ :name => "" }) { |accum, value| | |
accum[value] = record.send(value) | |
accum | |
} | |
end | |
def zones_to_move | |
Zerigo::DNS::Zone.all(:params => {:per_page => 999}).collect do |zz| | |
source.zones.get zz.domain | |
end | |
end | |
def copy_zone(zone) | |
new_zone = destination.zones.create(create_zone_hash(zone)) | |
zone.records.each do |record| | |
new_zone.records.create(create_record_hash(record)) | |
end | |
end | |
def outa_here | |
zones_to_move.each do |zone| | |
copy_zone(zone) | |
end | |
end | |
def ___reset_destination! | |
# this will delete freaking everything in the destination account | |
destination.zones.each &:destroy | |
end | |
def self.im_fucking | |
zemail = Zerigo::DNS::Base.user = 'XXXXXXXXXXXX' # CHANGE THIS | |
# the following is the Zerigo API token | |
zpassword = Zerigo::DNS::Base.password = "XXXXXXXXXXXXXX" # CHANGE THIS | |
ScrewYouZerigo.new(Fog::DNS.new({ | |
:provider => 'Zerigo', | |
:zerigo_email => zemail, | |
:zerigo_token => zpassword | |
}), | |
Fog::DNS.new({ | |
:provider => 'DNSimple', | |
:dnsimple_email => "XXXXXXXXXXXXX", # CHANGE THIS | |
# the following is your actual login password | |
:dnsimple_password => "XXXXXXXXXXXXX" # CHANGE THIS | |
})) | |
end | |
end | |
# unccoment the next line if you want this to be executable | |
# ScrewYouZerigo.im_fucking.outa_here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice !