-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·139 lines (112 loc) · 4.07 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·139 lines (112 loc) · 4.07 KB
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
#!/usr/bin/env bash
set -e
echo "Activating feature 'aztec-sandbox'"
# Get options
AUTO_START="${AUTOSTART:-true}"
IMPORT_TEST_ACCOUNTS="${IMPORTTESTACCOUNTS:-true}"
# Install dependencies
echo "Installing system dependencies..."
apt-get update && apt-get install -y \
curl \
jq \
git
# Install Node.js v22 if not present or version is too old
echo "Checking Node.js version..."
if ! command -v node &> /dev/null || [ $(node -v | cut -d'.' -f1 | sed 's/v//') -lt 20 ]; then
echo "Installing Node.js v22..."
curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
apt-get install -y nodejs
fi
# Set HOME to /workspaces persistently for all users and shells
echo "Setting HOME to /workspaces persistently..."
# Add to profile for login shells
cat > /etc/profile.d/01_set_home.sh << 'PROFILE_EOF'
# Set HOME to /workspaces for Aztec compatibility
export HOME="/workspaces"
# Add Aztec binaries to PATH
if [ -d "/workspaces/.aztec/bin" ]; then
export PATH="/workspaces/.aztec/bin:$PATH"
fi
PROFILE_EOF
chmod +x /etc/profile.d/01_set_home.sh
# Add to bashrc for non-login shells
cat >> /etc/bash.bashrc << 'BASHRC_EOF'
# Set HOME to /workspaces for Aztec compatibility
export HOME="/workspaces"
# Add Aztec binaries to PATH
if [ -d "/workspaces/.aztec/bin" ]; then
export PATH="/workspaces/.aztec/bin:$PATH"
fi
BASHRC_EOF
# Create Aztec installation script that runs with correct HOME
echo "Creating Aztec installation script..."
cat > /usr/local/share/install-aztec.sh << 'EOF'
#!/usr/bin/env bash
set -e
echo "Installing Aztec tools..."
# Set HOME to /workspaces and change to that directory
export HOME="/workspaces"
cd /workspaces
# Install Aztec using the official installation script (non-interactive mode)
echo "Running Aztec installation script..."
NON_INTERACTIVE=1 bash -c "curl -s https://install.aztec.network | bash -s"
# Create .bashrc if it doesn't exist and set up PXE_URL for Codespaces
if [ ! -f ~/.bashrc ]; then
touch ~/.bashrc
fi
if [ -n "\$CODESPACE_NAME" ] && ! grep -q "PXE_URL" ~/.bashrc; then
echo "export PXE_URL=https://\$CODESPACE_NAME-8080.preview.\$GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN" >> ~/.bashrc
fi
echo "Aztec tools installation complete!"
EOF
chmod +x /usr/local/share/install-aztec.sh
# Create startup script for postCreateCommand
echo "Creating startup script..."
cat > /usr/local/share/aztec-sandbox-start.sh << EOF
#!/usr/bin/env bash
set -e
# Set HOME to /workspaces
export HOME="/workspaces"
cd /workspaces
# Wait for Docker to be ready
echo "Waiting for Docker to be ready..."
for i in {1..30}; do
if docker info &> /dev/null; then
echo "Docker is ready!"
break
fi
if [ \$i -eq 30 ]; then
echo "Timeout waiting for Docker to start. Docker may not be available."
echo "You can manually install Aztec later by running: /usr/local/share/install-aztec.sh"
exit 0
fi
echo "Docker not ready yet, waiting... (\$i/30)"
sleep 2
done
# Add Aztec to PATH for this session
export PATH="/workspaces/.aztec/bin:\$PATH"
# Install Aztec tools if not already installed
if ! command -v aztec &> /dev/null; then
echo "Aztec tools not found. Installing..."
/usr/local/share/install-aztec.sh
# Re-export PATH after installation
export PATH="/workspaces/.aztec/bin:\$PATH"
fi
# Start the sandbox automatically if enabled
if [ "${AUTO_START}" = "true" ]; then
echo "Starting Aztec Sandbox in background..."
mkdir -p /workspaces/.aztec
nohup /workspaces/.aztec/bin/aztec start --sandbox > /workspaces/.aztec/aztec-sandbox.log 2>&1 &
echo \$! > /workspaces/.aztec/aztec-sandbox.pid
echo "Aztec Sandbox started in background!"
echo "Logs: /workspaces/.aztec/aztec-sandbox.log"
echo "PID: \$(cat /workspaces/.aztec/aztec-sandbox.pid)"
else
echo "Aztec setup complete!"
echo "The 'aztec' command is now available in your PATH."
echo "Run 'aztec start --sandbox' to start the sandbox manually."
fi
EOF
chmod +x /usr/local/share/aztec-sandbox-start.sh
echo "Aztec Sandbox feature installation complete!"
echo "Aztec tools will be installed when the container starts."