Repository navigation
Expand file tree
/
Copy pathtest.sh
More file actions
355 lines (297 loc) Β· 15.6 KB
/
Copy pathtest.sh
File metadata and controls
355 lines (297 loc) Β· 15.6 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
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
#!/bin/bash
# ==================== Aashish's Aztec Node Manager ====================
# Created by: Aashish π»
# Updated for Aztec 2.0.2: Changed --network alpha-testnet to --network testnet
# ======================================================================
# Color Codes
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
BOLD='\033[1m'
AZTEC_SERVICE="/etc/systemd/system/aztec.service"
AZTEC_DIR="$HOME/.aztec"
AZTEC_DATA_DIR="$AZTEC_DIR/testnet"
install_full() {
clear
echo -e "${YELLOW}${BOLD}π Starting Full Installation by Aashish...${NC}"
echo -e "${GREEN}π Updating system and installing dependencies...${NC}"
sudo apt-get update && sudo apt-get upgrade -y
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt update
sudo apt install -y nodejs
sudo apt install -y curl iptables build-essential git wget lz4 jq make gcc nano automake autoconf tmux htop nvme-cli libgbm1 pkg-config libssl-dev libleveldb-dev tar clang bsdmainutils ncdu unzip libleveldb-dev screen ufw apt-transport-https ca-certificates software-properties-common
echo -e "${BLUE}π³ Installing Docker...${NC}"
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo rm -rf /var/lib/apt/lists/* && sudo apt clean && sudo apt update --allow-insecure-repositories
sudo apt install -y docker-ce
sudo systemctl enable --now docker
sudo usermod -aG docker $USER
echo -e "${BLUE}π¦ Installing Docker Compose...${NC}"
sudo curl -L "https://github.com/docker/compose/releases/download/$(curl -s https://api.github.com/repos/docker/compose/releases/latest | jq -r .tag_name)/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
echo -e "${BLUE}π¦ Making sure Docker is running...${NC}"
sudo systemctl restart docker
sleep 3
echo -e "${YELLOW}βοΈ Installing Aztec CLI (inside docker group shell)...${NC}"
newgrp docker <<EONG
echo -e "${BLUE}π₯ Running Aztec Installer...${NC}"
bash <(curl -s https://install.aztec.network)
echo 'export PATH="\$HOME/.aztec/bin:\$PATH"' >> \$HOME/.bashrc
source \$HOME/.bashrc
export PATH="\$HOME/.aztec/bin:\$PATH"
if ! command -v aztec-up &> /dev/null; then
echo -e "${RED}β CLI install failed or aztec-up not found. Exiting.${NC}"
exit 1
fi
echo -e "${GREEN}π Running aztec-up testnet...${NC}"
aztec-up latest
EONG
echo 'export PATH="$HOME/.aztec/bin:$PATH"' >> ~/.bashrc
echo -e "${GREEN}π‘οΈ Configuring Firewall...${NC}"
sudo ufw allow 22
sudo ufw allow ssh
sudo ufw allow 40400
sudo ufw allow 8080
sudo ufw --force enable
echo -e "${YELLOW}π Collecting run parameters...${NC}"
read -p "πΉ Sepolia L1 RPC URL: " l1_rpc
read -p "πΉ Beacon Consensus RPC URL: " beacon_rpc
read -p "πΉ EVM Private Key (with or without 0x): " private_key
[[ $private_key != 0x* ]] && private_key="0x$private_key"
read -p "πΉ EVM Wallet Address: " evm_address
node_ip=$(curl -s ifconfig.me)
echo -e "${BLUE}π Creating systemd service...${NC}"
sudo tee $AZTEC_SERVICE > /dev/null <<EOF
[Unit]
Description=Aztec Node Service
After=network.target docker.service
[Service]
User=$USER
WorkingDirectory=$HOME
ExecStart=/bin/bash -c '$HOME/.aztec/bin/aztec start --node --archiver --sequencer \
--network testnet \
--l1-rpc-urls $l1_rpc \
--l1-consensus-host-urls $beacon_rpc \
--sequencer.validatorPrivateKeys $private_key \
--sequencer.coinbase $evm_address \
--p2p.p2pIp $node_ip'
Restart=always
RestartSec=5
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reexec
sudo systemctl daemon-reload
sudo systemctl enable aztec
sudo systemctl start aztec
echo -e "${GREEN}β
Installation complete!${NC}"
echo -e "${YELLOW}β‘ To check status: systemctl status aztec"
echo -e "${BLUE}π View logs live: journalctl -fu aztec${NC}"
fix_failed_fetch
sudo rm -rf "$HOME/.aztec/testnet/data" && sudo mkdir -p "$HOME/.aztec/testnet" && sudo wget https://files5.blacknodes.net/aztec/aztec-testnet.tar.lz4 -O /root/aztec-testnet.tar.lz4 && sudo lz4 -d /root/aztec-testnet.tar.lz4 | sudo tar x -C "$HOME/.aztec/testnet" && sudo rm /root/aztec-testnet.tar.lz4 && sudo chown -R "$USER":"$USER" "$HOME/.aztec/testnet" && sudo systemctl restart aztec
}
view_logs() {
echo -e "${YELLOW}π Showing last 100 Aztec logs...${NC}"
journalctl -u aztec -n 100 --no-pager --output cat
echo -e "\n${YELLOW}π‘ Streaming live logs... Press Ctrl+C to stop.${NC}\n"
journalctl -u aztec -f --no-pager --output cat
}
reconfigure() {
echo -e "${YELLOW}π§ Reconfiguring RPC URLs...${NC}"
if [ ! -f "$AZTEC_SERVICE" ]; then
echo -e "${RED}β Service file not found at $AZTEC_SERVICE${NC}"
return
fi
echo -e "${BLUE}π Reading current RPCs from service file...${NC}"
old_l1_rpc=$(grep -oP '(?<=--l1-rpc-urls\s)[^\s\\]+' "$AZTEC_SERVICE")
old_beacon_rpc=$(grep -oP '(?<=--l1-consensus-host-urls\s)[^\s\\]+' "$AZTEC_SERVICE")
echo -e "${GREEN}π Current RPCs:"
echo -e " π°οΈ Sepolia L1 RPC : ${YELLOW}$old_l1_rpc${NC}"
echo -e " π Beacon Consensus RPC : ${YELLOW}$old_beacon_rpc${NC}"
echo ""
read -p "πΉ Enter NEW Sepolia L1 RPC: " new_l1_rpc
read -p "πΉ Enter NEW Beacon RPC: " new_beacon_rpc
echo -e "\n${BLUE}β Stopping Aztec service...${NC}"
sudo systemctl stop aztec
echo -e "${YELLOW}π οΈ Replacing values in service file...${NC}"
sudo perl -i -pe "s|--l1-rpc-urls\s+\S+|--l1-rpc-urls $new_l1_rpc|g" "$AZTEC_SERVICE"
sudo perl -i -pe "s|--l1-consensus-host-urls\s+\S+|--l1-consensus-host-urls $new_beacon_rpc|g" "$AZTEC_SERVICE"
echo -e "${BLUE}π Reloading systemd and restarting service...${NC}"
sudo systemctl daemon-reload
sudo systemctl start aztec
echo -e "${GREEN}β
RPCs updated successfully!"
echo -e " π New Sepolia RPC : ${YELLOW}$new_l1_rpc${NC}"
echo -e " π New Beacon RPC : ${YELLOW}$new_beacon_rpc${NC}"
}
uninstall() {
echo -e "${YELLOW}π§Ή Uninstalling Aztec Node...${NC}"
if sudo systemctl is-active --quiet aztec; then
sudo systemctl stop aztec
fi
sudo systemctl disable aztec
sudo rm -f "$AZTEC_SERVICE"
sudo systemctl daemon-reload
sudo rm -rf "$AZTEC_DIR"
echo -e "${GREEN}β
Uninstallation complete.${NC}"
}
show_peer_id() {
clear
peerid=$(sudo docker logs $(docker ps -q --filter "name=aztec" | head -1) 2>&1 | \
grep -m 1 -ai 'DiscV5 service started' | grep -o '"peerId":"[^"]*"' | cut -d'"' -f4)
if [ -z "$peerid" ]; then
container_id=$(sudo docker ps --filter "ancestor=$(sudo docker images --format '{{.Repository}}:{{.Tag}}' | grep aztec | head -1)" -q | head -1)
if [ ! -z "$container_id" ]; then
peerid=$(sudo docker logs $container_id 2>&1 | \
grep -m 1 -ai 'DiscV5 service started' | grep -o '"peerId":"[^"]*"' | cut -d'"' -f4)
fi
fi
if [ -z "$peerid" ]; then
peerid=$(sudo docker logs $(docker ps -q --filter "name=aztec" | head -1) 2>&1 | \
grep -m 1 -ai '"peerId"' | grep -o '"peerId":"[^"]*"' | cut -d'"' -f4)
fi
label=" β PeerID"
peerline="β $peerid"
width=${#peerline}
[ ${#label} -gt $width ] && width=${#label}
line=$(printf '=%.0s' $(seq 1 $width))
if [ -n "$peerid" ]; then
echo "$line"
echo -e "$label"
echo -e "\e[1;32m$peerline\e[0m"
echo "$line"
echo
echo -e "\e[1;34mFetching stats from Nethermind Aztec Explorer...\e[0m"
response=$(curl -s "https://aztec.nethermind.io/api/peers?page_size=30000&latest=true")
stats=$(echo "$response" | jq -r --arg peerid "$peerid" '
.peers[] | select(.id == $peerid) |
[
.last_seen,
.created_at,
.multi_addresses[0].ip_info[0].country_name,
(.multi_addresses[0].ip_info[0].latitude | tostring),
(.multi_addresses[0].ip_info[0].longitude | tostring)
] | @tsv
')
if [ -n "$stats" ]; then
IFS=$'\t' read -r last first country lat lon <<<"$stats"
last_local=$(date -d "$last" "+%Y-%m-%d - %H:%M" 2>/dev/null || echo "$last")
first_local=$(date -d "$first" "+%Y-%m-%d - %H:%M" 2>/dev/null || echo "$first")
printf "%-12s: %s\n" "Last Seen" "$last_local"
printf "%-12s: %s\n" "First Seen" "$first_local"
printf "%-12s: %s\n" "Country" "$country"
printf "%-12s: %s\n" "Latitude" "$lat"
printf "%-12s: %s\n" "Longitude" "$lon"
else
echo -e "\e[1;31mNo stats found for this PeerID on Nethermind Aztec Explorer.\e[0m"
fi
else
echo -e "\e[1;31mβ No Aztec PeerID found.${NC}"
fi
echo -e "\n${YELLOW}π Press Enter to return to menu...${NC}"
read
}
fix_failed_fetch() {
rm -rf ~/.aztec/testnet/data/archiver
rm -rf ~/.aztec/testnet/data/world-tree
rm -rf ~/.bb-crs
ls ~/.aztec/testnet/data
docker-compose down
rm -rf ./data/archiver ./data/world_state
docker-compose up -d
}
update_node() {
echo -e "${YELLOW}π Updating Aztec Node to 2.0.2...${NC}"
sudo systemctl stop aztec
export PATH="$PATH:$HOME/.aztec/bin"
aztec-up latest
sudo rm -rf /tmp/aztec-world-state-*
sudo systemctl start aztec
echo -e "${GREEN}β
Node updated & restarted!${NC}"
}
generate_start_command() {
echo -e "${YELLOW}βοΈ Generating aztec start command from systemd service...${NC}"
SERVICE_FILE="/etc/systemd/system/aztec.service"
if [ ! -f "$SERVICE_FILE" ]; then
echo -e "${RED}β Systemd service not found at $SERVICE_FILE. Run install first.${NC}"
return
fi
L1_RPC=$(grep -oP '(?<=--l1-rpc-urls )\S+' "$SERVICE_FILE")
BEACON_RPC=$(grep -oP '(?<=--l1-consensus-host-urls )\S+' "$SERVICE_FILE")
PRIVATE_KEY=$(grep -oP '(?<=--sequencer.validatorPrivateKeys )\S+' "$SERVICE_FILE")
EVM_ADDRESS=$(grep -oP '(?<=--sequencer.coinbase )\S+' "$SERVICE_FILE")
PUBLIC_IP=$(grep -oP '(?<=--p2p.p2pIp )\S+' "$SERVICE_FILE")
echo -e "${GREEN}π’ Use the following command to run manually:${NC}"
echo ""
echo -e "${BLUE}aztec start --node --archiver --sequencer \\"
echo " --network testnet \\"
echo " --l1-rpc-urls $L1_RPC \\"
echo " --l1-consensus-host-urls $BEACON_RPC \\"
echo " --sequencer.validatorPrivateKeys $PRIVATE_KEY \\"
echo " --sequencer.coinbase $EVM_ADDRESS \\"
echo -e " --p2p.p2pIp $PUBLIC_IP${NC}"
echo ""
}
run_node() {
clear
show_header
echo -e "${BLUE}π Starting Aztec Node in Auto-Restart Mode...${NC}"
sudo rm -rf /tmp/aztec-world-state-*
sudo systemctl daemon-reload
sudo systemctl restart aztec
if sudo systemctl is-active --quiet aztec; then
echo -e "${GREEN}β
Aztec Node started successfully with auto-restart enabled.${NC}"
echo -e "${YELLOW}π View logs: journalctl -fu aztec${NC}"
else
echo -e "${RED}β Failed to start the Aztec Node. Check your configuration.${NC}"
fi
}
show_header() {
clear
echo -e "${BLUE}${BOLD}"
echo "βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"
echo "β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β"
echo "β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β"
echo "β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β"
echo "β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β"
echo "β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β"
echo "β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β"
echo "βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"
echo -e "${YELLOW} π Aztec Node Manager by Aashish π${NC}"
echo -e "${YELLOW} GitHub: https://github.com/HustleAirdrops${NC}"
echo -e "${YELLOW} Telegram: https://t.me/Hustle_Airdrops${NC}"
echo -e "${GREEN}===============================================================================${NC}"
}
# ===================== MENU ==========================
while true; do
clear
show_header
echo -e "${BLUE}${BOLD}================ AZTEC NODE MANAGER BY Aashish π =================${NC}"
echo -e " 1οΈβ£ Full Install"
echo -e " 2οΈβ£ Run Node"
echo -e " 3οΈβ£ View Logs"
echo -e " 4οΈβ£ Reconfigure RPC"
echo -e " 5οΈβ£ Uninstall Node"
echo -e " 6οΈβ£ Show Peer ID"
echo -e " 7οΈβ£ Update Node"
echo -e " 8οΈβ£ Generate Start Command"
echo -e " 9οΈβ£ Exit"
echo -e "${BLUE}============================================================================${NC}"
read -p "π Choose option (1-7): " choice
case $choice in
1) install_full ;;
2) run_node ;;
3) view_logs ;;
4) reconfigure ;;
5) uninstall ;;
6) show_peer_id ;;
7) update_node ;;
8) generate_start_command ;;
9) echo -e "${GREEN}π Exiting... Stay decentralized, Aashish!${NC}"; break ;;
*) echo -e "${RED}β Invalid option. Try again.${NC}"; sleep 1 ;;
esac
read -p "π Press Enter to return to menu..."
done