1
1
#! /bin/bash
2
+ export LANG=en_US.UTF-8
2
3
set -e
3
4
4
- LOGO=$( cat << EOF
5
+ LOGO=$( cat << ' EOF '
5
6
___ ___ ___ ___ ___ ___ ___ ___ ___ ___
6
7
/\ \ /\ \ /\ \ /\__\ /\ \ /\ \ /\ \ /\ \ /\ \ /\__\
7
8
/::\ \ /::\ \ /::\ \ /:| _|_ \:\ \ /::\ \ \:\ \ /::\ \ /::\ \ /:/ _/_
8
- /::\:\__\ /:/\:\__\ /::\:\__\ /::|/\__\ /::\__\ /\:\:\__\ /::\__\ /::\:\__\ /:/\:\__\ /::-" \__\\
9
- \/\::/ / \:\:\/__/ \:\:\/ / \/|::/ / /:/\/__/ \:\:\/__/ /:/\/__/ \/\::/ / \:\ \/__/ \;:;-",-"
9
+ /::\:\__\ /:/\:\__\ /::\:\__\ /::|/\__\ /::\__\ /\:\:\__\ /::\__\ /::\:\__\ /:/\:\__\ /::- \__\\
10
+ \/\::/ / \:\:\/__/ \:\:\/ / \/|::/ / /:/\/__/ \:\:\/__/ /:/\/__/ \/\::/ / \:\ \/__/ \;:;- ,-
10
11
/:/ / \::/ / \:\/ / |:/ / \/__/ \::/ / \/__/ /:/ / \:\__\ |:| |
11
12
\/__/ \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ \|__|
12
13
EOF
@@ -28,6 +29,7 @@ MSG_SUCCESS=$(cat <<EOF
28
29
✅ Setup complete!
29
30
30
31
To get started with AgentStack, run:
32
+ exec \$ SHELL
31
33
agentstack init
32
34
33
35
For more information, run:
64
66
}
65
67
# TODO allow user to specify install path with --target
66
68
# TODO allow user to specify Python version with --python-version
69
+ # TODO uninstall
67
70
68
71
say () {
69
72
if [ " 1" = " $PRINT_QUIET " ]; then
@@ -77,14 +80,34 @@ say_verbose() {
77
80
fi
78
81
}
79
82
80
- show_activity () {
83
+ ACTIVITY_PID=" "
84
+ _show_activity () {
81
85
while true ; do
82
86
echo -n " ."
83
87
sleep 1
84
88
done
85
89
}
86
90
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
+
87
109
err () {
110
+ end_activity
88
111
if [ " 1" = " $PRINT_QUIET " ]; then
89
112
local _red=$( tput setaf 1 2> /dev/null || echo ' ' )
90
113
local _reset=$( tput sgr0 2> /dev/null || echo ' ' )
@@ -179,8 +202,7 @@ install_uv() {
179
202
else
180
203
say " Installing uv..."
181
204
fi
182
- show_activity &
183
- local _activity_pid=$!
205
+ show_activity
184
206
185
207
# download with curl or wget
186
208
local _install_cmd
@@ -203,21 +225,13 @@ install_uv() {
203
225
err " uv installation failed: $_output "
204
226
fi
205
227
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
-
212
228
# verify uv installation
213
229
local _uv_version
214
230
_uv_version=" $( uv --version 2> /dev/null) " || {
215
231
_uv_version=0
216
232
}
217
233
218
- kill $_activity_pid
219
- say " "
220
-
234
+ end_activity
221
235
if [ -z " $_uv_version " ]; then
222
236
err " uv installation failed."
223
237
else
@@ -235,8 +249,7 @@ setup_python() {
235
249
say " Python $_python_version is available."
236
250
return 0
237
251
else
238
- show_activity &
239
- local _activity_pid=$!
252
+ show_activity
240
253
241
254
say " Installing Python $PYTHON_VERSION ..."
242
255
uv python install " $PYTHON_VERSION " --preview 2> /dev/null || {
@@ -246,8 +259,7 @@ setup_python() {
246
259
err " Failed to find Python"
247
260
}
248
261
249
- kill $_activity_pid
250
- say " "
262
+ end_activity
251
263
fi
252
264
253
265
if [ -x " $PYTHON_BIN_PATH " ]; then
@@ -261,8 +273,7 @@ setup_python() {
261
273
# Install an official release of the app
262
274
install_release () {
263
275
say " Installing $APP_NAME ..."
264
- show_activity &
265
- local _activity_pid=$!
276
+ show_activity
266
277
267
278
local _zip_ext
268
279
if check_cmd tar; then
@@ -321,9 +332,7 @@ install_release() {
321
332
# install & cleanup
322
333
setup_app " $_dir "
323
334
rm -rf " $_dir "
324
-
325
- kill $_activity_pid
326
- say " "
335
+ end_activity
327
336
say " 💥 $APP_NAME $VERSION installed successfully!"
328
337
}
329
338
@@ -335,8 +344,7 @@ install_dev_branch() {
335
344
fi
336
345
337
346
say " Installing $APP_NAME ..."
338
- show_activity &
339
- local _activity_pid=$!
347
+ show_activity
340
348
local _dir=" $( ensure mktemp -d) " || return 1
341
349
342
350
# clone from git
@@ -357,9 +365,7 @@ install_dev_branch() {
357
365
# install & cleanup
358
366
setup_app " $_dir "
359
367
rm -rf " $_dir "
360
-
361
- kill $_activity_pid
362
- say " "
368
+ end_activity
363
369
say " 🔧 $APP_NAME @ $DEV_BRANCH installed successfully!"
364
370
}
365
371
@@ -379,6 +385,7 @@ setup_app() {
379
385
fi
380
386
381
387
make_python_bin " $HOME /.local/bin/$APP_NAME "
388
+ update_path " $HOME /.local/bin"
382
389
say_verbose " Added bin to ~/.local/bin/$APP_NAME "
383
390
384
391
# verify installation
@@ -389,26 +396,22 @@ setup_app() {
389
396
update_path () {
390
397
local new_path=" $1 "
391
398
392
- # early exit if path is already present
393
- case " :$PATH :" in
394
- * " :$new_path :" * ) return 0 ;;
395
- esac
396
-
397
399
# update for current session
398
400
export PATH=" $new_path :$PATH "
399
401
402
+ # update for each shell
400
403
local config_files=(
401
404
" $HOME /.bashrc" # bash
402
405
" $HOME /.zshrc" # ssh
403
406
" $HOME /.profile" # POSIX fallback (sh, ksh, etc.)
404
407
)
405
-
406
- # update for each shell
407
408
for config_file in " ${config_files[@]} " ; do
408
409
if [ -f " $config_file " ]; then
409
410
if ! grep -E " ^[^#]*export[[:space:]]+PATH=.*(:$new_path |$new_path :|$new_path \$ )" " $config_file " > /dev/null 2>&1 ; then
410
411
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 "
412
415
fi
413
416
fi
414
417
done
@@ -558,13 +561,13 @@ main() {
558
561
parse_args " $@ "
559
562
560
563
say " $LOGO \n"
561
- say " Starting installation..."
562
564
563
565
if check_cmd $APP_NAME ; then
564
566
say " \n$MSG_ALREADY_INSTALLED \n"
565
567
exit 0
566
568
fi
567
569
570
+ say " Starting installation..."
568
571
check_dependencies
569
572
install_uv
570
573
setup_python
@@ -578,4 +581,4 @@ main() {
578
581
exit 0
579
582
}
580
583
581
- main " $@ "
584
+ main " $@ "
0 commit comments