Skip to content

Commit

Permalink
Initial checkin
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Paramonov committed Jan 5, 2010
0 parents commit 3bef686
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions ip.log
@@ -0,0 +1 @@
2010-01-04 21:45:11, 69.172.92.148
18 changes: 18 additions & 0 deletions whatsMyIp.groovy
@@ -0,0 +1,18 @@
#!/usr/bin/env groovy

// Inspired by http://github.com/blue64/my-ip

currentIp = ('http://whatsmyip.us/'.toURL().text =~ /\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/)[0]
println currentIp

def ipLog = new File('ip.log')
recentIp = ipLog.readLines().last().tokenize(',').last().trim()

if (currentIp != recentIp) {
println "IP Address has changed, it was $recentIp, now it's $currentIp"
ipLog << "${new Date().format('yyyy-MM-dd HH:mm:ss')}, $currentIp\n"

["git", "add", "ip.log"].execute()
["git", "commit", "-m", "$currentIp"].execute()
["git", "push"].execute()
}

0 comments on commit 3bef686

Please sign in to comment.