-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·578 lines (511 loc) · 17.2 KB
/
install.sh
File metadata and controls
executable file
·578 lines (511 loc) · 17.2 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
#!/usr/bin/env bash
#
# Spin OSINT Browser - Interactive Installer
# v12.0.3 "Jessica Jones"
#
# Usage: curl -fsSL https://raw.githubusercontent.com/thumpersecure/Spin/main/install.sh | bash
# or: bash install.sh
#
# Zero NPM — Pure Rust (iced 0.13 + wry 0.44)
# Only requires: git, rust/cargo, system GUI libraries
#
set -euo pipefail
# --- Colors ---
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
BOLD='\033[1m'
NC='\033[0m'
# --- Config ---
REPO_URL="https://github.com/thumpersecure/Spin.git"
REPO_API="https://api.github.com/repos/thumpersecure/Spin"
INSTALL_DIR="$HOME/Spin"
APP_DIR="$INSTALL_DIR/app"
CARGO_DIR="$APP_DIR/src-tauri"
BIN_PATH="$CARGO_DIR/target/release/spin"
MIN_RUST_VERSION="1.75"
CURRENT_VERSION="12.0.3"
# --- Helpers ---
print_banner() {
echo -e "${PURPLE}"
echo " ╔══════════════════════════════════════════════════╗"
echo " ║ ║"
echo " ║ S P I N v12.0.3 - Jessica Jones ║"
echo " ║ OSINT Investigation Browser ║"
echo " ║ ║"
echo " ║ \"Every case starts with a question.\" ║"
echo " ║ ║"
echo " ║ Zero NPM · Pure Rust · iced 0.13 · wry ║"
echo " ║ ║"
echo " ╚══════════════════════════════════════════════════╝"
echo -e "${NC}"
}
info() { echo -e "${BLUE}[INFO]${NC} $1"; }
success() { echo -e "${GREEN}[OK]${NC} $1"; }
warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
error() { echo -e "${RED}[ERROR]${NC} $1"; }
ask_yes_no() {
local prompt="$1"
local default="${2:-y}"
local choice
if [ "$default" = "y" ]; then
read -rp "$(echo -e "${CYAN}$prompt [Y/n]:${NC} ")" choice
choice="${choice:-y}"
else
read -rp "$(echo -e "${CYAN}$prompt [y/N]:${NC} ")" choice
choice="${choice:-n}"
fi
[[ "$choice" =~ ^[Yy] ]]
}
version_ge() {
# Returns 0 if $1 >= $2 (version comparison)
printf '%s\n%s' "$2" "$1" | sort -V -C
}
detect_os() {
if [[ "$OSTYPE" == "darwin"* ]]; then
echo "macos"
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
echo "linux"
else
echo "unknown"
fi
}
detect_linux_distro() {
if [ -f /etc/os-release ]; then
. /etc/os-release
echo "$ID"
else
echo "unknown"
fi
}
# --- Dependency Checks ---
check_git() {
if command -v git &>/dev/null; then
local ver
ver=$(git --version | grep -oP '\d+\.\d+\.\d+' | head -1)
success "Git found: v$ver"
return 0
else
warn "Git not found"
return 1
fi
}
check_rust() {
if command -v rustc &>/dev/null && command -v cargo &>/dev/null; then
local ver
ver=$(rustc --version | grep -oP '\d+\.\d+\.\d+' | head -1)
if version_ge "$ver" "$MIN_RUST_VERSION"; then
success "Rust found: v$ver (>= $MIN_RUST_VERSION required)"
return 0
else
warn "Rust v$ver found, but v$MIN_RUST_VERSION+ required"
return 1
fi
else
warn "Rust not found"
return 1
fi
}
# --- Install Functions ---
install_rust() {
info "Installing Rust via rustup..."
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source "$HOME/.cargo/env" 2>/dev/null || true
}
install_linux_deps() {
local distro
distro=$(detect_linux_distro)
info "Installing system libraries for $distro..."
case "$distro" in
ubuntu|debian|parrot|kali|linuxmint|pop)
sudo apt-get update
sudo apt-get install -y \
libgtk-3-dev \
libwebkit2gtk-4.1-dev \
libayatana-appindicator3-dev \
librsvg2-dev \
patchelf \
build-essential \
curl \
wget \
file \
libssl-dev \
libxdo-dev
;;
fedora|rhel|centos|rocky|alma)
sudo dnf install -y \
gtk3-devel \
webkit2gtk4.1-devel \
libappindicator-gtk3-devel \
librsvg2-devel \
patchelf \
openssl-devel
;;
arch|manjaro|endeavouros)
sudo pacman -S --noconfirm \
gtk3 \
webkit2gtk-4.1 \
libappindicator-gtk3 \
librsvg \
patchelf \
openssl
;;
*)
warn "Unsupported distro: $distro. You may need to install GTK3 and WebKit2GTK manually."
;;
esac
}
install_macos_deps() {
if ! command -v brew &>/dev/null; then
info "Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
}
# --- Uninstall ---
uninstall_spin() {
echo ""
info "Uninstalling Spin..."
if [ -d "$INSTALL_DIR" ]; then
if ask_yes_no "Remove $INSTALL_DIR?"; then
rm -rf "$INSTALL_DIR"
success "Removed $INSTALL_DIR"
fi
else
info "No installation found at $INSTALL_DIR"
fi
# Remove desktop shortcut
local desktop_file
if [ "$(detect_os)" = "linux" ]; then
desktop_file="$HOME/.local/share/applications/spin-browser.desktop"
if [ -f "$desktop_file" ]; then
rm -f "$desktop_file"
success "Removed desktop shortcut"
fi
if [ -f "$HOME/Desktop/spin-browser.desktop" ]; then
rm -f "$HOME/Desktop/spin-browser.desktop"
success "Removed Desktop shortcut"
fi
elif [ "$(detect_os)" = "macos" ]; then
if [ -L "/Applications/Spin.app" ]; then
rm -f "/Applications/Spin.app"
success "Removed /Applications/Spin.app symlink"
fi
fi
success "Uninstall complete."
echo ""
}
# --- Desktop Shortcut ---
create_desktop_shortcut() {
local os
os=$(detect_os)
if [ "$os" = "linux" ]; then
local icon_path="$INSTALL_DIR/assets/icon.png"
local desktop_entry="[Desktop Entry]
Name=Spin Browser
Comment=OSINT Investigation Browser - Jessica Jones v12.0.3
Exec=$BIN_PATH
Icon=$icon_path
Terminal=false
Type=Application
Categories=Network;WebBrowser;Security;
StartupNotify=true"
# App menu entry
mkdir -p "$HOME/.local/share/applications"
echo "$desktop_entry" > "$HOME/.local/share/applications/spin-browser.desktop"
chmod +x "$HOME/.local/share/applications/spin-browser.desktop"
success "Created app menu entry"
# Desktop shortcut
if [ -d "$HOME/Desktop" ]; then
echo "$desktop_entry" > "$HOME/Desktop/spin-browser.desktop"
chmod +x "$HOME/Desktop/spin-browser.desktop"
success "Created Desktop shortcut"
fi
elif [ "$os" = "macos" ]; then
info "On macOS, copy the built binary to your PATH:"
echo " sudo cp $BIN_PATH /usr/local/bin/spin"
echo " spin"
fi
}
# --- Main Install ---
do_install() {
echo ""
info "Starting installation..."
echo ""
# Step 1: Check/install dependencies
echo -e "${BOLD}Step 1: Checking dependencies...${NC}"
echo ""
local need_rust=false
check_git || { error "Git is required. Please install it first."; exit 1; }
if ! check_rust; then
need_rust=true
fi
echo ""
# Install missing deps
local os
os=$(detect_os)
if [ "$need_rust" = true ]; then
if ask_yes_no "Install Rust?"; then
install_rust
check_rust || { error "Rust installation failed."; exit 1; }
else
error "Rust $MIN_RUST_VERSION+ is required. Aborting."
exit 1
fi
fi
# System libraries
echo ""
echo -e "${BOLD}Step 2: System libraries...${NC}"
echo ""
if [ "$os" = "linux" ]; then
if ask_yes_no "Install system libraries (GTK3, WebKit2GTK, etc.)?"; then
install_linux_deps
fi
elif [ "$os" = "macos" ]; then
install_macos_deps
fi
# Step 3: Clone or update repo
echo ""
echo -e "${BOLD}Step 3: Getting Spin source code...${NC}"
echo ""
if [ -d "$INSTALL_DIR/.git" ]; then
info "Existing installation found at $INSTALL_DIR"
if ask_yes_no "Update to latest version?"; then
cd "$INSTALL_DIR"
git pull origin main
success "Updated to latest"
fi
else
if [ -d "$INSTALL_DIR" ]; then
warn "$INSTALL_DIR exists but is not a git repo"
if ask_yes_no "Remove and re-clone?"; then
rm -rf "$INSTALL_DIR"
else
error "Cannot continue. Please remove $INSTALL_DIR manually."
exit 1
fi
fi
info "Cloning Spin..."
git clone "$REPO_URL" "$INSTALL_DIR"
success "Cloned to $INSTALL_DIR"
fi
# Step 4: Fetch Rust dependencies
echo ""
echo -e "${BOLD}Step 4: Fetching Rust dependencies...${NC}"
echo ""
cd "$CARGO_DIR"
cargo fetch
success "Rust dependencies fetched"
# Step 5: Build verification
echo ""
echo -e "${BOLD}Step 5: Verifying build...${NC}"
echo ""
info "Running cargo check..."
if cargo check 2>&1; then
success "Rust build check: OK"
else
warn "cargo check had issues — see above. The build may still succeed."
fi
# Step 6: Desktop shortcut
echo ""
if ask_yes_no "Create a desktop shortcut?"; then
info "Building release binary first (required for shortcut)..."
cargo build --release
success "Built: $BIN_PATH"
create_desktop_shortcut
fi
# Done!
echo ""
echo -e "${GREEN}╔══════════════════════════════════════════════════╗${NC}"
echo -e "${GREEN}║ ║${NC}"
echo -e "${GREEN}║ Installation complete! ║${NC}"
echo -e "${GREEN}║ ║${NC}"
echo -e "${GREEN}║ To run Spin (dev): ║${NC}"
echo -e "${GREEN}║ cd ~/Spin/app/src-tauri && cargo run ║${NC}"
echo -e "${GREEN}║ ║${NC}"
echo -e "${GREEN}║ To build for production: ║${NC}"
echo -e "${GREEN}║ cd ~/Spin/app/src-tauri ║${NC}"
echo -e "${GREEN}║ cargo build --release ║${NC}"
echo -e "${GREEN}║ ║${NC}"
echo -e "${GREEN}╚══════════════════════════════════════════════════╝${NC}"
echo ""
# Verification
verify_install
}
# --- Verification ---
verify_install() {
echo -e "${BOLD}Verification:${NC}"
local all_ok=true
if [ -d "$APP_DIR" ]; then
success "App directory exists: $APP_DIR"
else
error "App directory missing: $APP_DIR"
all_ok=false
fi
if [ -f "$CARGO_DIR/Cargo.toml" ]; then
local ver
ver=$(grep -m1 '^version' "$CARGO_DIR/Cargo.toml" | cut -d'"' -f2)
success "Rust crate found: v$ver"
else
error "Cargo.toml missing at $CARGO_DIR"
all_ok=false
fi
if [ -f "$CARGO_DIR/Cargo.lock" ]; then
success "Cargo.lock present (dependencies resolved)"
else
warn "Cargo.lock missing — run: cd $CARGO_DIR && cargo fetch"
fi
if [ -f "$BIN_PATH" ]; then
success "Release binary built: $BIN_PATH"
else
warn "Release binary not built yet"
info "Build it with: cd $CARGO_DIR && cargo build --release"
fi
echo ""
if [ "$all_ok" = true ]; then
success "All checks passed. Spin is ready."
else
error "Some checks failed. See above for details."
fi
echo ""
}
# --- Check for Updates ---
check_for_updates() {
echo ""
info "Checking for updates..."
echo ""
# Read local version from Cargo.toml
local local_version="(not installed)"
if [ -f "$CARGO_DIR/Cargo.toml" ]; then
local_version=$(grep -m1 '^version' "$CARGO_DIR/Cargo.toml" | cut -d'"' -f2)
fi
info "Installed version: ${BOLD}$local_version${NC}"
info "Installer version: ${BOLD}$CURRENT_VERSION${NC}"
# Try to get latest release from GitHub API
if command -v curl &>/dev/null; then
local latest_tag
latest_tag=$(curl -sf "${REPO_API}/releases/latest" 2>/dev/null | grep -o '"tag_name": "[^"]*"' | cut -d'"' -f4)
if [ -n "$latest_tag" ]; then
local latest_version="${latest_tag#v}"
info "Latest release: ${BOLD}$latest_version${NC}"
if [ "$local_version" = "(not installed)" ]; then
warn "Spin is not installed. Use option 1 to install."
elif [ "$local_version" = "$latest_version" ]; then
success "You're running the latest release!"
elif version_ge "$latest_version" "$local_version"; then
warn "A newer version is available: v$latest_version"
echo ""
if ask_yes_no "Would you like to update now?"; then
cd "$INSTALL_DIR"
git fetch origin main
git pull origin main
cd "$CARGO_DIR"
cargo fetch
success "Updated to latest version."
echo ""
info "Rebuild with: cd $CARGO_DIR && cargo build --release"
fi
else
success "Your version ($local_version) is ahead of the latest release ($latest_version)."
fi
else
warn "Could not fetch latest release info from GitHub."
info "Check manually: https://github.com/thumpersecure/Spin/releases"
fi
else
warn "curl not available. Cannot check remote version."
fi
# Also check if the local git repo has upstream changes
if [ -d "$INSTALL_DIR/.git" ]; then
echo ""
info "Checking git repository for upstream changes..."
cd "$INSTALL_DIR"
git fetch origin main 2>/dev/null
local behind
behind=$(git rev-list --count HEAD..origin/main 2>/dev/null || echo "0")
if [ "$behind" -gt 0 ]; then
warn "Your installation is $behind commit(s) behind origin/main."
if ask_yes_no "Pull latest changes?"; then
git pull origin main
cd "$CARGO_DIR"
cargo fetch
success "Repository updated."
info "Rebuild with: cd $CARGO_DIR && cargo build --release"
fi
else
success "Repository is up to date with origin/main."
fi
fi
echo ""
}
# --- Main Menu ---
main() {
print_banner
echo -e "${BOLD}What would you like to do?${NC}"
echo ""
echo " 1) Install Spin (full installation)"
echo " 2) Update existing installation"
echo " 3) Check for updates"
echo " 4) Uninstall Spin"
echo " 5) Verify installation"
echo " 6) Build release binary"
echo " 7) Exit"
echo ""
read -rp "$(echo -e "${CYAN}Choose [1-7]:${NC} ")" choice
case "$choice" in
1)
# Check for old version
if [ -d "$INSTALL_DIR" ]; then
warn "Existing Spin installation found at $INSTALL_DIR"
if ask_yes_no "Would you like to uninstall the old version first? (recommended for stability)"; then
uninstall_spin
fi
fi
do_install
;;
2)
if [ ! -d "$INSTALL_DIR/.git" ]; then
error "No Spin installation found. Use option 1 to install."
exit 1
fi
cd "$INSTALL_DIR"
git pull origin main
cd "$CARGO_DIR"
cargo fetch
success "Updated successfully."
info "Rebuild with: cd $CARGO_DIR && cargo build --release"
verify_install
;;
3)
check_for_updates
;;
4)
uninstall_spin
;;
5)
verify_install
;;
6)
if [ ! -f "$CARGO_DIR/Cargo.toml" ]; then
error "Spin is not installed. Use option 1 to install first."
exit 1
fi
cd "$CARGO_DIR"
info "Building release binary..."
cargo build --release
success "Built: $BIN_PATH"
info "Run with: $BIN_PATH"
;;
7)
info "Goodbye."
exit 0
;;
*)
error "Invalid choice."
exit 1
;;
esac
}
main "$@"