Elffuss BraidHub

kikocis/llama-stack public

main · 731 B · executableRawPermalink
1# Copyright (c) Meta Platforms, Inc. and affiliates.
2# All rights reserved.
3#
4# This source code is licensed under the terms described in the LICENSE file in
5# the root directory of this source tree.
6
7cleanup() {
8 envname="$1"
9
10 set +x
11 echo "Cleaning up..."
12 conda deactivate
13 conda env remove --name $envname -y
14}
15
16handle_int() {
17 if [ -n $ENVNAME ]; then
18 cleanup $ENVNAME
19 fi
20 exit 1
21}
22
23handle_exit() {
24 if [ $? -ne 0 ]; then
25 echo -e "\033[1;31mABORTING.\033[0m"
26 if [ -n $ENVNAME ]; then
27 cleanup $ENVNAME
28 fi
29 fi
30}
31
32setup_cleanup_handlers() {
33 trap handle_int INT
34 trap handle_exit EXIT
35
36 __conda_setup="$('conda' 'shell.bash' 'hook' 2>/dev/null)"
37 eval "$__conda_setup"
38
39 conda deactivate
40}