June 10, 2008

Dynamic Cheese Grater

I decided I’d like to access my home computer from work, specifically I wanted to be able to ssh into the machine. I used to do this by setting up a dynamic host name and just leaving my computer on all day long, but that hardly seemed like the best way to deal with it. More specifically, I didn’t really want to pay for the electricity of running that thing all day long. So I decided to look into what I needed to do to get Wake-on-LAN to work with my Power Mac and FiOS modem.

Now I just needed a way to wake it up. First I played with this web page, which worked, but required me to type in my Desktop’s MAC address every time. Uncool. Then I found a little perl script that could do it, sorta. At that point I realized this was a job for ruby. And lo and behold I found K. Kodama WOL Class, which did nearly exactly what I wanted. I took that and hacked it up so my settings were all hard coded, added a she-bang, made it executable and linked to it from somewhere in my path. Now I can simply type “wakebold” and it will wake up my desktop at home (whom have affectionally named “bold”).

My changes were really easy:

# Configure the IP and MAC address for the computer you want here:

SETTINGS = { :mac_addr => "00:00:00:00:00:00", :host_name => "example.homeip.net"}

if $0 == __FILE__
  wol.wake(SETTINGS[:mac_addr], "", SETTINGS[:host_name])
  puts "Waking up #{SETTINGS[:host_name]}"

My hacked version can be found in my svn repo.

To do all this, you can do the following:

svn co http://www.fuzzymonk.com/svn/wakeywakey
chmod +x wakeywakey/wakey.rb
ln -s wakeywakey/wakey.rb /usr/local/bin/wakebold # or elsewhere in your path