-
Notifications
You must be signed in to change notification settings - Fork 234
/
aztec-install
executable file
·179 lines (154 loc) · 5.94 KB
/
aztec-install
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
#!/usr/bin/env bash
set -euo pipefail
# Colors
g="\033[32m" # Green
y="\033[33m" # Yellow
b="\033[34m" # Blue
p="\033[35m" # Purple
r="\033[0m" # Reset
bold="\033[1m"
# Function to replace characters and add color
function print_colored() {
local b=$'\033[34m' # Blue
local y=$'\033[33m' # Yellow
local r=$'\033[0m' # Reset
echo "$1" | sed -E "s/(█+)/${b}\1${y}/g"
}
function title() {
echo
print_colored " █████╗ ███████╗████████╗███████╗ ██████╗"
print_colored "██╔══██╗╚══███╔╝╚══██╔══╝██╔════╝██╔════╝"
print_colored "███████║ ███╔╝ ██║ █████╗ ██║"
print_colored "██╔══██║ ███╔╝ ██║ ██╔══╝ ██║"
print_colored "██║ ██║███████╗ ██║ ███████╗╚██████╗"
print_colored "╚═╝ ╚═╝╚══════╝ ╚═╝ ╚══════╝ ╚═════╝"
echo -e "${r}"
echo -e "Welcome to the ${bold}${b}Aztec${r} installer! Your journey into blockchain privacy begins... ${bold}${p}now${r}."
echo -e "We provide a docker image that works on any modern system (specifically: x64 or ARM64)."
echo -e "Please ensure docker is installed for your platform: https://docs.docker.com/engine/install"
echo
if [ "$(uname -s)" == "Darwin" ]; then
echo -e "${y}WARNING: For best performance we recommend adjusting your default docker settings:"
echo -e " - Under general, enable VirtioFS."
echo -e " - Under resources, set CPUs to ~80% your maximum."
echo -e " - Under resources, set Memory to ~80% your maximum."
echo -e "You may receive a warning about your home directory being mounted into a container."
echo -e "This is requested so we can read and write project files, that is all."
echo -e "${r}"
fi
echo -e "This will install the following scripts and update your PATH if necessary:"
echo -e " ${bold}${g}aztec${r} - a collection of tools to launch subsystems and interact with the aztec network."
echo -e " ${bold}${g}aztec-nargo${r} - aztec's build of nargo, the noir compiler toolchain."
echo -e " ${bold}${g}aztec-up${r} - a tool to upgrade the aztec toolchain to the latest, or specific versions."
echo -e " ${bold}${g}aztec-wallet${r} - our minimalistic CLI wallet"
echo
read -p "Do you wish to continue? (y/n)" -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 0
fi
}
function info {
echo -e "${g}$1${r}"
}
function warn {
echo -e "${y}$1${r}"
}
AZTEC_PATH=$HOME/.aztec
BIN_PATH=${BIN_PATH:-$AZTEC_PATH/bin}
# Define version if specified, otherwise set to "latest".
VERSION=${VERSION:-"latest"}
INSTALL_HOST=install.aztec.network.s3-website.eu-west-2.amazonaws.com
[ -z "${NON_INTERACTIVE:-}" ] && title
# Check if Docker is available.
if ! command -v docker &>/dev/null; then
warn "Docker is not installed. Please install Docker and try again."
exit 1
fi
# Check if Docker is running.
if ! docker info &>/dev/null; then
warn "Docker is not running. Please start Docker and try again."
exit 1
fi
if ! docker compose &>/dev/null && ! command -v docker-compose &>/dev/null; then
warn "WARNING: 'docker compose' not supported and docker-compose not found."
warn "Continuing installation, but aztec-sandbox will not work."
fi
# Create a "hidden" `$HOME/.aztec` dir, so as not to clutter the user's cwd.
mkdir -p $AZTEC_PATH
mkdir -p $BIN_PATH
# Download containers from dockerhub. Tag them as latest.
function pull_container {
docker pull aztecprotocol/$1:$VERSION
# If not latest, retag to be latest so it runs from scripts.
if [ $VERSION != "latest" ]; then
docker tag aztecprotocol/$1:$VERSION aztecprotocol/$1:latest
fi
}
export DOCKER_CLI_HINTS=false
if [ -z "${SKIP_PULL:-}" ]; then
info "Pulling aztec version $VERSION..."
pull_container aztec-nargo
pull_container aztec
pull_container cli-wallet
fi
# Download the Docker Compose file. Used by aztec.
curl -fsSL http://$INSTALL_HOST/docker-compose.sandbox.yml -o $AZTEC_PATH/docker-compose.sandbox.yml
curl -fsSL http://$INSTALL_HOST/docker-compose.test.yml -o $AZTEC_PATH/docker-compose.test.yml
function install_bin {
local install_url
if [ "$VERSION" != "latest" ]; then
install_url="http://$INSTALL_HOST/$VERSION/$1"
else
install_url="http://$INSTALL_HOST/$1"
fi
curl -fsSL "$install_url" -o "$BIN_PATH/$1"
chmod +x "$BIN_PATH/$1"
echo "Installed: $BIN_PATH/$1"
}
info "Installing scripts in $BIN_PATH..."
rm -f $BIN_PATH/aztec*
install_bin .aztec-run
install_bin aztec
install_bin aztec-up
install_bin aztec-nargo
install_bin aztec-wallet
function update_path_env_var {
TARGET_DIR="${1}"
# Check if the target directory is in the user's PATH.
if [[ ":$PATH:" != *":$TARGET_DIR:"* ]]; then
# Determine the user's shell.
SHELL_PROFILE=""
case $SHELL in
*/bash)
SHELL_PROFILE="$HOME/.bashrc"
;;
*/zsh)
SHELL_PROFILE="$HOME/.zshrc"
;;
# Add other shells as needed
*)
echo "Unsupported shell: $SHELL"
return
;;
esac
if [ -z "${NON_INTERACTIVE:-}" ]; then
# Inform the user about the change and ask for confirmation
warn "The directory $TARGET_DIR is not in your PATH."
read -p "Add it to $SHELL_PROFILE to make the aztec binaries accessible? (y/n)" -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
warn "Skipped updating PATH. You might need to add $TARGET_DIR to your PATH manually to use the binary."
return
fi
fi
# Add the target directory to the user's PATH in their profile.
echo "export PATH=\"\$PATH:$TARGET_DIR\"" >>"$SHELL_PROFILE"
if [ -z "${NON_INTERACTIVE:-}" ]; then
info "Done! Starting fresh shell..."
$SHELL
fi
fi
}
update_path_env_var $BIN_PATH
info "Done!"