Created
July 29, 2012 22:05
-
-
Save sgonyea/3202098 to your computer and use it in GitHub Desktop.
Renews your DHCP Lease every 30-seconds, until an IP Address is assigned. Fight crappy WAPs!
This file contains 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 | |
# I believe 'en1' is the default WiFi device name on Mac OS X. It's what mine is set to. | |
def device; @device ||= ARGV[0] || "en1" end | |
def ip_set? | |
ip = `ipconfig getifaddr #{device}` | |
return false if ip.empty? | |
return false if ip.start_with?("169") | |
return true | |
end | |
def renew_dhcp_until_ip | |
until ip_set? | |
# Reset the IP | |
`sudo ipconfig set #{device} BOOTP` | |
`sudo ipconfig set #{device} DHCP` | |
sleep 30 | |
end | |
`say 'Hey! You! You have an IP now! Z O M and G!'` | |
end | |
renew_dhcp_until_ip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment