Improve logging in script & fill .env before usage & update repo IPFS CID

This commit is contained in:
Theo 2023-10-05 14:46:40 -07:00
parent 1923cb278c
commit 13f3166adc

@ -5,7 +5,7 @@ if [ "$EUID" -ne 0 ];
exit 1; exit 1;
fi; fi;
this_repo_ipfs_cid="bafybeienn6huru6cxs3ovl5ogeik2wnvviqtoainqj4zn2q3q7zzezvu6u"; this_repo_ipfs_cid="bafybeieo67exajd256bkdxviwqv6leyi4zxk4bby3wj2u466bqfer7lyde";
user_home_dir=$(eval echo ~$USER); user_home_dir=$(eval echo ~$USER);
tornado_folder="$user_home_dir/tornado-ipfs"; tornado_folder="$user_home_dir/tornado-ipfs";
script_log_file="/tmp/tornado-ipfs-installation.log"; script_log_file="/tmp/tornado-ipfs-installation.log";
@ -39,6 +39,7 @@ function install_requred_packages(){
if ! is_package_installed $package; then if ! is_package_installed $package; then
# Kill apache process, because Debian configuring nginx package right during installation # Kill apache process, because Debian configuring nginx package right during installation
if [ $package = "nginx" ]; then systemctl stop apache2; fi; if [ $package = "nginx" ]; then systemctl stop apache2; fi;
echo "Start $package package installation";
apt install --yes --force-yes -o DPkg::Options::="--force-confold" $package &>> $script_log_file; apt install --yes --force-yes -o DPkg::Options::="--force-confold" $package &>> $script_log_file;
if ! is_package_installed $package; then if ! is_package_installed $package; then
echo_log_err_and_exit "Error: cannot install \"$package\" package"; echo_log_err_and_exit "Error: cannot install \"$package\" package";
@ -50,11 +51,19 @@ function install_requred_packages(){
} }
function install_node(){ function install_node(){
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash &>> $script_log_file; curl -s -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash &>> $script_log_file;
. ~/.nvm/nvm.sh; . ~/.nvm/nvm.sh;
. ~/.profile; . ~/.profile;
. ~/.bashrc; . ~/.bashrc;
nvm install 16.20.2 &>> $script_log_file;
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 $required_node_version successfully installed";
else
echo_log_err_and_exit "Cannot install node $required_node_version or node installed with error";
fi;
} }
function download_repo(){ function download_repo(){
@ -74,22 +83,33 @@ function install_node_dependencies(){
function run_ipfs_daemon(){ function run_ipfs_daemon(){
cd $tornado_folder; cd $tornado_folder;
wget https://dist.ipfs.tech/kubo/v0.22.0/kubo_v0.22.0_linux-amd64.tar.gz; 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; sudo bash install.sh &>> $script_log_file;
ipfs init --profile server; ipfs init --profile server;
sudo -b ipfs daemon; sudo -b ipfs daemon;
} }
function configure_firewall(){ function configure_firewall(){
ufw allow OpenSSH;
echo "y" | ufw enable;
if ufw status | grep -qw active; then
ufw allow 8080; ufw allow 8080;
ufw allow 4001; ufw allow 4001;
ufw deny 5000; ufw deny 5000;
ufw deny 5001; ufw deny 5001;
ufw insert 1 allow OpenSSH;
echo "y" | ufw enable;
ufw reload; ufw reload;
if ufw status | grep -qw 4001; then
echo "Peering ports for IPFS opened successfully via UFW";
else
echo_log_err $(ufw status);
echo_log_err_and_exit "Cannot open ports for IPFS daemon, configure ufw please";
fi;
else
echo "UFW is disabled, ports already opened successfully, but need to close port 5001";
fi;
} }
function add_to_cron(){ function add_to_cron(){
@ -112,6 +132,14 @@ function add_to_cron(){
fi; fi;
} }
function prepare_env(){
cd $tornado_folder;
delete_if_exists .env;
local rpc_url="https://eth.llamarpc.com"l;
echo "RPC_URL=$rpc_url" > .env;
echo "ENS_ROOT_DOMAIN=tornadocash.eth" >> .env;
}
function run_pinner(){ function run_pinner(){
cd $tornado_folder; cd $tornado_folder;
yarn pin; yarn pin;
@ -125,4 +153,5 @@ install_node_dependencies;
run_ipfs_daemon; run_ipfs_daemon;
configure_firewall; configure_firewall;
add_to_cron; add_to_cron;
prepare_env;
run_pinner; run_pinner;