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
0 commit comments