summaryrefslogtreecommitdiffstats
path: root/system/OpenSnitch/rc.opensnitchd
diff options
context:
space:
mode:
Diffstat (limited to 'system/OpenSnitch/rc.opensnitchd')
-rw-r--r--system/OpenSnitch/rc.opensnitchd49
1 files changed, 49 insertions, 0 deletions
diff --git a/system/OpenSnitch/rc.opensnitchd b/system/OpenSnitch/rc.opensnitchd
new file mode 100644
index 0000000000..7e8c30fa1c
--- /dev/null
+++ b/system/OpenSnitch/rc.opensnitchd
@@ -0,0 +1,49 @@
+#!/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