Update firewall.sh

Including the bulk of the core code.