From 5b87f99548863e46be64709f86fcfbf6620398b9 Mon Sep 17 00:00:00 2001 From: sfaber34 Date: Sat, 20 Apr 2024 13:07:42 -0600 Subject: [PATCH] updated bgnodes.sh --- packages/nextjs/public/bgnodes.sh | 107 +++++++++++++++++++++++++++++- 1 file changed, 106 insertions(+), 1 deletion(-) diff --git a/packages/nextjs/public/bgnodes.sh b/packages/nextjs/public/bgnodes.sh index 3ca6e00..43bca7b 100644 --- a/packages/nextjs/public/bgnodes.sh +++ b/packages/nextjs/public/bgnodes.sh @@ -1,3 +1,108 @@ #!/bin/bash -echo "Hello World!" \ No newline at end of file +# Default values for the options +e="geth" +c="prysm" + +# Help function to display usage information +show_help() { + echo "Usage: $0 [options]" + echo "" + echo "Options:" + echo " -e Specify the execution client ('geth' or 'reth')" + echo " -c Specify the consensus client ('prysm' or 'lighthouse')" + echo " -h Display this help message and exit" + echo "" +} + +# Process command-line options +while getopts ":e:c:h" opt; do + case ${opt} in + e ) + e=$OPTARG + # Validate the execution client option + if [[ $e != "geth" && $e != "reth" ]]; then + echo "Invalid option for -e. Use 'geth' or 'reth'." + exit 1 + fi + ;; + c ) + c=$OPTARG + # Validate the consensus client option + if [[ $c != "prysm" && $c != "lighthouse" ]]; then + echo "Invalid option for -c. Use 'prysm' or 'lighthouse'." + exit 1 + fi + ;; + h ) + show_help + exit 0 + ;; + \? ) + echo "Invalid option: -$OPTARG" 1>&2 + show_help + exit 1 + ;; + : ) + echo "Option -$OPTARG requires an argument." 1>&2 + exit 1 + ;; + esac +done + +echo "Execution client selected: $e" +echo -e "Consensus client selected: $c\n" + +os_name=$(uname -s) +echo -e "The operating system is: $os_name\n" + +echo -e "Checking for dependencies" +if command -v node >/dev/null 2>&1; then + echo "Node.js is installed. Version:" + node -v +else + echo "Please install node.js (https://nodejs.org/en/download)" + exit 1 +fi + +if command -v yarn >/dev/null 2>&1; then + echo "Yarn is installed. Version:" + yarn -v +else + echo "Please install yarn (https://yarnpkg.com/getting-started/install)" + exit 1 +fi +echo -e "\n" + +if [ ! -d "$HOME/ethereum/consensus" ]; then + echo "Creating '~/ethereum/consensus'" + mkdir -p "$HOME/ethereum/consensus" +fi + +# if [ "$e" == "geth" ]; then +# echo "The execution client is Geth." +# elif [ "$e" == "reth" ]; then +# echo "The execution client is Reth." +# fi + +if [ ! -d "$HOME/ethereum/execution" ]; then + echo "Creating '~/ethereum/execution'" + mkdir -p "$HOME/ethereum/execution" +fi + +if [ "$c" == "prysm" ]; then + if [ ! -f "$HOME/ethereum/execution/prysm.sh" ]; then + echo "Installing Prysm." + cd "$HOME/ethereum/execution" + curl https://raw.githubusercontent.com/prysmaticlabs/prysm/master/prysm.sh --output prysm.sh && chmod +x prysm.sh + else + echo "Prysm is already installed." + fi +elif [ "$c" == "lighthouse" ]; then + echo "Installing Lighthouse." + # Todo: Add Lighthouse install code +fi + + + +# node helloWorld.js \ No newline at end of file