/
setup_pulse_node.sh
704 lines (603 loc) · 24.7 KB
/
setup_pulse_node.sh
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
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
#!/bin/bash
# v.1.1
#Icosa, Hex, Hedron,
#Three shapes in symmetry dance,
#Nature's art is shown.
# By tdslaine aka Peter L Dipslayer TG: @dipslayer369 Twitter: @dipslayer
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m' # No Color
start_dir=$(pwd)
script_dir=$(dirname "$0")
source "$script_dir/functions.sh"
clear
echo " Pulse Node/Validator/Monitoring Setup by Dipslayer"
echo "
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓ ▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓ ▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓ ▓▓▓▓▓ ▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓
▓▓ ▓▓▓ ▓▓▓ ▓▓
▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓ ▓▓▓▓ ▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓ ▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
░▓▓▓▓▓▓▓▓▓▓▓▓▓▒ ▓▓▓▓▓▓ ▓▒ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
"
echo "donations: 0xCB00d822323B6f38d13A1f951d7e31D9dfDED4AA "
echo "Please press Enter to continue..."
read -p ""
clear
echo -e "\033[1;33m"
echo "┌─────────────────────────────────────────────────────────┐"
echo "│ DISCLAIMER! Please read the following carefully! │"
echo "├─────────────────────────────────────────────────────────┤"
echo "│ This script automates the installation and setup │"
echo "│ process for a PulseChain Node/Validator. │"
echo "│ │"
echo "│ By using this script, you acknowledge that you |"
echo "| understand the potential risks involved and accept │"
echo "│ full responsibility for the security and custody │"
echo "│ of your own assets. │"
echo "│ │"
echo "│ It is strongly recommended that you review the script │"
echo "│ and understand its workings before proceeding. │"
echo "└─────────────────────────────────────────────────────────┘"
echo -e "\033[0m"
read -p "Do you wish to continue? (y/n): " CONFIRM
if [[ "$CONFIRM" != "y" && "$CONFIRM" != "Y" ]]; then
echo "Aborting."
exit 1
fi
clear
echo -e "\033[1;33m"
echo -e "+============================================+"
echo -e "| ☆ Shoutouts ☆ |"
echo -e "+============================================+"
echo -e "| Sincere thanks to @rainbowtopgun for his |"
echo -e "| invaluable feedback & steadfast support |"
echo -e "| during the development of these scripts. |"
echo -e "| |"
echo -e "| Special thanks to raskitoma for forking |"
echo -e "| the Yoldark_ETH_staking_dashboard. GitHub: |"
echo -e "| https://github.com/raskitoma/pulse- |"
echo -e "| staking-dashboard |"
echo -e "| |"
echo -e "| Gratitude to the Pulse-dev Telegram for |"
echo -e "| their valuable info & collective wisdom. |"
echo -e "| |"
echo -e "| Big thanks to all who contributed with |"
echo -e "| constructive feedback to improve my work! |"
echo -e "+--------------------------------------------+"
echo -e "\033[0m"
press_enter_to_continue
clear
echo "+=================+"
echo "| Choose Network: |"
echo "+=================+"
echo "| 1) Mainnet |"
echo "| |"
echo "| 2) Testnet |"
echo "+-----------------+"
echo ""
read -p "Enter your Network choice (1 or 2): " -r choice
case $choice in
1)
set_network_variables "mainnet"
;;
2)
set_network_variables "testnet"
;;
*)
echo "Invalid choice. Exiting."
exit 1
;;
esac
#enabling ntp for timesyncronization
clear
echo ""
echo "We are going to setup the timezone first, it is important to be synced in time for the Chain to work correctly"
sleep 2
echo "enabling ntp for timesync"
sudo timedatectl set-ntp true
echo ""
echo "enabled ntp timesync"
echo ""
echo -e "${RED}Please choose your CORRECT timezone at the following screen${NC}"
echo ""
echo "Press Enter to continue..."
read -p ""
sudo dpkg-reconfigure tzdata
echo "timezone set"
sleep 1
echo ""
clear
echo "+=============================================================+"
echo "| Please choose a Execution-Client: |"
echo "+=============================================================+"
echo "| 1) Geth (full node, faster sync time.) |"
echo "| Recommended for normal usage, stores all transactions |"
echo "| and the most recent states |"
echo "+-------------------------------------------------------------+"
echo "| 2) Erigon (archive node, longer sync time.) |"
echo "| Recommended for developers and advanced users, |"
echo "| stores the entire history of the Ethereum blockchain, |"
echo "| including all historical states |"
echo "+-------------------------------------------------------------+"
echo "| 3) Erigon (pruned to keep last 2000 blocks) |"
echo "| WARNING !: Still testing if this is beneficial over geth |"
echo "| so use with caution. No guarantee this will work. |"
echo "| It will only keep the last 2000 blocks |"
echo "+-------------------------------------------------------------+"
echo ""
while true; do
read -e -p "Enter your Client choice (1, 2, or 3): " ETH_CLIENT_CHOICE
case $ETH_CLIENT_CHOICE in
1)
ETH_CLIENT="geth"
break
;;
2)
ETH_CLIENT="erigon"
break
;;
3)
ETH_CLIENT="erigon"
break
;;
*)
echo "Invalid choice. Please enter a valid choice (1, 2, or 3)."
;;
esac
done
while true; do
echo ""
echo ""
echo -e "+===================================+"
echo -e "| Choose your Consensus client: |"
echo -e "+===================================+"
echo -e "| 1) Lighthouse |"
echo -e "| 2) Prysm |"
echo -e "+-----------------------------------+"
echo ""
read -p "Enter your Client choice (1 or 2): " CONSENSUS_CLIENT_CHOICE
case $CONSENSUS_CLIENT_CHOICE in
1)
CONSENSUS_CLIENT="lighthouse"
break
;;
2)
CONSENSUS_CLIENT="prysm"
break
;;
*)
echo "Invalid choice. Please enter a valid choice (1 or 2)."
;;
esac
done
# Enable tab autocompletion for the read command if line editing is enabled
if [ -n "$BASH_VERSION" ] && [ -n "$PS1" ] && [ -t 0 ]; then
bind '"\t":menu-complete'
fi
clear
# Get custom path for the blockchain folder
echo ""
echo -e "+===============================================================+"
echo -e "| Node/Clients and all required DataFolders/files will be |"
echo -e "| installed under the specified path. It includes databases, |"
echo -e "| keystore, and various startup/helper scripts. |"
echo -e "+===============================================================+"
echo ""
read -e -p 'Enter target path (Press Enter for default: /blockchain): ' CUSTOM_PATH
echo ""
# Set the default value for custom path if the user enters nothing
if [ -z "$CUSTOM_PATH" ]; then
CUSTOM_PATH="/blockchain"
fi
# Docker run commands for Ethereum clients
GETH_CMD="sudo -u geth docker run -dt --restart=always \\
--network=host \\
--name execution \\
-v ${CUSTOM_PATH}:/blockchain \\
registry.gitlab.com/pulsechaincom/go-pulse:latest \\
--${EXECUTION_NETWORK_FLAG} \\
--authrpc.jwtsecret=/blockchain/jwt.hex \\
--datadir=/blockchain/execution/geth \\
--http \\
--ws \\
--state.scheme=path \\
--gpo.ignoreprice 1 \\
--metrics \\
--pprof \\
--ws.api web3,eth,txpool,net,engine \\
--http.api web3,eth,txpool,net,engine,admin,debug "
ERIGON_CMD="sudo -u erigon docker run -dt --restart=always \\
--network=host \\
--name execution \\
-v ${CUSTOM_PATH}:/blockchain \\
registry.gitlab.com/pulsechaincom/erigon-pulse:latest \\
--chain=${EXECUTION_NETWORK_FLAG} \\
--authrpc.jwtsecret=/blockchain/jwt.hex \\
--datadir=/blockchain/execution/erigon \\
--http \\
--http.api="eth,erigon,web3,net,debug,trace,txpool" \\
--metrics \\
--pprof \\
--externalcl "
ERIGON_CMD2="sudo -u erigon docker run -dt --restart=always \\
--network=host \\
--name execution \\
-v ${CUSTOM_PATH}:/blockchain \\
registry.gitlab.com/pulsechaincom/erigon-pulse:latest \\
--chain=${EXECUTION_NETWORK_FLAG} \\
--authrpc.jwtsecret=/blockchain/jwt.hex \\
--datadir=/blockchain/execution/erigon \\
--externalcl \\
--http \\
--http.api="eth,erigon,web3,net,debug,trace,txpool" \\
--metrics \\
--pprof \\
--prune.h.older=2000 \\
--prune.t.older=2000 \\
--prune.c.older=2000 \\
--prune=r "
# Docker run commands for Consensus clients
PRYSM_CMD="# Retrieve the current IP address
#IP=\$(curl -s ipinfo.io/ip)
#if [ -z \"\$IP\" ]; then
# echo \"Failed to retrieve IP address. Exiting...\"
# echo ""
#fi
sudo -u prysm docker run -dt --restart=always \\
--network=host \\
--name beacon \\
-v ${CUSTOM_PATH}:/blockchain \\
registry.gitlab.com/pulsechaincom/prysm-pulse/beacon-chain:latest \\
--${PRYSM_NETWORK_FLAG} \\
--jwt-secret=/blockchain/jwt.hex \\
--datadir=/blockchain/consensus/prysm \\
--checkpoint-sync-url=${CHECKPOINT} \\
--min-sync-peers 1 \\
--genesis-beacon-api-url=${CHECKPOINT} \\
#--p2p-host-ip \$IP
"
LIGHTHOUSE_CMD="sudo -u lighthouse docker run -dt --restart=always \\
--network=host \\
--name beacon \\
-v ${CUSTOM_PATH}:/blockchain \\
registry.gitlab.com/pulsechaincom/lighthouse-pulse:latest \\
lighthouse bn \\
--network=${LIGHTHOUSE_NETWORK_FLAG} \\
--execution-jwt=/blockchain/jwt.hex \\
--datadir=/blockchain/consensus/lighthouse \\
--execution-endpoint=http://localhost:8551 \\
--checkpoint-sync-url=${CHECKPOINT} \\
--staking \\
--metrics \\
--validator-monitor-auto \\
--http "
# Use the variables in both single and separate script modes
clear
# check for any snap Version of docker installed and remove it (because it enables images to be mounted writable only in home folders)
if snap list | grep -q '^docker '; then
echo "Docker snap package found. Removing..."
sudo snap remove docker
else
echo "No Docker snap package found."
fi
# Add the deadsnakes PPA repository to install the latest Python version
echo -e "${GREEN}Adding deadsnakes PPA to get the latest Python Version${NC}"
sudo add-apt-repository ppa:deadsnakes/ppa -y
echo ""
echo -e "${GREEN}Installing Dependencies...${NC}"
sudo apt-get update -y
sudo apt-get upgrade -y
echo ""
# Perform distribution upgrade and remove unused packages
sudo apt-get dist-upgrade -y
sudo apt autoremove -y
echo ""
# Install required packages
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
htop \
gnupg \
git \
ufw \
tmux \
dialog \
rhash \
openssl \
wmctrl \
jq \
lsb-release \
dbus-x11 \
python3.10 python3.10-venv python3.10-dev python3-pip
echo ""
# Downloading Docker
echo -e "${GREEN}Adding Docker PPA and 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
echo ""
sudo apt-get update -y
echo ""
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose
echo ""
clear
echo -e "${GREEN}Starting and enabling docker service${NC}"
sudo systemctl start docker
sudo systemctl enable docker
# Adding Main user to the Docker group
add_user_to_docker_group
echo -e "${GREEN}Creating ${CUSTOM_PATH} Main-Folder${NC}"
sudo mkdir "${CUSTOM_PATH}"
echo ""
echo -e "${GREEN}Generating jwt.hex secret${NC}"
sudo sh -c "openssl rand -hex 32 | tr -d '\n' > ${CUSTOM_PATH}/jwt.hex"
echo ""
echo -e "${GREEN}Creating subFolders for ${ETH_CLIENT} and ${CONSENSUS_CLIENT}${NC}"
sudo mkdir -p "${CUSTOM_PATH}/execution/$ETH_CLIENT"
sudo mkdir -p "${CUSTOM_PATH}/consensus/$CONSENSUS_CLIENT"
echo ""
get_main_user
echo -e "${GREEN}Creating the users ${ETH_CLIENT} and ${CONSENSUS_CLIENT} and setting permissions to the folders${NC}"
sudo useradd -M -G docker $ETH_CLIENT
sudo useradd -M -G docker $CONSENSUS_CLIENT
sudo chown -R ${ETH_CLIENT}:docker "${CUSTOM_PATH}/execution"
sudo chmod -R 750 "${CUSTOM_PATH}/execution"
sudo chown -R ${CONSENSUS_CLIENT}:docker "${CUSTOM_PATH}/consensus/"
sudo chmod -R 750 "${CUSTOM_PATH}/consensus"
press_enter_to_continue
echo "Creating shared group to access jwt.hex file"
# Permission Madness
# defining group for jwt.hex file
sudo groupadd pls-shared
sudo usermod -aG pls-shared ${ETH_CLIENT}
sudo usermod -aG pls-shared ${CONSENSUS_CLIENT}
# defining file permissions for jwt.hexSS
#echo "ETH_CLIENT: ${ETH_CLIENT}"
#echo "CUSTOM_PATH: ${CUSTOM_PATH}"
#echo "File path: ${CUSTOM_PATH}/jwt.hex"
#ls -l "${CUSTOM_PATH}/jwt.hex"
sleep 1
sudo chown ${ETH_CLIENT}:pls-shared ${CUSTOM_PATH}/jwt.hex
sleep 1
sudo chmod 640 ${CUSTOM_PATH}/jwt.hex
sleep 1
#ls -l "${CUSTOM_PATH}/jwt.hex"
press_enter_to_continue
#clear
echo ""
# Firewall Setup
# Prompt for the Rules to add
echo -e "${GREEN}Setting up firewall to allow access to SSH and port 8545 for localhost and private network connection to the RPC.${NC}"
ip_range=$(get_ip_range)
read -p "Do you want to allow access to the RPC and SSH from within your local network ($ip_range) only? (y/N): " local_network_choice
read -p "Do you want to allow RPC (8545) access ?(y/N): " rpc_choice
if [[ $rpc_choice == "y" ]]; then
sudo ufw allow from 127.0.0.1 to any port 8545 proto tcp comment 'RPC Port'
if [[ $local_network_choice == "y" ]]; then
sudo ufw allow from $ip_range to any port 8545 proto tcp comment 'RPC Port for private IP range'
fi
fi
read -p "Do you want to allow SSH access to this server? (y/N): " ssh_choice
if [[ $ssh_choice == "y" ]]; then
read -p "Enter SSH port (default is 22): " ssh_port
if [[ $ssh_port == "" ]]; then
ssh_port=22
fi
if [[ $local_network_choice == "n" ]]; then
sudo ufw allow $ssh_port/tcp comment 'SSH Port'
elif [[ $local_network_choice == "y" ]]; then
sudo ufw allow from $ip_range to any port $ssh_port proto tcp comment 'SSH Port for private IP range'
fi
fi
#############################################################################################################
echo ""
echo -e "${GREEN}Setting Firewall to default, deny incomming and allow outgoing, enabling the Firewall${NC}"
echo ""
sudo ufw default deny incoming
echo ""
sudo ufw default allow outgoing
echo ""
# Allow inbound traffic for specific ports based on user choices
if [ "$ETH_CLIENT_CHOICE" = "1" ]; then # as per https://geth.ethereum.org/docs/fundamentals/security
sudo ufw allow 30303/tcp
sudo ufw allow 30303/udp
elif [ "$ETH_CLIENT_CHOICE" = "2" ]; then #as per https://github.com/ledgerwatch/erigon
sudo ufw allow 30303/tcp
sudo ufw allow 30303/udp
sudo ufw allow 30304/tcp
sudo ufw allow 30304/udp
sudo ufw allow 42069/tcp
sudo ufw allow 42069/udp
sudo ufw allow 4000/udp
sudo ufw allow 4001/tcp
fi
if [ "$CONSENSUS_CLIENT" = "prysm" ]; then #as per https://docs.prylabs.network/docs/prysm-usage/p2p-host-ip
sudo ufw allow 13000/tcp
sudo ufw allow 12000/udp
elif [ "$CONSENSUS_CLIENT" = "lighthouse" ]; then #as per https://lighthouse-book.sigmaprime.io/faq.html
sudo ufw allow 9000
fi
echo ""
echo "enabling firewall now..."
sudo ufw enable
sleep 1
clear
echo ""
echo "The Ethereum and Consensus clients will be started separately using two different scripts."
echo "The start_execution.sh script will start the execution client."
echo "The start_consensus.sh script will start the consensus (beacon) client."
echo "The scripts will be generated in the directory \"$CUSTOM_PATH\"."
echo ""
echo "Generating scripts..."
echo ""
echo -e "${GREEN}Generating start_execution.sh script${NC}"
cat > start_execution.sh << EOL
#!/bin/bash
echo "Starting ${ETH_CLIENT}"
EOL
if [ $ETH_CLIENT_CHOICE = "1" ]; then
sudo docker pull registry.gitlab.com/pulsechaincom/go-pulse:latest
cat >> start_execution.sh << EOL
${GETH_CMD}
EOL
fi
if [ $ETH_CLIENT_CHOICE = "2" ]; then
sudo docker pull registry.gitlab.com/pulsechaincom/erigon-pulse:latest
cat >> start_execution.sh << EOL
${ERIGON_CMD}
EOL
fi
if [ $ETH_CLIENT_CHOICE = "3" ]; then
cat >> start_execution.sh << EOL
${ERIGON_CMD2}
EOL
fi
chmod +x start_execution.sh
sudo mv start_execution.sh "$CUSTOM_PATH"
sudo chown $main_user:docker "$CUSTOM_PATH/start_execution.sh"
echo ""
echo -e "${GREEN}Generating start_consensus.sh script${NC}"
cat > start_consensus.sh << EOL
#!/bin/bash
echo "Starting ${CONSENSUS_CLIENT}"
EOL
if [ "$CONSENSUS_CLIENT" = "prysm" ]; then
sudo docker pull registry.gitlab.com/pulsechaincom/prysm-pulse/beacon-chain:latest
sudo docker pull registry.gitlab.com/pulsechaincom/prysm-pulse/prysmctl:latest
cat >> start_consensus.sh << EOL
${PRYSM_CMD}
EOL
elif [ "$CONSENSUS_CLIENT" = "lighthouse" ]; then
sudo docker pull registry.gitlab.com/pulsechaincom/lighthouse-pulse:latest
cat >> start_consensus.sh << EOL
${LIGHTHOUSE_CMD}
EOL
fi
chmod +x start_consensus.sh
sudo mv start_consensus.sh "$CUSTOM_PATH"
sudo chown $main_user:docker "$CUSTOM_PATH/start_consensus.sh"
echo ""
echo -e "${GREEN}start_execution.sh and start_consensus.sh created successfully!${NC}"
echo ""
echo ""
# Create the helper directory if it doesn't exist
sudo mkdir -p "${CUSTOM_PATH}/helper"
echo ""
echo -e "${GREEN}copying over helper scripts${NC}"
sudo cp setup_validator.sh "$CUSTOM_PATH/helper"
sudo cp setup_monitoring.sh "$CUSTOM_PATH/helper"
sudo cp functions.sh "$CUSTOM_PATH/helper"
sudo cp helper/* "$CUSTOM_PATH/helper"
# Permissions to folders
sudo chmod -R +x $CUSTOM_PATH/helper/
sudo chmod -R 755 $CUSTOM_PATH/helper/
sudo chown -R $main_user:docker $CUSTOM_PATH/helper
echo ""
echo -e "${GREEN}Finished copying helper scripts${NC}"
echo ""
echo ""
echo "Creating a small menu for general housekeeping"
echo ""
menu_script="$(script_launch_template)"
menu_script+="$(printf '\nhelper_scripts_path="%s/helper"\n' "${CUSTOM_PATH}")"
menu_script+="$(menu_script_template)"
# Write the menu script to the helper directory
echo "${menu_script}" | sudo tee "${CUSTOM_PATH}/menu.sh" > /dev/null 2>&1
sudo chmod +x "${CUSTOM_PATH}/menu.sh"
sudo cp "${CUSTOM_PATH}/menu.sh" /usr/local/bin/plsmenu > /dev/null 2>&1
sudo chown -R $main_user:docker $CUSTOM_PATH/menu.sh
echo "Menu script has been generated and written to ${CUSTOM_PATH}/menu.sh"
read -p "Do you want to add Desktop-Shortcuts to a menu for general logging and node/validator settings (Recommended)? [Y/n] " log_choice
echo ""
echo -e "${RED}Note: You might have to right-click > allow launching on these${NC}"
echo ""
if [[ "$log_choice" =~ ^[Yy]$ || "$log_choice" == "" ]]; then
create-desktop-shortcut ${CUSTOM_PATH}/helper/tmux_logviewer.sh tmux_LOGS
create-desktop-shortcut ${CUSTOM_PATH}/helper/log_viewer.sh ui_LOGS
#create-desktop-shortcut ${CUSTOM_PATH}/helper/restart_docker.sh Restart-clients
create-desktop-shortcut ${CUSTOM_PATH}/helper/stop_docker.sh Stop-clients
#create-desktop-shortcut ${CUSTOM_PATH}/helper/update_docker.sh Update-clients
create-desktop-shortcut ${CUSTOM_PATH}/menu.sh Validator-Menu ${CUSTOM_PATH}/helper/LogoVector.svg
fi
echo "Menu generated and copied over to /usr/local/bin/plsmenu - you can open this helper menu by running plsmenu in the terminal"
echo ""
press_enter_to_continue
###### added features
cron
grace
#beacon
# setting 775 for the exeuction folder, in case of backup
sudo chmod 775 -R $CUSTOM_PATH/execution
# setting 777 for install_path
sudo chmod 777 -R ${INSTALL_PATH}
clear
read -p "$(echo -e ${GREEN})Would you like to setup a validator? (y/n):$(echo -e ${NC}))" VALIDATOR_CHOICE
echo ""
if [ "$VALIDATOR_CHOICE" = "y" ]; then
echo ""
echo "Starting setup_validator.sh script"
echo ""
cd ${start_dir}
#echo "debug"
sudo chmod +x setup_validator.sh
sudo ./setup_validator.sh
exit 0
else
echo "Skipping creation of validator."
echo "You can always create a validator later by running the ./setup_validator.sh script separately."
echo ""
fi
read -p "Do you want to start the execution and consensus scripts now? [Y/n] " choice
# Check if the user wants to run the scripts
if [[ "$choice" =~ ^[Yy]$ || "$choice" == "" ]]; then
# Generate the command to start the scripts
command1="${CUSTOM_PATH}/start_execution.sh > /dev/null 2>&1 &"
command2="${CUSTOM_PATH}/start_consensus.sh > /dev/null 2>&1 &"
# Print the command to the terminal
echo "Running command: $command1"
echo "Running command: $command2"
# Run the command
eval $command1
sleep 1
eval $command2
sleep 1
fi
clear
echo ""
echo -e "${GREEN}Congratulations, node installation/setup is now complete.${NC}"
echo ""
display_credits
# Inform the user that a reboot is required, making 'Yes' the default choice
echo ""
echo "The system now requires a reboot to complete the setup. Would you like to reboot now? (Yes/no)"
read -p "" user_response
# Treat an empty response as 'yes'
if [[ -z "$user_response" ]] || [[ "$user_response" == "yes" ]] || [[ "$user_response" == "y" ]]; then
echo "Rebooting the system..."
sleep 1
sudo reboot
else
echo "Please reboot the system manually to complete the setup."
exit 0
fi
exit 0