Skip to content

Commit c9a0f42

Browse files
Copilotandrejusk
andcommitted
Add OpenSnitch installation script for Linux
Co-authored-by: andrejusk <[email protected]>
1 parent 83a1144 commit c9a0f42

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

script/install.d/82-opensnitch.sh

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/usr/bin/env bash
2+
3+
# -----------------------------------------------------------------------------
4+
# Description:
5+
# Install OpenSnitch application firewall on Linux.
6+
# Docs: https://github.com/evilsocket/opensnitch/wiki/Installation
7+
#
8+
9+
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
10+
if ! command -v opensnitchd &>/dev/null || ! command -v opensnitch-ui &>/dev/null; then
11+
echo "Installing OpenSnitch..."
12+
13+
# Create temporary directory for downloads
14+
temp_dir=$(mktemp -d)
15+
cd "$temp_dir"
16+
17+
# Use a known stable version as fallback
18+
LATEST_VERSION="v1.7.0.0"
19+
20+
# Try to get the latest release version, but don't fail if it doesn't work
21+
RELEASE_URL="https://api.github.com/repos/evilsocket/opensnitch/releases/latest"
22+
LATEST_FROM_API=$(curl -s "$RELEASE_URL" 2>/dev/null | grep '"tag_name"' | cut -d'"' -f4 2>/dev/null)
23+
24+
if [[ -n "$LATEST_FROM_API" ]]; then
25+
LATEST_VERSION="$LATEST_FROM_API"
26+
echo "Using latest version: $LATEST_VERSION"
27+
else
28+
echo "Using fallback version: $LATEST_VERSION"
29+
fi
30+
31+
# Download URLs for the .deb packages (note the -1 suffix in the filename)
32+
VERSION_NUM="${LATEST_VERSION#v}"
33+
DAEMON_URL="https://github.com/evilsocket/opensnitch/releases/download/${LATEST_VERSION}/opensnitch_${VERSION_NUM}-1_amd64.deb"
34+
UI_URL="https://github.com/evilsocket/opensnitch/releases/download/${LATEST_VERSION}/python3-opensnitch-ui_${VERSION_NUM}-1_all.deb"
35+
36+
# Download the packages
37+
echo "Downloading OpenSnitch daemon from: $DAEMON_URL"
38+
if ! wget -q "$DAEMON_URL" -O "opensnitch.deb"; then
39+
echo "Failed to download OpenSnitch daemon"
40+
cd - >/dev/null
41+
rm -rf "$temp_dir"
42+
exit 1
43+
fi
44+
45+
echo "Downloading OpenSnitch UI from: $UI_URL"
46+
if ! wget -q "$UI_URL" -O "opensnitch-ui.deb"; then
47+
echo "Failed to download OpenSnitch UI"
48+
cd - >/dev/null
49+
rm -rf "$temp_dir"
50+
exit 1
51+
fi
52+
53+
# Install the packages
54+
echo "Installing OpenSnitch packages..."
55+
sudo apt-get install -qq ./opensnitch.deb ./opensnitch-ui.deb
56+
57+
# Clean up
58+
cd - >/dev/null
59+
rm -rf "$temp_dir"
60+
61+
# Enable and start the service
62+
sudo systemctl enable opensnitch &>/dev/null || true
63+
sudo systemctl start opensnitch &>/dev/null || true
64+
65+
echo "OpenSnitch installation completed"
66+
else
67+
echo "OpenSnitch is already installed"
68+
fi
69+
70+
# Display version information
71+
if command -v opensnitchd &>/dev/null; then
72+
opensnitchd --version 2>/dev/null || echo "OpenSnitch daemon installed"
73+
fi
74+
else
75+
echo -e "${YELLOW}Skipping OpenSnitch: Linux only${NC}"
76+
fi

tests/test_binaries.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from subprocess import run
88
import pytest
99
import os
10+
import platform
1011

1112

1213
# --------------------------------------------------------------------------- #
@@ -51,6 +52,8 @@ def in_shell_path(shell: Text, binary: Text) -> bool:
5152
"neofetch",
5253
"redis-cli",
5354
"redis-server",
55+
"opensnitchd" if platform.system() == "Linux" else None,
56+
"opensnitch-ui" if platform.system() == "Linux" else None,
5457
# language: python
5558
"pyenv",
5659
"python",

0 commit comments

Comments
 (0)