From ff4210d92f9e8d8ef1f3391822e9a9fbeef429b6 Mon Sep 17 00:00:00 2001 From: Theo Date: Tue, 10 Oct 2023 15:59:17 -0700 Subject: [PATCH] Add installation checks for libraries & fix rpc link --- scripts/hostIPFS.sh | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/scripts/hostIPFS.sh b/scripts/hostIPFS.sh index 285d2fe..4b5ff9b 100644 --- a/scripts/hostIPFS.sh +++ b/scripts/hostIPFS.sh @@ -51,15 +51,18 @@ function install_requred_packages(){ } function install_node(){ - curl -s -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash &>> $script_log_file; - . ~/.nvm/nvm.sh; - . ~/.profile; - . ~/.bashrc; + if ! command -v "nvm" &> $script_log_file; then + curl -s -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash &>> $script_log_file; + . ~/.nvm/nvm.sh; + . ~/.profile; + . ~/.bashrc; + fi; local required_node_version=16.20.2; nvm install $required_node_version &>> $script_log_file; nvm use $required_node_version &>> $script_log_file; - if node -v | grep -qw $required_node_version; then + echo $(node -v); + if node -v | grep -q $required_node_version; then echo "Node $required_node_version successfully installed"; else echo_log_err_and_exit "Cannot install node $required_node_version or node installed with error"; @@ -67,28 +70,32 @@ function install_node(){ } function download_repo(){ - ipfs_gateways=("https://ipfs.io/ipfs" "https://dweb.link/ipfs" "https://cloudflare-ipfs.com/ipfs" "https://gateway.pinata.cloud/ipfs" "https://hardbin.com/ipfs"); - for gateway in ${ipfs_gateways[@]}; do - delete_if_exists $tornado_folder; - if git clone $gateway/$this_repo_ipfs_cid $tornado_folder; then break; fi; - done; - if [ ! -d $tornado_folder ]; then echo_log_err_and_exit "Cannot download repository from IPFS"; fi; + ipfs_gateways=("https://ipfs.io/ipfs" "https://dweb.link/ipfs" "https://cloudflare-ipfs.com/ipfs" "https://gateway.pinata.cloud/ipfs" "https://hardbin.com/ipfs"); + for gateway in ${ipfs_gateways[@]}; do + delete_if_exists $tornado_folder; + if git clone $gateway/$this_repo_ipfs_cid $tornado_folder; then break; fi; + done; + if [ ! -d $tornado_folder ]; then echo_log_err_and_exit "Cannot download repository from IPFS"; fi; } function install_node_dependencies(){ - npm i -g yarn &>> $script_log_file; - cd $tornado_folder; - yarn &>> $script_log_file; + npm i -g yarn &>> $script_log_file; + cd $tornado_folder; + yarn &>> $script_log_file; } function run_ipfs_daemon(){ + if ! command -v "ipfs" &> $script_log_file; then cd $tornado_folder; wget https://dist.ipfs.tech/kubo/v0.22.0/kubo_v0.22.0_linux-amd64.tar.gz &>> $script_log_file; tar -xvzf kubo_v0.22.0_linux-amd64.tar.gz; cd kubo; sudo bash install.sh &>> $script_log_file; ipfs init --profile server; + fi; + if ! ps aux | grep -w "ipfs daemon" | grep -v "grep"; then sudo -b ipfs daemon; + fi; } function configure_firewall(){ @@ -135,7 +142,7 @@ function add_to_cron(){ function prepare_env(){ cd $tornado_folder; delete_if_exists .env; - local rpc_url="https://eth.llamarpc.com"l; + local rpc_url="https://eth.llamarpc.com"; echo "RPC_URL=$rpc_url" > .env; echo "ENS_ROOT_DOMAIN=tornadocash.eth" >> .env; }