From 45e45592175016d1725f520ff4b5acd52d719e53 Mon Sep 17 00:00:00 2001 From: sfaber34 Date: Tue, 11 Jun 2024 13:22:55 -0600 Subject: [PATCH] Re-added old bash script untill I can get the yes/no version working on Ubuntu --- packages/nextjs/public/runBuidlGuidlClient.sh | 200 +++++++-------- .../nextjs/public/runBuidlGuidlClientYesNo.sh | 234 ++++++++++++++++++ 2 files changed, 325 insertions(+), 109 deletions(-) create mode 100755 packages/nextjs/public/runBuidlGuidlClientYesNo.sh diff --git a/packages/nextjs/public/runBuidlGuidlClient.sh b/packages/nextjs/public/runBuidlGuidlClient.sh index 99fa660..ac86e76 100755 --- a/packages/nextjs/public/runBuidlGuidlClient.sh +++ b/packages/nextjs/public/runBuidlGuidlClient.sh @@ -1,5 +1,9 @@ #!/bin/bash +# TODO: Add Mac and Windows prereq installs (see checkWindowsPrereqs() in index.js) +# TODO: OpenSSL... +# TODO: Need a sudo apt install for npm after nodejs + # Default values for the options e="geth" c="prysm" @@ -50,171 +54,149 @@ while getopts ":e:c:h" opt; do esac done -# Function to ask for user confirmation -confirm() { - # Loop until a valid response is received - while true; do - read -r -p "$1 [Y/n]: " response - case "$response" in - [Yy]* ) return 0;; # User confirmed (yes) - [Nn]* ) return 1;; # User denied (no) - * ) echo "Please answer yes or no.";; - esac - done -} - echo "Execution client selected: $e" echo -e "Consensus client selected: $c\n" os_name=$(uname -s) if [ "$os_name" = "Linux" ]; then - echo -e "\n💪 Updating apt-get packages" - sudo apt-get update - sudo apt-get upgrade -y + # echo -e "Updating apt-get packages" + # sudo apt-get update + # sudo apt-get upgrade -y - echo -e "\n🕵️ Checking for dependencies" + echo -e "\nChecking for dependencies" if command -v node >/dev/null 2>&1; then - echo -e "\n✅ Node is installed. Version:" + echo -e "\nNode.js is installed. Version:" node -v else - read -r -p "❓ Node is not installed. Do you want to install it? [y/N] " response - if [[ "$response" =~ ^[Yy]$ ]]; then - echo -e "\n💪 Installing Node" - cd ~ - curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - - sudo apt install -y nodejs - else - echo -e "\n👎 Node installation canceled." - fi - fi - - exit - - if command -v npm >/dev/null 2>&1; then - echo -e "\n✅ NPM is installed. Version:" - npm -v - else - if confirm "\n❓ NPM is not installed. Do you want to install it?"; then - echo -e "\n💪 Installing NPM" - sudo apt install npm - else - echo -e "\n👎 NPM installation canceled." - fi + echo -e "\nRun these lines to install Node.js" + echo -e "curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -" + echo -e "sudo apt install -y nodejs" + exit + # echo -e "\nInstalling Node.js" + # cd ~ + # curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - + # sudo apt install -y nodejs fi if command -v yarn >/dev/null 2>&1; then - echo -e "\n✅ Yarn is installed. Version:" + echo -e "\nYarn is installed. Version:" yarn -v else - if confirm "\n❓ Yarn is not installed. Do you want to install it?"; then - echo -e "\n💪 Installing Yarn" - sudo npm i yarn -g - else - echo -e "\n👎 Yarn installation canceled." - fi + echo -e "\nRun this line to install Yarn" + echo -e "sudo npm i yarn -g" + exit + # echo -e "\nInstalling Yarn" + # sudo npm i yarn -g fi if command -v git >/dev/null 2>&1; then - echo -e "\n✅ Git is installed. Version:" + echo -e "\nGit is installed. Version:" git --version else - if confirm "\n❓ Git is not installed. Do you want to install it?"; then - echo -e "\n💪 Installing Git" - sudo apt-get install git-all -y - else - echo -e "\n👎 Git installation canceled." - fi + echo -e "\nRun this line to install Git" + echo -e "sudo apt-get install git-all -y" + exit + # echo -e "\nInstalling Git" + # sudo apt-get install git-all -y fi + # if command -v lz4 >/dev/null 2>&1; then + # echo -e "\nLZ4 is installed. Version:" + # lz4 --version + # else + # echo -e "\nInstalling LZ4" + # sudo apt-get install lz4 + # fi + + # if npm list -g pm2 >/dev/null 2>&1; then + # echo -e "\npm2 is installed." + # else + # echo -e "\Run this line to install pm2" + # echo -e "sudo npm install pm2@latest -g" + # exit + # # echo -e "\nInstalling pm2." + # # sudo npm install pm2@latest -g + # fi + if command -v make >/dev/null 2>&1; then - echo -e "\n✅ GNU Make is installed. Version:" - make -v + echo -e "\nGNU Make is installed. Version:" + yarn -v else - if confirm "\n❓ GNU Make is not installed. Do you want to install it?"; then - echo -e "\n💪 Installing GNU Make" - sudo apt-get install build-essential - else - echo -e "\n👎 GNU Make installation canceled." - fi + echo -e "\nRun this line to install GNU Make" + echo -e "sudo apt-get install build-essential" + exit + # echo -e "\nInstalling Yarn" + # sudo npm i yarn -g fi fi if [ "$os_name" = "Darwin" ]; then - echo -e "\n🕵️ Checking for dependencies" + echo -e "\nChecking for dependencies" if command -v node >/dev/null 2>&1; then - echo -e "\n✅ Node is installed. Version:" + echo -e "\nNode.js is installed. Version:" node -v else - if confirm "\n❓ Node is not installed. Do you want to install it?"; then - echo -e "\n💪 Installing Node" - brew install node - else - echo -e "\n👎 Node installation canceled." - fi + echo -e "\nRun this line to install Node.js" + echo -e "brew install node" + exit fi if command -v yarn >/dev/null 2>&1; then - echo -e "\n✅ Yarn is installed. Version:" + echo -e "\nYarn is installed. Version:" yarn -v else - if confirm "\n❓ Yarn is not installed. Do you want to install it?"; then - echo -e "\n💪 Installing Yarn" - brew install yarn - else - echo -e "\n👎 Yarn installation canceled." - fi + echo -e "\nRun this line to install Yarn" + echo -e "brew install yarn" + exit fi if command -v git >/dev/null 2>&1; then echo -e "\nGit is installed. Version:" git --version else - if confirm "\n❓ Git is not installed. Do you want to install it?"; then - echo -e "\n💪 Installing Git" - brew install git - else - echo -e "\n👎 Git installation canceled." - fi + echo -e "\nRun this line to install Git" + echo -e "brew install git" + exit fi + # if npm list -g pm2 >/dev/null 2>&1; then + # echo -e "\npm2 is installed." + # else + # echo -e "\nRun this line to install pm2:" + # echo "npm i -g pm2" + # exit + # fi + if command -v make >/dev/null 2>&1; then - echo -e "\n✅ GNU Make is installed. Version:" - make -v + echo -e "\nGNU Make is installed. Version:" + yarn -v else - if confirm "\n❓ GNU Make is not installed. Do you want to install it?"; then - echo -e "\n💪 Installing GNU Make" - brew install make - else - echo -e "\n👎 GNU Make installation canceled." - fi + echo -e "\nRun this line to install GNU Make" + echo -e "brew install make" + exit + # echo -e "\nInstalling Yarn" + # sudo npm i yarn -g fi if command -v gpg >/dev/null 2>&1; then - echo -e "\n✅ gnupg is installed." + echo -e "\ngnupg is installed." else - read -r -p "❓ gnupg is not installed. Do you want to install it? [y/N] " -n 1 - if [[ "$REPLY" =~ ^[Yy]$ ]]; then - echo -e "\n💪 Installing gnupg:" - brew install gnupg - else - echo -e "\n👎 gnupg installation canceled." - fi + echo -e "\nRun this line to install gnupg:" + echo "brew install gnupg" + exit fi if perl -MDigest::SHA -e '1' >/dev/null 2>&1; then - echo -e "\n✅ Perl-Digest-SHA is installed." + echo -e "\nperl-Digest-SHA is installed." else - if confirm "\n❓ Perl-Digest-SHA is not installed. Do you want to install it?"; then - echo -e "\n💪 Installing perl-Digest-SHA" - brew install perl - brew install cpanminus - cpanm Digest::SHA - else - echo -e "\n👎 Perl-Digest-SHA installation canceled." - fi + echo -e "\nRun these lines to install perl-Digest-SHA" + echo "brew install perl" + echo "brew install cpanminus" + echo "cpanm Digest::SHA" + exit fi fi diff --git a/packages/nextjs/public/runBuidlGuidlClientYesNo.sh b/packages/nextjs/public/runBuidlGuidlClientYesNo.sh new file mode 100755 index 0000000..99fa660 --- /dev/null +++ b/packages/nextjs/public/runBuidlGuidlClientYesNo.sh @@ -0,0 +1,234 @@ +#!/bin/bash + +# 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 + +# Function to ask for user confirmation +confirm() { + # Loop until a valid response is received + while true; do + read -r -p "$1 [Y/n]: " response + case "$response" in + [Yy]* ) return 0;; # User confirmed (yes) + [Nn]* ) return 1;; # User denied (no) + * ) echo "Please answer yes or no.";; + esac + done +} + +echo "Execution client selected: $e" +echo -e "Consensus client selected: $c\n" + +os_name=$(uname -s) + +if [ "$os_name" = "Linux" ]; then + echo -e "\n💪 Updating apt-get packages" + sudo apt-get update + sudo apt-get upgrade -y + + echo -e "\n🕵️ Checking for dependencies" + + if command -v node >/dev/null 2>&1; then + echo -e "\n✅ Node is installed. Version:" + node -v + else + read -r -p "❓ Node is not installed. Do you want to install it? [y/N] " response + if [[ "$response" =~ ^[Yy]$ ]]; then + echo -e "\n💪 Installing Node" + cd ~ + curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - + sudo apt install -y nodejs + else + echo -e "\n👎 Node installation canceled." + fi + fi + + exit + + if command -v npm >/dev/null 2>&1; then + echo -e "\n✅ NPM is installed. Version:" + npm -v + else + if confirm "\n❓ NPM is not installed. Do you want to install it?"; then + echo -e "\n💪 Installing NPM" + sudo apt install npm + else + echo -e "\n👎 NPM installation canceled." + fi + fi + + if command -v yarn >/dev/null 2>&1; then + echo -e "\n✅ Yarn is installed. Version:" + yarn -v + else + if confirm "\n❓ Yarn is not installed. Do you want to install it?"; then + echo -e "\n💪 Installing Yarn" + sudo npm i yarn -g + else + echo -e "\n👎 Yarn installation canceled." + fi + fi + + if command -v git >/dev/null 2>&1; then + echo -e "\n✅ Git is installed. Version:" + git --version + else + if confirm "\n❓ Git is not installed. Do you want to install it?"; then + echo -e "\n💪 Installing Git" + sudo apt-get install git-all -y + else + echo -e "\n👎 Git installation canceled." + fi + fi + + if command -v make >/dev/null 2>&1; then + echo -e "\n✅ GNU Make is installed. Version:" + make -v + else + if confirm "\n❓ GNU Make is not installed. Do you want to install it?"; then + echo -e "\n💪 Installing GNU Make" + sudo apt-get install build-essential + else + echo -e "\n👎 GNU Make installation canceled." + fi + fi +fi + +if [ "$os_name" = "Darwin" ]; then + echo -e "\n🕵️ Checking for dependencies" + + if command -v node >/dev/null 2>&1; then + echo -e "\n✅ Node is installed. Version:" + node -v + else + if confirm "\n❓ Node is not installed. Do you want to install it?"; then + echo -e "\n💪 Installing Node" + brew install node + else + echo -e "\n👎 Node installation canceled." + fi + fi + + if command -v yarn >/dev/null 2>&1; then + echo -e "\n✅ Yarn is installed. Version:" + yarn -v + else + if confirm "\n❓ Yarn is not installed. Do you want to install it?"; then + echo -e "\n💪 Installing Yarn" + brew install yarn + else + echo -e "\n👎 Yarn installation canceled." + fi + fi + + if command -v git >/dev/null 2>&1; then + echo -e "\nGit is installed. Version:" + git --version + else + if confirm "\n❓ Git is not installed. Do you want to install it?"; then + echo -e "\n💪 Installing Git" + brew install git + else + echo -e "\n👎 Git installation canceled." + fi + fi + + if command -v make >/dev/null 2>&1; then + echo -e "\n✅ GNU Make is installed. Version:" + make -v + else + if confirm "\n❓ GNU Make is not installed. Do you want to install it?"; then + echo -e "\n💪 Installing GNU Make" + brew install make + else + echo -e "\n👎 GNU Make installation canceled." + fi + fi + + if command -v gpg >/dev/null 2>&1; then + echo -e "\n✅ gnupg is installed." + else + read -r -p "❓ gnupg is not installed. Do you want to install it? [y/N] " -n 1 + if [[ "$REPLY" =~ ^[Yy]$ ]]; then + echo -e "\n💪 Installing gnupg:" + brew install gnupg + else + echo -e "\n👎 gnupg installation canceled." + fi + fi + + if perl -MDigest::SHA -e '1' >/dev/null 2>&1; then + echo -e "\n✅ Perl-Digest-SHA is installed." + else + if confirm "\n❓ Perl-Digest-SHA is not installed. Do you want to install it?"; then + echo -e "\n💪 Installing perl-Digest-SHA" + brew install perl + brew install cpanminus + cpanm Digest::SHA + else + echo -e "\n👎 Perl-Digest-SHA installation canceled." + fi + fi +fi + +if [ ! -d "$HOME/buidlguidl-client" ]; then + echo -e "\n🚀 Cloning buidlguidl-client repo" + cd ~ + git clone https://github.com/BuidlGuidl/buidlguidl-client.git + cd buidlguidl-client + yarn install +else + echo -e "\n⌛️ Updating buidlguidl-client repo" + cd "$HOME/buidlguidl-client" + git pull +fi + +cd "$HOME/buidlguidl-client" +node index.js