Repository navigation
Expand file tree
/
Copy paths.sh
More file actions
474 lines (394 loc) Β· 20.4 KB
/
Copy paths.sh
File metadata and controls
474 lines (394 loc) Β· 20.4 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
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
#!/bin/bash
# ==================== Aashish's Aztec Node Manager ====================
# Created by: Aashish π»
# ======================================================================
# 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/alpha-testnet"
unzip_files_aztec() {
ZIP_FILE=$(find "$HOME" -maxdepth 1 -type f -name "*.zip" | head -n 1)
if [ -n "$ZIP_FILE" ]; then
log "INFO" "π Found ZIP file: $ZIP_FILE, unzipping to $HOME ..."
# Ensure unzip is installed
if ! command -v unzip &>/dev/null; then
log "INFO" "π¦ 'unzip' not found, installing..."
if command -v apt &>/dev/null; then
sudo apt update && sudo apt install -y unzip
elif command -v yum &>/dev/null; then
sudo yum install -y unzip
elif command -v apk &>/dev/null; then
sudo apk add unzip
else
log "ERROR" "β Could not install 'unzip' (unknown package manager)."
return 1
fi
fi
# Unzip to home
unzip -o "$ZIP_FILE" -d "$HOME" >/dev/null 2>&1
if [ -f "$HOME/aztec.service" ]; then
log "INFO" "β
Extracted aztec.service to $HOME"
else
log "WARN" "β οΈ No aztec.service found in ZIP"
fi
ls -l "$HOME"
if [ -f "$HOME/aztec.service" ]; then
log "INFO" "β
Successfully extracted AZTEC files from $ZIP_FILE"
else
log "WARN" "β οΈ No expected aztec.service file found in $ZIP_FILE"
fi
else
log "WARN" "β οΈ No ZIP file found in $HOME, proceeding without unzipping"
fi
}
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 alpha-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}π Unzipping Aztec service files...${NC}"
unzip_files_aztec
echo -e "${YELLOW}π Collecting run parameters...${NC}"
# Define aztec.service file path
AZTEC_SERVICE_FILE="$HOME/aztec.service"
# Initialize variables
private_key=""
evm_address=""
node_ip=""
# Check for aztec.service file
if [ -f "$AZTEC_SERVICE_FILE" ]; then
log "INFO" "β
Found aztec.service file at $AZTEC_SERVICE_FILE, attempting to extract parameters..."
# Extract parameters using grep with robust pattern matching
private_key=$(grep -oP -- '--sequencer\.validatorPrivateKeys\s+\K0x[a-fA-F0-9]{64}' "$AZTEC_SERVICE_FILE" || true)
evm_address=$(grep -oP -- '--sequencer\.coinbase\s+\K0x[a-fA-F0-9]{40}' "$AZTEC_SERVICE_FILE" || true)
node_ip=$(grep -oP -- '--p2p\.p2pIp\s+\K[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' "$AZTEC_SERVICE_FILE" || true)
# Validate extracted parameters
if [[ -n "$private_key" && "$private_key" =~ ^0x[a-fA-F0-9]{64}$ ]] &&
[[ -n "$evm_address" && "$evm_address" =~ ^0x[a-fA-F0-9]{40}$ ]] &&
[[ -n "$node_ip" && "$node_ip" =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
log "INFO" "β
Successfully extracted parameters from aztec.service"
echo -e "${GREEN}π Extracted parameters:${NC}"
echo -e "${GREEN} EVM Address: $evm_address${NC}"
echo -e "${GREEN} Node IP: $node_ip${NC}"
else
log "WARN" "β οΈ Failed to extract valid parameters from aztec.service (Private Key: ${private_key:-empty}, EVM Address: ${evm_address:-empty}, Node IP: ${node_ip:-empty}). Prompting user..."
echo -e "${YELLOW}β οΈ Invalid or missing parameters in aztec.service. Please provide manually:${NC}"
private_key=""
evm_address=""
node_ip=""
fi
else
log "WARN" "β οΈ No aztec.service file found at $AZTEC_SERVICE_FILE. Prompting user for parameters..."
echo -e "${YELLOW}β οΈ aztec.service file not found. Please provide parameters manually:${NC}"
fi
# Prompt user if any parameter is missing or invalid
if [ -z "$private_key" ]; then
while true; do
read -p "πΉ EVM Private Key (with or without 0x, 64 hex chars): " private_key
[[ $private_key != 0x* ]] && private_key="0x$private_key"
if [[ "$private_key" =~ ^0x[a-fA-F0-9]{64}$ ]]; then
break
else
echo -e "${RED}β Invalid private key! Must be 64 hexadecimal characters (with 0x prefix). Try again.${NC}"
fi
done
fi
if [ -z "$evm_address" ]; then
while true; do
read -p "πΉ EVM Wallet Address (40 hex chars with 0x): " evm_address
if [[ "$evm_address" =~ ^0x[a-fA-F0-9]{40}$ ]]; then
break
else
echo -e "${RED}β Invalid EVM address! Must be 40 hexadecimal characters with 0x prefix. Try again.${NC}"
fi
done
fi
if [ -z "$node_ip" ]; then
node_ip=$(curl -s ifconfig.me 2>/dev/null || echo "")
if [[ ! "$node_ip" =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
while true; do
read -p "πΉ Node IP (IPv4 format, e.g., 192.168.1.1): " node_ip
if [[ "$node_ip" =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
break
else
echo -e "${RED}β Invalid IP address! Must be in IPv4 format (e.g., 192.168.1.1). Try again.${NC}"
fi
done
fi
fi
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 alpha-testnet \
--l1-rpc-urls http://38.102.86.215:8545 \
--l1-consensus-host-urls http://38.102.86.215:3500 \
--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/alpha-testnet/data" && sudo mkdir -p "$HOME/.aztec/alpha-testnet" && sudo wget https://files5.blacknodes.net/aztec/aztec-alpha-testnet.tar.lz4 -O /root/aztec-alpha-testnet.tar.lz4 && sudo lz4 -d /root/aztec-alpha-testnet.tar.lz4 | sudo tar x -C "$HOME/.aztec/alpha-testnet" && sudo rm /root/aztec-alpha-testnet.tar.lz4 && sudo chown -R "$USER":"$USER" "$HOME/.aztec/alpha-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/alpha-testnet/data/archiver
rm -rf ~/.aztec/alpha-testnet/data/world-tree
rm -rf ~/.bb-crs
ls ~/.aztec/alpha-testnet/data
docker-compose down
rm -rf ./data/archiver ./data/world_state
docker-compose up -d
}
update_node() {
echo -e "${YELLOW}π Updating Aztec Node...${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 alpha-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