-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathinstall.sh
More file actions
89 lines (79 loc) · 2.95 KB
/
install.sh
File metadata and controls
89 lines (79 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
# install-deps.sh - Handles installation of UV and libpcap (Linux/macOS equivalent of Npcap).
# This script is designed to run on Linux (Debian/Ubuntu, Fedora/RHEL) and macOS (Homebrew).
# It will use 'sudo' to install system dependencies.
# Exit immediately if a command exits with a non-zero status.
set -e
if [ "$EUID" -eq 0 ]; then
echo "Error: Do not run this script as root. Please run as a regular user."
exit 1
fi
# --- 0. Utility Functions ---
# Function to check if a command exists
command_exists () {
command -v "$1" >/dev/null 2>&1
}
# Function to detect the package manager
detect_package_manager() {
if command_exists apt-get; then
echo "apt"
elif command_exists yum; then
echo "yum"
elif command_exists dnf; then
echo "dnf"
elif command_exists brew; then
echo "brew"
else
echo "unknown"
fi
}
# --- 1. Libpcap (Packet Capture Dependency) Check and Installation ---
echo "Checking and installing packet capture dependencies (libpcap equivalent)..."
MANAGER=$(detect_package_manager)
LIBCAP_DEPS=()
case "$MANAGER" in
"apt")
echo "Detected Debian/Ubuntu."
LIBCAP_DEPS=("libpcap-dev" "tcpdump")
sudo apt-get update
sudo apt-get install -y "${LIBCAP_DEPS[@]}"
;;
"yum" | "dnf")
echo "Detected Fedora/RHEL/CentOS."
LIBCAP_DEPS=("libpcap" "libpcap-devel" "tcpdump")
# On RHEL/Fedora, access is often granted by default or via /dev/bpf/
sudo $MANAGER install -y "${LIBCAP_DEPS[@]}"
;;
"brew")
echo "Detected macOS (Homebrew)."
# macOS uses BPF devices for network capture, but libpcap is still needed for headers
LIBCAP_DEPS=("libpcap" "tcpdump")
if command_exists brew; then
brew install "${LIBCAP_DEPS[@]}" || true # Allow it to fail if already installed
else
echo "Error: Homebrew is not installed. Please install Homebrew before running this script on macOS."
exit 1
fi
;;
"unknown")
echo "Error: Could not detect a supported package manager (apt, yum, dnf, or brew)."
echo "Please manually install 'libpcap' development headers and 'tcpdump'."
exit 1
;;
esac
echo "Packet capture dependencies installed."
# --- 3. UV Installation ---
echo "Checking for 'uv' and installing if necessary..."
if ! command_exists uv; then
echo "'uv' not found. Installing now (this may take a moment)..."
# Download and execute the uv install script
curl -Ls https://astral.sh/uv/install.sh | bash
# Note: UV is typically installed into $HOME/.cargo/bin,
# which needs to be in PATH for the next step.
echo "UV installation complete."
else
echo "'uv' found. Skipping UV installation."
fi
echo "=========================================================="
echo "Setup is complete. Returning control to the launch script."
echo "=========================================================="