Skip to content

Instantly share code, notes, and snippets.

@selvakn
Created August 31, 2010 03:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save selvakn/558510 to your computer and use it in GitHub Desktop.
Save selvakn/558510 to your computer and use it in GitHub Desktop.
A ruby client to update ip to zoneedit
#! /usr/bin/ruby
unless ARGV.size >= 3
puts "USAGE: zoneedit_updater.rb username password domain [force [IP]]"
exit
end
USERNAME = ARGV[0]
PASSWORD = ARGV[1]
DOMAIN = ARGV[2]
IP_FILE = File.dirname(__FILE__) + "/.zoneedit_ip"
File.delete(IP_FILE) if ARGV[3] && File.exists?(IP_FILE)
previous_ip = File.exists?(IP_FILE) ? File.read(IP_FILE) : nil
current_ip = ARGV[4] || `curl -s www.whatismyip.com/automation/n09230945.asp`
puts "Current Public IP: #{current_ip}"
if previous_ip != current_ip
puts `curl -s -u #{USERNAME}:#{PASSWORD} 'http://dynamic.zoneedit.com/auth/dynamic.html?host=#{DOMAIN}'`
File.open(IP_FILE, "w"){|f| f << current_ip}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment