#!/bin/sh # Start opensnitchd: start_opensnitchd() { echo "Start Opensnitch" if [ -x /usr/bin/opensnitchd ]; then [ ! -d /etc/opensnitchd/rules ] && mkdir -p /etc/opensnitchd/rules chown -R root:root /etc/opensnitchd chown root:root /var/log/opensnitchd.log chmod -R 755 /etc/opensnitchd chmod -R 644 /etc/opensnitchd/rules chmod 600 /var/log/opensnitchd.log fi /usr/bin/opensnitchd -rules-path /etc/opensnitchd/rules -log-file /var/log/opensnitchd.log > /dev/null 2>&1 & } # Stop opensnitchd: stop_opensnitchd() { if /usr/bin/pgrep -f /usr/bin/opensnitchd >/dev/null; then echo "Stopping application firewall" /usr/bin/pkill -SIGINT opensnitchd else echo "Opensnitch is not running" exit 1 fi } # Restart opensnitchd: restart_opensnitchd() { stop_opensnitchd sleep 1 start_opensnitchd } case "$1" in 'start') start_opensnitchd ;; 'stop') stop_opensnitchd ;; 'restart') restart_opensnitchd ;; *) echo "usage $0 start|stop|restart" esac