Add installation checks for libraries & fix rpc link

This commit is contained in:
Theo 2023-10-10 15:59:17 -07:00
parent fcc757cc6a
commit ff4210d92f

@ -51,15 +51,18 @@ function install_requred_packages(){
} }
function install_node(){ function install_node(){
curl -s -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash &>> $script_log_file; if ! command -v "nvm" &> $script_log_file; then
. ~/.nvm/nvm.sh; curl -s -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash &>> $script_log_file;
. ~/.profile; . ~/.nvm/nvm.sh;
. ~/.bashrc; . ~/.profile;
. ~/.bashrc;
fi;
local required_node_version=16.20.2; local required_node_version=16.20.2;
nvm install $required_node_version &>> $script_log_file; nvm install $required_node_version &>> $script_log_file;
nvm use $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"; echo "Node $required_node_version successfully installed";
else else
echo_log_err_and_exit "Cannot install node $required_node_version or node installed with error"; 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(){ 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"); 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 for gateway in ${ipfs_gateways[@]}; do
delete_if_exists $tornado_folder; delete_if_exists $tornado_folder;
if git clone $gateway/$this_repo_ipfs_cid $tornado_folder; then break; fi; if git clone $gateway/$this_repo_ipfs_cid $tornado_folder; then break; fi;
done; done;
if [ ! -d $tornado_folder ]; then echo_log_err_and_exit "Cannot download repository from IPFS"; fi; if [ ! -d $tornado_folder ]; then echo_log_err_and_exit "Cannot download repository from IPFS"; fi;
} }
function install_node_dependencies(){ function install_node_dependencies(){
npm i -g yarn &>> $script_log_file; npm i -g yarn &>> $script_log_file;
cd $tornado_folder; cd $tornado_folder;
yarn &>> $script_log_file; yarn &>> $script_log_file;
} }
function run_ipfs_daemon(){ function run_ipfs_daemon(){
if ! command -v "ipfs" &> $script_log_file; then
cd $tornado_folder; cd $tornado_folder;
wget https://dist.ipfs.tech/kubo/v0.22.0/kubo_v0.22.0_linux-amd64.tar.gz &>> $script_log_file; 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; tar -xvzf kubo_v0.22.0_linux-amd64.tar.gz;
cd kubo; cd kubo;
sudo bash install.sh &>> $script_log_file; sudo bash install.sh &>> $script_log_file;
ipfs init --profile server; ipfs init --profile server;
fi;
if ! ps aux | grep -w "ipfs daemon" | grep -v "grep"; then
sudo -b ipfs daemon; sudo -b ipfs daemon;
fi;
} }
function configure_firewall(){ function configure_firewall(){
@ -135,7 +142,7 @@ function add_to_cron(){
function prepare_env(){ function prepare_env(){
cd $tornado_folder; cd $tornado_folder;
delete_if_exists .env; 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 "RPC_URL=$rpc_url" > .env;
echo "ENS_ROOT_DOMAIN=tornadocash.eth" >> .env; echo "ENS_ROOT_DOMAIN=tornadocash.eth" >> .env;
} }