Skip to content

Commit 588b127

Browse files
committed
MacOS fixes. More robust dots.
1 parent abb4cd4 commit 588b127

File tree

1 file changed

+42
-39
lines changed

1 file changed

+42
-39
lines changed

install.sh

100644100755
Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#!/bin/bash
2+
export LANG=en_US.UTF-8
23
set -e
34

4-
LOGO=$(cat <<EOF
5+
LOGO=$(cat <<'EOF'
56
___ ___ ___ ___ ___ ___ ___ ___ ___ ___
67
/\ \ /\ \ /\ \ /\__\ /\ \ /\ \ /\ \ /\ \ /\ \ /\__\
78
/::\ \ /::\ \ /::\ \ /:| _|_ \:\ \ /::\ \ \:\ \ /::\ \ /::\ \ /:/ _/_
8-
/::\:\__\ /:/\:\__\ /::\:\__\ /::|/\__\ /::\__\ /\:\:\__\ /::\__\ /::\:\__\ /:/\:\__\ /::-"\__\\
9-
\/\::/ / \:\:\/__/ \:\:\/ / \/|::/ / /:/\/__/ \:\:\/__/ /:/\/__/ \/\::/ / \:\ \/__/ \;:;-",-"
9+
/::\:\__\ /:/\:\__\ /::\:\__\ /::|/\__\ /::\__\ /\:\:\__\ /::\__\ /::\:\__\ /:/\:\__\ /::- \__\\
10+
\/\::/ / \:\:\/__/ \:\:\/ / \/|::/ / /:/\/__/ \:\:\/__/ /:/\/__/ \/\::/ / \:\ \/__/ \;:;- ,-
1011
/:/ / \::/ / \:\/ / |:/ / \/__/ \::/ / \/__/ /:/ / \:\__\ |:| |
1112
\/__/ \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ \|__|
1213
EOF
@@ -28,6 +29,7 @@ MSG_SUCCESS=$(cat <<EOF
2829
✅ Setup complete!
2930
3031
To get started with AgentStack, run:
32+
exec \$SHELL
3133
agentstack init
3234
3335
For more information, run:
@@ -64,6 +66,7 @@ EOF
6466
}
6567
# TODO allow user to specify install path with --target
6668
# TODO allow user to specify Python version with --python-version
69+
# TODO uninstall
6770

6871
say() {
6972
if [ "1" = "$PRINT_QUIET" ]; then
@@ -77,14 +80,34 @@ say_verbose() {
7780
fi
7881
}
7982

80-
show_activity() {
83+
ACTIVITY_PID=""
84+
_show_activity() {
8185
while true; do
8286
echo -n "."
8387
sleep 1
8488
done
8589
}
8690

91+
show_activity() {
92+
if [ "1" = "$PRINT_QUIET" ] || [ "1" = "$PRINT_VERBOSE" ]; then
93+
return 0
94+
fi
95+
_show_activity &
96+
ACTIVITY_PID=$!
97+
# trap end_activity EXIT
98+
# trap 'kill $ACTIVITY_PID' INT
99+
# wait $ACTIVITY_PID
100+
}
101+
102+
end_activity() {
103+
if [ -n "$ACTIVITY_PID" ]; then
104+
say "" # newline after the dots
105+
kill $ACTIVITY_PID
106+
fi
107+
}
108+
87109
err() {
110+
end_activity
88111
if [ "1" = "$PRINT_QUIET" ]; then
89112
local _red=$(tput setaf 1 2>/dev/null || echo '')
90113
local _reset=$(tput sgr0 2>/dev/null || echo '')
@@ -179,8 +202,7 @@ install_uv() {
179202
else
180203
say "Installing uv..."
181204
fi
182-
show_activity &
183-
local _activity_pid=$!
205+
show_activity
184206

185207
# download with curl or wget
186208
local _install_cmd
@@ -203,21 +225,13 @@ install_uv() {
203225
err "uv installation failed: $_output"
204226
fi
205227

206-
# ensure uv is in PATH
207-
if ! check_cmd uv; then
208-
say_verbose "Adding ~/.local/bin to PATH"
209-
update_path "$HOME/.local/bin"
210-
fi
211-
212228
# verify uv installation
213229
local _uv_version
214230
_uv_version="$(uv --version 2>/dev/null)" || {
215231
_uv_version=0
216232
}
217233

218-
kill $_activity_pid
219-
say ""
220-
234+
end_activity
221235
if [ -z "$_uv_version" ]; then
222236
err "uv installation failed."
223237
else
@@ -235,8 +249,7 @@ setup_python() {
235249
say "Python $_python_version is available."
236250
return 0
237251
else
238-
show_activity &
239-
local _activity_pid=$!
252+
show_activity
240253

241254
say "Installing Python $PYTHON_VERSION..."
242255
uv python install "$PYTHON_VERSION" --preview 2>/dev/null || {
@@ -246,8 +259,7 @@ setup_python() {
246259
err "Failed to find Python"
247260
}
248261

249-
kill $_activity_pid
250-
say ""
262+
end_activity
251263
fi
252264

253265
if [ -x "$PYTHON_BIN_PATH" ]; then
@@ -261,8 +273,7 @@ setup_python() {
261273
# Install an official release of the app
262274
install_release() {
263275
say "Installing $APP_NAME..."
264-
show_activity &
265-
local _activity_pid=$!
276+
show_activity
266277

267278
local _zip_ext
268279
if check_cmd tar; then
@@ -321,9 +332,7 @@ install_release() {
321332
# install & cleanup
322333
setup_app "$_dir"
323334
rm -rf "$_dir"
324-
325-
kill $_activity_pid
326-
say ""
335+
end_activity
327336
say "💥 $APP_NAME $VERSION installed successfully!"
328337
}
329338

@@ -335,8 +344,7 @@ install_dev_branch() {
335344
fi
336345

337346
say "Installing $APP_NAME..."
338-
show_activity &
339-
local _activity_pid=$!
347+
show_activity
340348
local _dir="$(ensure mktemp -d)" || return 1
341349

342350
# clone from git
@@ -357,9 +365,7 @@ install_dev_branch() {
357365
# install & cleanup
358366
setup_app "$_dir"
359367
rm -rf "$_dir"
360-
361-
kill $_activity_pid
362-
say ""
368+
end_activity
363369
say "🔧 $APP_NAME @ $DEV_BRANCH installed successfully!"
364370
}
365371

@@ -379,6 +385,7 @@ setup_app() {
379385
fi
380386

381387
make_python_bin "$HOME/.local/bin/$APP_NAME"
388+
update_path "$HOME/.local/bin"
382389
say_verbose "Added bin to ~/.local/bin/$APP_NAME"
383390

384391
# verify installation
@@ -389,26 +396,22 @@ setup_app() {
389396
update_path() {
390397
local new_path="$1"
391398

392-
# early exit if path is already present
393-
case ":$PATH:" in
394-
*":$new_path:"*) return 0 ;;
395-
esac
396-
397399
# update for current session
398400
export PATH="$new_path:$PATH"
399401

402+
# update for each shell
400403
local config_files=(
401404
"$HOME/.bashrc" # bash
402405
"$HOME/.zshrc" # ssh
403406
"$HOME/.profile" # POSIX fallback (sh, ksh, etc.)
404407
)
405-
406-
# update for each shell
407408
for config_file in "${config_files[@]}"; do
408409
if [ -f "$config_file" ]; then
409410
if ! grep -E "^[^#]*export[[:space:]]+PATH=.*(:$new_path|$new_path:|$new_path\$)" "$config_file" >/dev/null 2>&1; then
410411
echo "export PATH=\"$new_path:\$PATH\"" >> "$config_file"
411-
say_verbose "Added $new_path to $config_file"
412+
say_verbose "Added PATH $new_path to $config_file"
413+
else
414+
say_verbose "PATH $new_path already in $config_file"
412415
fi
413416
fi
414417
done
@@ -558,13 +561,13 @@ main() {
558561
parse_args "$@"
559562

560563
say "$LOGO\n"
561-
say "Starting installation..."
562564

563565
if check_cmd $APP_NAME; then
564566
say "\n$MSG_ALREADY_INSTALLED\n"
565567
exit 0
566568
fi
567569

570+
say "Starting installation..."
568571
check_dependencies
569572
install_uv
570573
setup_python
@@ -578,4 +581,4 @@ main() {
578581
exit 0
579582
}
580583

581-
main "$@"
584+
main "$@"

0 commit comments

Comments
 (0)