From 2f7e696857815ffbbd9098a918a5d31326ebe993 Mon Sep 17 00:00:00 2001 From: Robert Mordzon Date: Thu, 5 Dec 2024 19:10:00 +0100 Subject: [PATCH 1/3] Update rc.local; set BRANCH="r0.7.4" set BRANCH="r0.7.4" --- distros/raspberry_pi/rc.local | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/distros/raspberry_pi/rc.local b/distros/raspberry_pi/rc.local index 6646015..1145972 100644 --- a/distros/raspberry_pi/rc.local +++ b/distros/raspberry_pi/rc.local @@ -3,7 +3,7 @@ # Web3 Pi - rc.local # -BRANCH="dev" +BRANCH="r0.7.4" # Function: echolog # Description: Logs messages with a timestamp prefix. If no arguments are provided, From 850382c276115f50c8fa2eb954519cdcf1219148 Mon Sep 17 00:00:00 2001 From: Robert Mordzon Date: Thu, 5 Dec 2024 19:42:29 +0100 Subject: [PATCH 2/3] exclude goerli network from config.txt --- distros/raspberry_pi/config-consensus.txt | 4 ++-- distros/raspberry_pi/config-exec.txt | 4 ++-- distros/raspberry_pi/config.txt | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/distros/raspberry_pi/config-consensus.txt b/distros/raspberry_pi/config-consensus.txt index cf5c4d5..8b32d77 100644 --- a/distros/raspberry_pi/config-consensus.txt +++ b/distros/raspberry_pi/config-consensus.txt @@ -18,12 +18,12 @@ geth_port=30303 [nimbus] nimbus_port=9000 -# Ethereum network: mainnet/holesky/sepolia/goerli +# Ethereum network: mainnet/holesky/sepolia nimbus_network=mainnet [lighthouse] lighthouse_port=9000 -# Ethereum network: mainnet/holesky/sepolia/goerli +# Ethereum network: mainnet/holesky/sepolia lighthouse_network=mainnet # End of Web3 Pi config diff --git a/distros/raspberry_pi/config-exec.txt b/distros/raspberry_pi/config-exec.txt index 5b7f23d..aa22848 100644 --- a/distros/raspberry_pi/config-exec.txt +++ b/distros/raspberry_pi/config-exec.txt @@ -18,12 +18,12 @@ geth_port=30303 [nimbus] nimbus_port=9000 -# Ethereum network: mainnet/holesky/sepolia/goerli +# Ethereum network: mainnet/holesky/sepolia nimbus_network=mainnet [lighthouse] lighthouse_port=9000 -# Ethereum network: mainnet/holesky/sepolia/goerli +# Ethereum network: mainnet/holesky/sepolia lighthouse_network=mainnet # End of Web3 Pi config diff --git a/distros/raspberry_pi/config.txt b/distros/raspberry_pi/config.txt index 7d18505..e6ff757 100644 --- a/distros/raspberry_pi/config.txt +++ b/distros/raspberry_pi/config.txt @@ -20,12 +20,12 @@ geth_port=30303 [nimbus] nimbus_port=9000 -# Ethereum network: mainnet/holesky/sepolia/goerli +# Ethereum network: mainnet/holesky/sepolia nimbus_network=mainnet [lighthouse] lighthouse_port=9000 -# Ethereum network: mainnet/holesky/sepolia/goerli +# Ethereum network: mainnet/holesky/sepolia lighthouse_network=mainnet # End of Web3 Pi config From 4ccb3c11bde930f1a144caecc4587577d850e93c Mon Sep 17 00:00:00 2001 From: Robert Mordzon Date: Thu, 5 Dec 2024 22:45:03 +0100 Subject: [PATCH 3/3] added testnet servers list; sorting; jwt.hex from microSD if exist; scripts names change --- distros/raspberry_pi/install.sh | 17 +++++++++---- distros/raspberry_pi/lighthouse/lighthouse.sh | 2 +- distros/raspberry_pi/nimbus/nimbus.sh | 15 +++++++++--- .../{pingServers.sh => ping_servers.sh} | 12 +++++++++- .../scripts/servers_list_holesky.txt | 5 ++++ ...rversList.txt => servers_list_mainnet.txt} | 0 .../scripts/servers_list_sepolia.txt | 3 +++ .../{sort_servers.sh => servers_sort.sh} | 24 ++++++++++++++++--- 8 files changed, 65 insertions(+), 13 deletions(-) rename distros/raspberry_pi/scripts/{pingServers.sh => ping_servers.sh} (79%) create mode 100644 distros/raspberry_pi/scripts/servers_list_holesky.txt rename distros/raspberry_pi/scripts/{serversList.txt => servers_list_mainnet.txt} (100%) create mode 100644 distros/raspberry_pi/scripts/servers_list_sepolia.txt rename distros/raspberry_pi/scripts/{sort_servers.sh => servers_sort.sh} (61%) diff --git a/distros/raspberry_pi/install.sh b/distros/raspberry_pi/install.sh index d04d87e..0eb599f 100644 --- a/distros/raspberry_pi/install.sh +++ b/distros/raspberry_pi/install.sh @@ -557,11 +557,18 @@ if [ "$(get_install_stage)" -eq 2 ]; then echolog "Adding client directories required to run the node" sudo -u ethereum mkdir -p /home/ethereum/clients/secrets/ - set_status "[install.sh] - Generating the jwt.hex file" - #sudo -u ethereum openssl rand -hex 32 | tr -d "\n" | tee /home/ethereum/clients/secrets/jwt.hex - sudo -u ethereum openssl rand -hex 32 | sudo -u ethereum tr -d "\n" | sudo -u ethereum tee /home/ethereum/clients/secrets/jwt.hex - echolog " " - + set_status "[install.sh] - Prepare the jwt.hex file" + # Check if the file exists + if [ -f "/boot/firmware/jwt.hex" ]; then + # Move the file to the destination directory + mv "/boot/firmware/jwt.hex" "/home/ethereum/clients/secrets/" + echolog "The /boot/firmware/jwt.hex file has been moved to /home/ethereum/clients/secrets/" + else + echolog "The /boot/firmware/jwt.hex file does not exist. Generating new jwt.hex file" + sudo -u ethereum openssl rand -hex 32 | sudo -u ethereum tr -d "\n" | sudo -u ethereum tee /home/ethereum/clients/secrets/jwt.hex + echolog " " + fi + set_status "[install.sh] - Copying scripts to /home/ethereum/scripts" ln -s /opt/web3pi/Ethereum-On-Raspberry-Pi/distros/raspberry_pi/scripts/ /home/ethereum/ chmod +x /opt/web3pi/Ethereum-On-Raspberry-Pi/distros/raspberry_pi/scripts/*.sh diff --git a/distros/raspberry_pi/lighthouse/lighthouse.sh b/distros/raspberry_pi/lighthouse/lighthouse.sh index 00382e6..e4db761 100644 --- a/distros/raspberry_pi/lighthouse/lighthouse.sh +++ b/distros/raspberry_pi/lighthouse/lighthouse.sh @@ -72,7 +72,7 @@ while [ $? -ne 0 ]; do done # Script for finding the best server -source /opt/web3pi/Ethereum-On-Raspberry-Pi/distros/raspberry_pi/scripts/pingServers.sh +source /opt/web3pi/Ethereum-On-Raspberry-Pi/distros/raspberry_pi/scripts/ping_servers.sh echolog "$(date): Connected - ${pingServerAdr}" echolog "exec_url = ${exec_url}" diff --git a/distros/raspberry_pi/nimbus/nimbus.sh b/distros/raspberry_pi/nimbus/nimbus.sh index 9e4684c..fd5d654 100644 --- a/distros/raspberry_pi/nimbus/nimbus.sh +++ b/distros/raspberry_pi/nimbus/nimbus.sh @@ -87,10 +87,19 @@ echolog "nimbus_port = ${nimbus_port}" echolog "nimbus_network = ${nimbus_network}" echolog "nimbus_dir = ${nimbus_dir}" -bash /opt/web3pi/Ethereum-On-Raspberry-Pi/distros/raspberry_pi/scripts/sort_servers.sh - # File with the list of servers -SERVERS_FILE="/opt/web3pi/Ethereum-On-Raspberry-Pi/distros/raspberry_pi/scripts/serversList.txt" +SERVERS_FILE="/opt/web3pi/Ethereum-On-Raspberry-Pi/distros/raspberry_pi/scripts/servers_list_${nimbus_network}.txt" + +if [ -f "${SERVERS_FILE}" ]; then + echolog "SERVERS_FILE = ${SERVERS_FILE}" +else + echolog "File ${SERVERS_FILE} does not exist." + return 1 +fi + +bash /opt/web3pi/Ethereum-On-Raspberry-Pi/distros/raspberry_pi/scripts/servers_sort.sh $SERVERS_FILE + +sleep 1 # Iterate through each server from the list success=false diff --git a/distros/raspberry_pi/scripts/pingServers.sh b/distros/raspberry_pi/scripts/ping_servers.sh similarity index 79% rename from distros/raspberry_pi/scripts/pingServers.sh rename to distros/raspberry_pi/scripts/ping_servers.sh index a62bce3..7e7cc03 100644 --- a/distros/raspberry_pi/scripts/pingServers.sh +++ b/distros/raspberry_pi/scripts/ping_servers.sh @@ -1,6 +1,16 @@ #!/bin/bash -servers_file="/opt/web3pi/Ethereum-On-Raspberry-Pi/distros/raspberry_pi/scripts/serversList.txt" +# Read custom config flags from /boot/firmware/config.txt +config_read_file() { + (grep -E "^${2}=" -m 1 "${1}" 2>/dev/null || echo "VAR=UNDEFINED") | head -n 1 | cut -d '=' -f 2-; +} + +config_get() { + val="$(config_read_file /boot/firmware/config.txt "${1}")"; + printf -- "%s" "${val}"; +} + +servers_file="/opt/web3pi/Ethereum-On-Raspberry-Pi/distros/raspberry_pi/scripts/servers_list_${lighthouse_network}.txt" best_server="" best_ping=1000000 # set a very high initial value diff --git a/distros/raspberry_pi/scripts/servers_list_holesky.txt b/distros/raspberry_pi/scripts/servers_list_holesky.txt new file mode 100644 index 0000000..0a84a0c --- /dev/null +++ b/distros/raspberry_pi/scripts/servers_list_holesky.txt @@ -0,0 +1,5 @@ +https://holesky.beaconstate.info +https://holesky-checkpoint-sync.stakely.io +https://beaconstate-holesky.chainsafe.io +https://holesky.beaconstate.ethstaker.cc +https://checkpoint-sync.holesky.ethpandaops.io \ No newline at end of file diff --git a/distros/raspberry_pi/scripts/serversList.txt b/distros/raspberry_pi/scripts/servers_list_mainnet.txt similarity index 100% rename from distros/raspberry_pi/scripts/serversList.txt rename to distros/raspberry_pi/scripts/servers_list_mainnet.txt diff --git a/distros/raspberry_pi/scripts/servers_list_sepolia.txt b/distros/raspberry_pi/scripts/servers_list_sepolia.txt new file mode 100644 index 0000000..591947d --- /dev/null +++ b/distros/raspberry_pi/scripts/servers_list_sepolia.txt @@ -0,0 +1,3 @@ +https://checkpoint-sync.sepolia.ethpandaops.io +https://beaconstate-sepolia.chainsafe.io +https://sepolia.beaconstate.info \ No newline at end of file diff --git a/distros/raspberry_pi/scripts/sort_servers.sh b/distros/raspberry_pi/scripts/servers_sort.sh similarity index 61% rename from distros/raspberry_pi/scripts/sort_servers.sh rename to distros/raspberry_pi/scripts/servers_sort.sh index 52b1764..861bf62 100644 --- a/distros/raspberry_pi/scripts/sort_servers.sh +++ b/distros/raspberry_pi/scripts/servers_sort.sh @@ -1,9 +1,27 @@ #!/bin/bash -echo "Start sorting server list..." +# Function: echolog +# Description: Logs messages with a timestamp prefix. If no arguments are provided, +# reads from stdin and logs each line. Outputs to console and appends to $LOGI file. +LOGI="/var/log/web3pi.log" +echolog(){ + if [ $# -eq 0 ] + then cat - | while read -r message + do + echo "$(date +"[%F %T %Z] -") $message" | tee -a $LOGI + done + else + echo -n "$(date +'[%F %T %Z]') - " | tee -a $LOGI + echo "$*" | tee -a $LOGI + fi +} + +echolog "Start sorting server list..." # File with the list of servers -SERVERS_FILE="/opt/web3pi/Ethereum-On-Raspberry-Pi/distros/raspberry_pi/scripts/serversList.txt" +SERVERS_FILE=$1 + +echolog "SERVERS_FILE = ${SERVERS_FILE}" # Check if the file exists if [ ! -f "$SERVERS_FILE" ]; then @@ -45,4 +63,4 @@ awk '{print $2}' "$TEMP_FILE" > "$SERVERS_FILE" # Remove the temporary file rm "$TEMP_FILE" -echo "The server list has been sorted based on average ping times." +echolog "The server list has been sorted based on average ping times."