Skip to content

Instantly share code, notes, and snippets.

@shichao-an
Last active August 29, 2015 14:13
Show Gist options
  • Save shichao-an/56fb7bc64b6731130573 to your computer and use it in GitHub Desktop.
Save shichao-an/56fb7bc64b6731130573 to your computer and use it in GitHub Desktop.
Restart firewall on OS X
#!/bin/bash
# Restart firewall on OS X 10.9 and 10.10
# This script only works if you already turned on your firewall
if /usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate | grep 'Firewall is disabled.' > /dev/null
then
echo 'Firewall is turned off.' >&2
else
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate off && sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment