ControlPlane determines where you are or what you are doing based on a number of available evidence sources and then automatically reconfigures your Mac based on your preferences. Evidence sources can include your current location, visible WiFi networks, attached USB devices, running applications and more. You can even write your own evidence sources using shell scripts!
I like synchronizing a bunch of files from a server to my Mac periodically, but only when at my home office.
The script uses scselect to determine whether the Mac is in the office and quietly exits if it isn’t:
You don’t have to use ControlPlane for this to work: changing network locations manually has the same effect.