-
Notifications
You must be signed in to change notification settings - Fork 309
/
Copy pathinstall
executable file
·72 lines (58 loc) · 1.85 KB
/
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
#!/usr/bin/env bash
set -e
# Colors and symbols
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
NC='\033[0m'
SUCCESS="✓"
ERROR="✗"
BB_DIR="${HOME}/.bb"
INSTALL_PATH="${BB_DIR}/bbup"
BBUP_URL="https://raw.githubusercontent.com/AztecProtocol/aztec-packages/master/barretenberg/bbup/bbup"
# Create .bb directory if it doesn't exist
mkdir -p "$BB_DIR"
# Download bbup
printf "${BLUE}Downloading bbup...${NC}\n"
if command -v curl &> /dev/null; then
curl -fsSL "$BBUP_URL" -o "$INSTALL_PATH"
elif command -v wget &> /dev/null; then
wget -q "$BBUP_URL" -O "$INSTALL_PATH"
else
printf "${RED}${ERROR} Neither curl nor wget found. Please install either curl or wget.${NC}\n"
exit 1
fi
if [ ! -f "$INSTALL_PATH" ]; then
printf "${RED}${ERROR} Failed to download bbup${NC}\n"
exit 1
fi
chmod 755 "$INSTALL_PATH"
# Add to shell config files if not already present
PATH_ENTRY="export PATH=\"\${HOME}/.bb:\${PATH}\""
FISH_PATH_ENTRY="set -gx PATH \${HOME}/.bb \$PATH"
add_to_config() {
local config_file="$1"
local entry="$2"
if [ -f "$config_file" ] && ! grep -q "/.bb:" "$config_file"; then
echo "$entry" >> "$config_file"
return 0
fi
return 1
}
SHELL_UPDATED=false
if add_to_config "${HOME}/.bashrc" "$PATH_ENTRY"; then
SHELL_UPDATED=true
fi
if add_to_config "${HOME}/.zshrc" "$PATH_ENTRY"; then
SHELL_UPDATED=true
fi
if [ -f "${HOME}/.config/fish/config.fish" ] && ! grep -q "/.bb " "${HOME}/.config/fish/config.fish"; then
echo "$FISH_PATH_ENTRY" >> "${HOME}/.config/fish/config.fish"
SHELL_UPDATED=true
fi
printf "${GREEN}${SUCCESS} Successfully installed bbup${NC}\n"
if [ "$SHELL_UPDATED" = true ]; then
printf "${BLUE}Please run 'source ~/.bashrc' or restart your terminal to use bbup${NC}\n"
else
printf "${BLUE}Your PATH already includes ~/.bb - you can run 'bbup' from anywhere${NC}\n"
fi