forked from disler/mac-mini-agent
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·276 lines (230 loc) · 6.75 KB
/
install.sh
File metadata and controls
executable file
·276 lines (230 loc) · 6.75 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
#!/usr/bin/env bash
# Linux Mini Agent — Automated Installer
# Run: ./install.sh
#
# Installs system dependencies, Python environments, and verifies everything works.
# Requires sudo for apt packages. Safe to re-run (skips already-installed tools).
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "$0")" && pwd)"
PASS=0
FAIL=0
WARN=0
# --- Helpers ---
info() { echo -e "\033[1;34m[INFO]\033[0m $*"; }
ok() { echo -e "\033[1;32m[PASS]\033[0m $*"; PASS=$((PASS + 1)); }
fail() { echo -e "\033[1;31m[FAIL]\033[0m $*"; FAIL=$((FAIL + 1)); }
warn() { echo -e "\033[1;33m[WARN]\033[0m $*"; WARN=$((WARN + 1)); }
step() { echo ""; echo -e "\033[1;37m--- $* ---\033[0m"; }
has() { command -v "$1" &>/dev/null; }
# --- Phase 1: System Info ---
step "System Info"
if [ -f /etc/os-release ]; then
. /etc/os-release
info "OS: $PRETTY_NAME"
else
info "OS: $(uname -s) $(uname -r)"
fi
info "Kernel: $(uname -r)"
info "Arch: $(uname -m)"
if [ -z "${DISPLAY:-}" ] && [ -z "${WAYLAND_DISPLAY:-}" ]; then
warn "No DISPLAY set — GUI tools (steer) require an X11 session"
fi
# --- Phase 2: Install System Packages ---
step "System Packages"
APT_PACKAGES=(
tmux
xdotool
scrot
tesseract-ocr
wmctrl
xclip
x11-utils
imagemagick
)
OPTIONAL_PACKAGES=(
python3-gi
gir1.2-atspi-2.0
)
missing=()
for pkg in "${APT_PACKAGES[@]}"; do
if dpkg -s "$pkg" &>/dev/null; then
info "$pkg: already installed"
else
missing+=("$pkg")
fi
done
optional_missing=()
for pkg in "${OPTIONAL_PACKAGES[@]}"; do
if dpkg -s "$pkg" &>/dev/null; then
info "$pkg: already installed"
else
optional_missing+=("$pkg")
fi
done
if [ ${#missing[@]} -gt 0 ]; then
info "Installing: ${missing[*]}"
sudo apt update -qq
sudo apt install -y -qq "${missing[@]}"
fi
if [ ${#optional_missing[@]} -gt 0 ]; then
info "Installing optional (AT-SPI accessibility): ${optional_missing[*]}"
sudo apt install -y -qq "${optional_missing[@]}" 2>/dev/null || warn "Optional AT-SPI packages failed — accessibility trees won't work"
fi
# --- Phase 3: Install uv ---
step "Python Package Manager (uv)"
if has uv; then
info "uv: $(uv --version)"
else
info "Installing uv..."
curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="$HOME/.local/bin:$PATH"
if has uv; then
info "uv installed: $(uv --version)"
else
fail "uv installation failed"
fi
fi
# --- Phase 4: Install just ---
step "Task Runner (just)"
if has just; then
info "just: $(just --version)"
else
info "Installing just..."
if has cargo; then
cargo install just
elif has apt; then
sudo apt install -y -qq just 2>/dev/null || {
# just may not be in apt on older distros — try prebuilt
curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to "$HOME/.local/bin"
}
fi
if has just; then
info "just installed: $(just --version)"
else
fail "just installation failed — install manually: https://github.com/casey/just"
fi
fi
# --- Phase 5: Sync Python Apps ---
step "Python App Dependencies"
cd "$REPO_ROOT"
for app in steer drive listen direct telegram; do
app_dir="$REPO_ROOT/apps/$app"
if [ -f "$app_dir/pyproject.toml" ]; then
info "Syncing $app..."
(cd "$app_dir" && uv sync --quiet 2>&1) && info "$app: dependencies synced" || warn "$app: sync had warnings"
else
warn "$app: no pyproject.toml found"
fi
done
# --- Phase 6: Create .env if missing ---
step "Environment Configuration"
if [ ! -f "$REPO_ROOT/.env" ]; then
cp "$REPO_ROOT/.env.sample" "$REPO_ROOT/.env"
chmod 600 "$REPO_ROOT/.env"
info "Created .env from .env.sample (permissions: 600) — edit it to add your API keys and tokens"
else
# Ensure existing .env has restrictive permissions (contains API keys)
chmod 600 "$REPO_ROOT/.env"
info ".env already exists (permissions secured)"
fi
# --- Phase 7: Verification ---
step "Verification"
# Check system tools
for tool in tmux xdotool scrot tesseract wmctrl xclip xrandr; do
if has "$tool"; then
ok "$tool"
else
fail "$tool not found"
fi
done
# Check uv
if has uv; then
ok "uv ($(uv --version 2>/dev/null || echo '?'))"
else
fail "uv not found"
fi
# Check just
if has just; then
ok "just ($(just --version 2>/dev/null || echo '?'))"
else
fail "just not found"
fi
# Check steer
if (cd "$REPO_ROOT/apps/steer" && uv run python main.py --version) &>/dev/null; then
ok "steer CLI"
else
fail "steer CLI failed to run"
fi
# Check drive
if (cd "$REPO_ROOT/apps/drive" && uv run python main.py --version) &>/dev/null; then
ok "drive CLI"
else
fail "drive CLI failed to run"
fi
# Check listen (no --help flag; just verify imports work)
if (cd "$REPO_ROOT/apps/listen" && uv run python -c "import main; print('ok')") &>/dev/null; then
ok "listen server"
else
fail "listen server failed"
fi
# Check direct
if (cd "$REPO_ROOT/apps/direct" && uv run python main.py --help) &>/dev/null; then
ok "direct CLI"
else
fail "direct CLI failed"
fi
# Check telegram
if (cd "$REPO_ROOT/apps/telegram" && uv run python -c "import telegram; print('ok')") &>/dev/null; then
ok "telegram bot dependencies"
else
fail "telegram bot dependencies failed"
fi
# Check justfile
if (cd "$REPO_ROOT" && just --list) &>/dev/null; then
ok "justfile recipes"
else
fail "justfile failed"
fi
# Screenshot test (only if DISPLAY is set)
if [ -n "${DISPLAY:-}" ]; then
screenshot_out=$(cd "$REPO_ROOT/apps/steer" && uv run python main.py see --json 2>/dev/null || echo "")
if echo "$screenshot_out" | grep -q '"screenshot"'; then
ok "steer screenshot (X11)"
else
fail "steer screenshot — check DISPLAY and scrot"
fi
else
warn "Skipping screenshot test — no DISPLAY set"
fi
# tmux test
if tmux new-session -d -s _install_test 2>/dev/null; then
tmux kill-session -t _install_test 2>/dev/null
ok "tmux sessions"
else
fail "tmux session creation"
fi
# --- Report ---
step "Results"
TOTAL=$((PASS + FAIL))
echo ""
echo " Passed: $PASS/$TOTAL"
if [ $FAIL -gt 0 ]; then
echo " Failed: $FAIL"
fi
if [ $WARN -gt 0 ]; then
echo " Warnings: $WARN"
fi
echo ""
if [ $FAIL -eq 0 ]; then
echo -e "\033[1;32m✓ Installation complete! All checks passed.\033[0m"
echo ""
echo " Next steps:"
echo " 1. Edit .env with your API keys"
echo " 2. just listen — start the job server"
echo " 3. just telegram — start the Telegram bot (needs TELEGRAM_BOT_TOKEN)"
echo " 4. just send \"prompt\" — send a job"
echo ""
else
echo -e "\033[1;31m✗ $FAIL check(s) failed. Fix the issues above and re-run ./install.sh\033[0m"
exit 1
fi