-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·159 lines (145 loc) · 6.95 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·159 lines (145 loc) · 6.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/usr/bin/env bash
# ─────────────────────────────────────────────────────────────────────────────
# AirDriver installer · Kali / Parrot / Debian / Ubuntu
#
# Sets up everything you need and drops an `airdriver` command on your PATH:
# • system prerequisites (dkms, headers, iw, aircrack-ng, Qt libs…)
# • an isolated Python virtualenv with the GUI (PySide6)
# • a smart launcher that even makes `sudo airdriver` open the GUI correctly
#
# Usage: sudo ./install.sh
# Re-runnable: safe to run again to repair or update an install.
# ─────────────────────────────────────────────────────────────────────────────
set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
VENV="$HERE/.venv"
LAUNCHER="/usr/local/bin/airdriver"
# --- pretty output ----------------------------------------------------------
if [ -t 1 ]; then
BOLD='\033[1m'; GREEN='\033[32m'; YELLOW='\033[33m'; CYAN='\033[36m'; RED='\033[31m'; RESET='\033[0m'
else
BOLD=''; GREEN=''; YELLOW=''; CYAN=''; RED=''; RESET=''
fi
say() { echo -e "${CYAN}${BOLD}▸${RESET} $*"; }
ok() { echo -e " ${GREEN}✓${RESET} $*"; }
warn() { echo -e " ${YELLOW}!${RESET} $*"; }
err() { echo -e " ${RED}✗${RESET} $*"; }
echo
echo -e "${BOLD}${CYAN} AirDriver installer${RESET} — WiFi adapter driver auto-installer"
echo -e " ${YELLOW}https://github.com/at0m-b0mb/AirDriver${RESET}"
echo
IS_ROOT=0; [ "$(id -u)" -eq 0 ] && IS_ROOT=1
# The real user, so a venv made under sudo isn't left root-owned.
REAL_USER="${SUDO_USER:-$(id -un)}"
# --- 0. bootstrap when piped from curl --------------------------------------
# Makes the one-liner work:
# curl -fsSL https://raw.githubusercontent.com/at0m-b0mb/AirDriver/main/install.sh | sudo bash
# When there's no checkout next to this script, fetch one and re-exec from it.
REPO_URL="https://github.com/at0m-b0mb/AirDriver.git"
CLONE_DIR="${AIRDRIVER_DIR:-/opt/airdriver}"
if [ ! -f "$HERE/pyproject.toml" ]; then
say "No local checkout found — fetching AirDriver into $CLONE_DIR …"
if ! command -v git >/dev/null 2>&1; then
if [ "$IS_ROOT" -eq 1 ] && command -v apt-get >/dev/null 2>&1; then
apt-get update -qq || true
apt-get install -y git || { err "Could not install git."; exit 1; }
else
err "git is required. Install it first: sudo apt install -y git"
exit 1
fi
fi
if [ -d "$CLONE_DIR/.git" ]; then
git -C "$CLONE_DIR" pull --ff-only || warn "Could not update the existing clone."
else
mkdir -p "$(dirname "$CLONE_DIR")"
git clone --depth=1 "$REPO_URL" "$CLONE_DIR" || { err "Clone failed."; exit 1; }
fi
ok "Source at $CLONE_DIR"
exec bash "$CLONE_DIR/install.sh" "$@"
fi
# --- 1. system prerequisites (needs root; best-effort) ----------------------
if command -v apt-get >/dev/null 2>&1; then
if [ "$IS_ROOT" -eq 1 ]; then
say "Installing system prerequisites (this can take a minute)…"
apt-get update -qq || warn "apt update failed (offline?) — continuing."
# Build toolchain + pentest tooling. usbutils/pciutils are a convenience,
# not a requirement: AirDriver enumerates hardware from sysfs and only uses
# lsusb/lspci, when present, for their vendor-resolved product names.
BUILD_PKGS=(python3 python3-venv python3-pip
dkms build-essential bc libelf-dev git pkg-config
usbutils pciutils iw wireless-tools rfkill aircrack-ng
"linux-headers-$(uname -r)")
# Qt6 / xcb runtime libs PySide6 needs to actually open a window.
QT_PKGS=(libgl1 libegl1 libdbus-1-3 libxkbcommon-x11-0
libxcb-cursor0 libxcb-xinerama0 libxcb-icccm4 libxcb-image0
libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-shape0
libxcb-shm0 libxcb-util1 fontconfig)
apt-get install -y --no-install-recommends "${BUILD_PKGS[@]}" \
|| warn "Some build packages failed — driver builds may need them later."
apt-get install -y --no-install-recommends "${QT_PKGS[@]}" \
|| warn "Some Qt libs failed to install — the GUI may not open (CLI still works)."
ok "System prerequisites done."
else
warn "Not root: skipping system packages."
warn "For the full setup (and the GUI) re-run with: ${BOLD}sudo ./install.sh${RESET}"
fi
else
warn "No apt found — assuming this is a dev box. Installing Python deps only."
fi
# --- 2. Python virtualenv + AirDriver (with GUI extras) ---------------------
# Build the venv as the real user when we were invoked via sudo, so the user
# can run/update it later without sudo.
run_as_user() {
if [ "$IS_ROOT" -eq 1 ] && [ "$REAL_USER" != "root" ]; then
sudo -u "$REAL_USER" "$@"
else
"$@"
fi
}
say "Creating Python virtualenv at .venv …"
if [ ! -x "$VENV/bin/python" ]; then
run_as_user python3 -m venv "$VENV"
fi
run_as_user "$VENV/bin/python" -m pip install --quiet --upgrade pip wheel || true
say "Installing AirDriver + GUI (PySide6)…"
if run_as_user "$VENV/bin/python" -m pip install --quiet -e "$HERE[gui]"; then
ok "Installed AirDriver with the GUI."
else
warn "GUI extra failed — installing core only (CLI will still work)."
run_as_user "$VENV/bin/python" -m pip install --quiet -e "$HERE" \
&& ok "Installed AirDriver (CLI only)."
fi
# --- 3. smart launcher on PATH ----------------------------------------------
say "Installing the 'airdriver' launcher…"
write_launcher() {
cat > "$1" <<EOF
#!/usr/bin/env bash
# AirDriver launcher (generated by install.sh). The display-env repair for
# 'sudo airdriver' lives in Python (airdriver.gui.app), so this just execs.
exec "$VENV/bin/python" -m airdriver "\$@"
EOF
chmod +x "$1"
}
if [ "$IS_ROOT" -eq 1 ] || [ -w "$(dirname "$LAUNCHER")" ]; then
write_launcher "$LAUNCHER"
ok "Launcher installed: ${BOLD}$LAUNCHER${RESET}"
else
mkdir -p "$HOME/.local/bin"
write_launcher "$HOME/.local/bin/airdriver"
ok "Launcher installed: ${BOLD}$HOME/.local/bin/airdriver${RESET}"
case ":$PATH:" in
*":$HOME/.local/bin:"*) : ;;
*) warn "Add ~/.local/bin to PATH: echo 'export PATH=\"\$HOME/.local/bin:\$PATH\"' >> ~/.bashrc" ;;
esac
fi
# --- 4. done ----------------------------------------------------------------
echo
echo -e "${GREEN}${BOLD} AirDriver is installed.${RESET}"
echo
echo -e " ${BOLD}Launch the GUI${RESET} ${GREEN}sudo airdriver${RESET} ${YELLOW}# recommended — installs run as root${RESET}"
echo -e " ${BOLD}Scan adapters${RESET} ${GREEN}airdriver scan${RESET}"
echo -e " ${BOLD}Check readiness${RESET} ${GREEN}airdriver doctor${RESET}"
echo -e " ${BOLD}Bundle offline${RESET} ${GREEN}./scripts/fetch_offline_drivers.sh${RESET} ${YELLOW}# run while online${RESET}"
echo
echo -e " No display / over SSH? Everything works headless via the CLI."
echo