Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'A script to automtically enable and disable the firewall (based on location in 10.6)' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A script to automtically enable and disable the firewall (based on location in 10.6)
Authored by: edljedi on Oct 09, '09 03:28:47AM

I liked the idea of the script, however, I have been using MarcoPolo and network locations. I changed the second half of the script to look at the network location. When MarcoPolo determines there is a change in the network it will change the location and subsequently the firewall status. This includes what looks like to be a new firewall state in 10.6 (or at least I don't remember seeing it in 10.5). Note: 0 = off; 1 = on; 2 = block all incoming

#Checks to see what the current location is and set the firewall accordingly
#This stores the current location from the networksetup command.
LOCATION=$(networksetup -getcurrentlocation)

#This case looks at $LOCATION for specific locations and runs commands accordingly
case "$LOCATION" in

#On my home location, function firewall turns firewall off.
Home)
firewall 0
;;

#On my work location, function firewall turns firewall on.
Work)
firewall 1
;;

#If on the automatic location, function firewall turns the firewall on w/ block all.
Automatic)
firewall 2
;;

#On any other location, function firewall turns firewall on w/ block all.
*)
firewall 2
;;

esac



[ Reply to This | # ]
A script to automtically enable and disable the firewall (based on location in 10.6)
Authored by: edljedi on Oct 09, '09 03:30:53AM

probably should have had networksetup be /usr/sbin/networksetup



[ Reply to This | # ]