Created
August 31, 2010 03:43
-
-
Save selvakn/558510 to your computer and use it in GitHub Desktop.
A ruby client to update ip to zoneedit
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
#! /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