Skip to content

Instantly share code, notes, and snippets.

@postpostmodern
Created February 5, 2009 17:02
Show Gist options
  • Save postpostmodern/58832 to your computer and use it in GitHub Desktop.
Save postpostmodern/58832 to your computer and use it in GitHub Desktop.
Fixes NS records that incorrectly list slicehost.com instead of slicehost.net as the nameserver
#!/usr/bin/env ruby
# This should fix your NS records if you used the old version of slicedns.rb.
# Check to see if any of your zones list ns1/2/3.slicehost.com as a nameserver.
# It will change ALL NS records that have ns*.slicehost.com to ns*.slicehost.net
require 'rubygems'
require 'activeresource'
API_PASSWORD = 'your_api_key'
# Address class is required for Slice class
class Address < String; end
# Define the ActiveResource classes
class Record < ActiveResource::Base
self.site = "https://#{API_PASSWORD}@api.slicehost.com/"
def info
' | ' + self.name.to_s.ljust(30) +
' | ' + self.record_type.to_s.ljust(5) +
' | ' + self.data.to_s.ljust(34) +
' | '
end
end
nsrecords = Record.find(:all, :params => { :record_type => 'NS' })
nsrecords.each do |r|
case r.data
when 'ns1.slicehost.com.'
r.data = 'ns1.slicehost.net.'
r.save
puts r.info
when 'ns2.slicehost.com.'
r.data = 'ns2.slicehost.net.'
r.save
puts r.info
when 'ns3.slicehost.com.'
r.data = 'ns3.slicehost.net.'
r.save
puts r.info
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment