-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathinstall.sh
executable file
·110 lines (91 loc) · 2.29 KB
/
install.sh
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
#!/usr/bin/env bash
set -euo pipefail
os=$(uname -ms)
release="https://github.com/algorandfoundation/nodekit/releases/latest/download"
Red=''
Green=''
Yellow=''
Blue=''
Opaque=''
Bold_White=''
Bold_Green=''
Reset=''
if [[ -t 1 ]]; then
Reset='\033[0m'
Red='\033[0;31m'
Green='\033[0;32m'
Yellow='\033[0;33m'
Blue='\033[0;34m'
Bold_Green='\033[1;32m'
Bold_White='\033[1m'
Opaque='\033[0;2m'
fi
success() {
echo -e "${Green}$@ ${Reset}"
}
info() {
echo -e "${Opaque}$@ ${Reset}"
}
warn() {
echo -e "${Yellow}WARN${Reset}: ${Opaque}$@ ${Reset}"
}
error() {
echo -e "${Red}ERROR${Reset}:" "${Yellow}" "$@" "${Reset}" >&2
exit 1
}
prompt_default_no() {
echo -n "$1 (y/N) "
read -rn1 prompt_response < /dev/tty
echo ""
if [[ "$prompt_response" =~ "y" ]]; then
return 0
fi
return 1
}
if [ -f nodekit ]; then
warn "A nodekit file already exists in the current directory."
if prompt_default_no "Do you want to upgrade it to the latest nodekit?"; then
rm nodekit
else
info "Not upgrading nodekit.\n\nYou can run nodekit with:\n\n./nodekit\n\nOr start the installer with:\n\n./nodekit bootstrap"
exit 0
fi
fi
if [[ ${OS:-} = Windows_NT ]]; then
error "Unsupported platform. Windows is supported only via WSL.\n\nFor WSL installation instructions, see here: https://learn.microsoft.com/en-us/windows/wsl/install"
fi
trap "warn SIGINT received." int
trap "info Exiting the installation" exit
case $os in
'Darwin x86_64')
platform=amd64-darwin
;;
'Darwin arm64')
platform=arm64-darwin
;;
'Linux aarch64' | 'Linux arm64')
platform=arm64-linux
;;
'Linux x86_64' | *)
platform=amd64-linux
;;
esac
target="nodekit-$platform"
url="$release/$target"
echo -e "${Opaque}Downloading:${Reset}${Bold_White} $target ${Reset}from $url"
errormessage="Failed to download ${target} from ${release} ${url}"
if curl --version > /dev/null 2>&1; then
curl --fail --location --progress-bar --output nodekit "$url" || error "$errormessage"
else
wget -qO nodekit --show-progress "$url" || error "$errormessage"
fi
chmod +x nodekit
trap - int
trap - exit
success "Downloaded: ${Bold_Green}${target} as nodekit 🎉${Reset}"
info "Explore all nodekit options with:"
echo "./nodekit --help"
echo ""
info "Starting nodekit bootstrap"
echo "./nodekit bootstrap"
./nodekit bootstrap