Created
February 6, 2014 17:19
-
-
Save elandesign/8848599 to your computer and use it in GitHub Desktop.
No-IP update script
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/env ruby | |
require 'logger' | |
USERNAME = "me%40example.org" | |
PASSWORD = "password" | |
HOSTNAME = "subdomain.no-ip.biz" | |
TEMPFILE = "/tmp/ip_address" | |
TTL = 86400 | |
LOGFILE = "/var/log/noip.log" | |
current_ip = `curl http://curlmyip.com 2>/dev/null`.strip | |
if File.exist?(TEMPFILE) | |
last_ip = open(TEMPFILE).read.strip | |
last_updated = File.mtime(TEMPFILE) | |
else | |
last_ip = "" | |
last_updated = 0 | |
end | |
log = Logger.new(LOGFILE) | |
if last_ip != current_ip || (Time.now - last_updated) > TTL | |
result = `curl -k "https://#{USERNAME}:#{PASSWORD}@dynupdate.no-ip.com/nic/update?hostname=#{HOSTNAME}" 2>/dev/null` | |
File.open(TEMPFILE, 'w') { |file| file.write(current_ip) } | |
log.info(result) | |
end |
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
I, [2014-01-14T11:07:38.425934 #848] INFO -- : Hello World | |
I, [2014-01-17T12:15:20.406824 #5554] INFO -- : nochg 94.173.20.56 | |
I, [2014-01-18T12:30:01.656793 #8910] INFO -- : nochg 94.173.20.56 | |
I, [2014-01-19T12:30:02.419608 #16856] INFO -- : nochg 94.173.20.56 | |
I, [2014-01-20T12:45:05.396566 #20786] INFO -- : | |
I, [2014-01-21T13:00:02.216972 #22767] INFO -- : nochg 94.173.20.56 | |
I, [2014-01-22T13:15:02.167938 #24953] INFO -- : nochg 94.173.20.56 | |
I, [2014-01-23T19:00:02.265888 #27297] INFO -- : nochg 94.173.20.56 | |
I, [2014-01-24T19:15:02.764824 #31664] INFO -- : nochg 94.173.20.56 | |
I, [2014-01-25T19:30:02.090007 #35850] INFO -- : nochg 94.173.20.56 | |
I, [2014-01-26T19:45:02.079662 #48628] INFO -- : nochg 94.173.20.56 | |
I, [2014-01-27T20:00:01.792617 #71181] INFO -- : nochg 94.173.20.56 | |
I, [2014-01-28T20:00:02.612154 #74402] INFO -- : nochg 94.173.20.56 | |
I, [2014-01-29T20:15:02.737142 #78330] INFO -- : nochg 94.173.20.56 | |
I, [2014-01-30T20:30:02.506062 #81007] INFO -- : nochg 94.173.20.56 | |
I, [2014-01-31T20:45:02.407692 #89233] INFO -- : nochg 94.173.20.56 | |
I, [2014-02-01T21:00:03.410672 #94081] INFO -- : nochg 94.173.20.56 | |
I, [2014-02-02T21:15:02.319380 #98939] INFO -- : nochg 94.173.20.56 | |
I, [2014-02-03T21:30:02.180255 #3782] INFO -- : nochg 94.173.20.56 | |
I, [2014-02-04T21:45:02.027728 #7192] INFO -- : nochg 94.173.20.56 | |
I, [2014-02-05T21:45:03.348978 #11484] INFO -- : nochg 94.173.20.56 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment