-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·107 lines (94 loc) · 3.5 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·107 lines (94 loc) · 3.5 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
#!/bin/bash
set -e
echo "╔════════════════════════════════════════════════════════════╗"
echo "║ SQLive - Setup & Installation ║"
echo "╚════════════════════════════════════════════════════════════╝"
echo ""
# Detect OS
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
OS="linux"
elif [[ "$OSTYPE" == "darwin"* ]]; then
OS="macos"
else
echo "❌ Unsupported OS: $OSTYPE"
echo "SQLive currently requires Linux (or Linux via Multipass on macOS)"
exit 1
fi
echo "📍 Detected: $OS"
echo ""
# Install dependencies
if [ "$OS" = "linux" ]; then
echo "📦 Installing dependencies..."
# Detect Linux distro
if command -v apt-get &> /dev/null; then
echo " Using apt (Ubuntu/Debian)"
sudo apt-get update
sudo apt-get install -y build-essential curl git bpftrace rustup
elif command -v dnf &> /dev/null; then
echo " Using dnf (Fedora)"
sudo dnf install -y gcc make curl git bpftrace rustup
elif command -v pacman &> /dev/null; then
echo " Using pacman (Arch)"
sudo pacman -S base-devel curl git bpftrace rustup
else
echo "❌ Unsupported package manager"
echo "Please install manually: build tools, curl, git, bpftrace, rustup"
exit 1
fi
fi
echo ""
echo "🦀 Setting up Rust..."
rustup default stable
rustup update
echo ""
echo "🔨 Building SQLive..."
cd "$(dirname "$0")"
cargo build --release
echo ""
echo "📍 Installing binary..."
BINARY_PATH="$(pwd)/target/release/sqlive"
if [ "$OS" = "linux" ]; then
sudo cp "$BINARY_PATH" /usr/local/bin/sqlive
sudo chmod +x /usr/local/bin/sqlive
INSTALL_PATH="/usr/local/bin/sqlive"
elif [ "$OS" = "macos" ]; then
# On macOS, just leave it in the repo
INSTALL_PATH="$BINARY_PATH"
echo "⚠️ macOS detected. You'll need to run SQLive inside a Linux VM (Multipass recommended)"
echo " On macOS: sqlive is at $INSTALL_PATH"
fi
echo ""
echo "✓ Checking bpftrace..."
if ! command -v bpftrace &> /dev/null; then
echo "❌ bpftrace not found!"
echo "Please install bpftrace manually"
exit 1
fi
echo "✓ bpftrace found: $(which bpftrace)"
echo ""
echo "✓ Checking sudo access..."
if ! sudo -n true 2>/dev/null; then
echo "⚠️ You'll be prompted for your password when using sqlive"
fi
echo ""
echo "╔════════════════════════════════════════════════════════════╗"
echo "║ ✓ Setup Complete! ║"
echo "╚════════════════════════════════════════════════════════════╝"
echo ""
echo "🚀 Next steps:"
echo ""
echo "1. Compile your program with debug symbols:"
echo " gcc -g -o myapp myapp.c"
echo ""
echo "2. Start your program:"
echo " ./myapp &"
echo ""
echo "3. Run SQLive:"
echo " sqlive ./myapp --functions 'function_name1,function_name2'"
echo ""
echo "4. Write SQL queries:"
echo " sql> SELECT function, COUNT(*) FROM calls GROUP BY function;"
echo " sql> SELECT * FROM calls LIMIT 10;"
echo ""
echo "📖 For more info: https://github.com/yourusername/sqlive"
echo ""