Verified Commit 70e1b7b0 authored by BTCxZelko's avatar BTCxZelko
Browse files

RoninDojo 1.5 merge

parents 2ddd0039 6efae756
<img src="https://raw.githubusercontent.com/Crazyk031/Images/master/RoninDojo%20Logo.png" width="300" height="300" />
# RoninDojo
RoninDojo is an Installation Assistant and UI for Samourai Wallet's Dojo. We use the Manjaro ARM Minimal operating system on Raspberry Pi4 or Odroid N2.
RoninDojo is an Installation Assistant and Administration Tool for Samourai Wallet's Dojo, Whirlpool, Indexer, and more. It is compatible with single-board computers such as Rockpro64, Odroid N2, Raspberry Pi4, etc. To get started you will need the computer, a micro SD card with RoninOS or Manjaro ARM XFCE flashed onto it, and a 1TB Solid State Drive.
Guides, information, and more can be found on the RoninDojo Wiki page.
Guides, hardware suggestions, useful commands, and more can be found on the RoninDojo Wiki page.
[**RoninDojo Wiki Home**](https://code.samourai.io/ronindojo/RoninDojo/-/wikis/home)
#!/bin/bash
RED='\033[0;31m'
RED=$(tput setaf 1)
# used for color with ${RED}
NC='\033[0m'
NC=$(tput sgr0)
# No Color
echo -e "${NC}"
echo " _____________________________________________________|_._._._._._._._._, "
echo " \____________________________________________________|_|_|_|_|_|_|_|_|_| "
echo " ! "
echo -e "${RED}"
echo " I dreamt of ______ _ _ _ _ "
echo " worldly success | ___ \ (_) | | | (_) "
echo " once.| |_/ /___ _ __ _ _ __ | | | |_| "
echo " | // _ \| '_ \| | '_ \ | | | | | "
echo " | |\ \ (_) | | | | | | | | | |_| | | "
echo " \_| \_\___/|_| |_|_|_| |_|by\____/|_| "
echo " @GuerraMoneta "
echo -e " & @BTCxZelko ${NC}"
echo " ,_._._._._._._._._|_____________________________________________________ "
echo " |_|_|_|_|_|_|_|_|_|____________________________________________________/ "
echo " ! "
echo -e "${NC}"
cat << EOF
_____________________________________________________|_._._._._._._._._,
\____________________________________________________|_|_|_|_|_|_|_|_|_|
!
$(echo -e "${RED}")
I dreamt of ______ _ _ _ _
worldly success | ___ \ (_) | | | (_)
once.| |_/ /___ _ __ _ _ __ | | | |_|
| // _ \| '_ \| | '_ \ | | | | |
| |\ \ (_) | | | | | | | | | |_| | |
\_| \_\___/|_| |_|_|_| |_|by\____/|_|
@GuerraMoneta
& @BTCxZelko
$(echo -e "${NC}")
,_._._._._._._._._|_____________________________________________________
|_|_|_|_|_|_|_|_|_|____________________________________________________/
!
EOF
sleep 5s
#!/bin/bash
# shellcheck source=/dev/null
RED='\033[0;31m'
# used for color with ${RED}
YELLOW='\033[1;33m'
# used for color with ${YELLOW}
NC='\033[0m'
# No Color
. "$HOME"/RoninDojo/Scripts/defaults.sh
. "$HOME"/RoninDojo/Scripts/functions.sh
# start of warning
echo -e "${RED}"
echo "***"
echo "Running Dojo install in 15s..."
echo "***"
echo -e "${NC}"
sleep 5s
_sleep 5
echo -e "${RED}"
echo "***"
echo "If you have already installed Dojo on your system, use Ctrl+C to exit now!"
echo "Use Ctrl+C to exit now if needed!"
echo "***"
echo -e "${NC}"
sleep 5s
_sleep 10
echo -e "${RED}"
echo "***"
echo "If you are a new user sit back, relax, and enjoy."
echo "***"
echo -e "${NC}"
sleep 5s
# end of warning
# start dojo setup
echo -e "${RED}"
echo "***"
echo "Downloading and extracting latest RoninDojo release..."
echo "***"
echo -e "${NC}"
cd ~
git clone https://code.samourai.io/Ronin/samourai-dojo.git # CHANGE TO MASTER AFTER MERGE
cd "$HOME" || exit
git clone -b "${SAMOURAI_BRANCH:-master}" "$SAMOURAI_REPO" dojo
echo -e "${RED}"
echo "***"
echo "Making ~/dojo and copying data."
echo "Values necessary for usernames, passwords, etc. will randomly be generated now..."
echo "***"
echo -e "${NC}"
sleep 2s
mkdir ~/dojo
cp -r samourai-dojo/* ~/dojo
sleep 2s
_sleep 5
echo -e "${RED}"
echo "***"
echo "Removing all the files no longer needed."
echo "These values are found in RoninDojo menus or in the ${DOJO_PATH}/conf directory."
echo "***"
echo -e "${NC}"
sleep 2s
rm -rf samourai-dojo/
sleep 1s
_sleep 5
# see defaults.sh for dojo path
echo -e "${RED}"
echo "***"
echo "Setting the RPC User and Password..."
echo "Be aware you will use these values to login to Dojo Maintenance Tool, Block Explorer, and more!"
echo "***"
echo -e "${NC}"
sleep 2s
_sleep 8
echo -e "${RED}"
echo "***"
echo "NOTICE:"
echo "Randomly generated 32 character value is used, and can be found in Dojo conf directory."
echo "Setting the RPC User and Password..."
echo "***"
echo -e "${NC}"
sleep 3s
_sleep 2
RPC_PASS=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
#RPC Configuration at dojo/docker/my-dojo/conf/docker-bitcoind.conf.tpl
rm -rf ~/dojo/docker/my-dojo/conf/docker-bitcoind.conf.tpl
# Create new docker bitcoind conf file
echo "
cat << EOF > "${DOJO_PATH}"/conf/docker-bitcoind.conf.tpl
#########################################
# CONFIGURATION OF BITCOIND CONTAINER
#########################################
......@@ -127,7 +103,7 @@ BITCOIND_EPHEMERAL_HS=on
# Warning: Do not expose your RPC API to internet!
# See BITCOIND_RPC_EXTERNAL_IP
# Value: on | off
BITCOIND_RPC_EXTERNAL=off
BITCOIND_RPC_EXTERNAL=on
# IP address used to expose the RPC API to external apps
# This parameter is inactive if BITCOIND_RPC_EXTERNAL isn't set to 'on'
# Warning: Do not expose your RPC API to internet!
......@@ -159,56 +135,25 @@ BITCOIND_ZMQ_RAWTXS=9501
# Set value to 9502 if BITCOIND_INSTALL is set to 'on'
# Type: integer
BITCOIND_ZMQ_BLK_HASH=9502
" | sudo tee -a ~/dojo/docker/my-dojo/conf/docker-bitcoind.conf.tpl
EOF
# create new docker bitcoind conf file
# websearch "bash heredoc" for info on redirection
# configuring ~/dojo/docker/my-dojo/conf/docker-node.conf.tpl
echo -e "${RED}"
echo "****"
echo "***"
echo "Setting the Node API Key and JWT Secret..."
echo "***"
echo -e "${NC}"
sleep 2s
_sleep 2
echo -e "${RED}"
echo "***"
echo "NOTICE:"
echo "Randomly generated 64 character value is used, and can be found in Dojo conf directory."
echo "***"
sleep 2s
echo -e "${NC}"
NODE_API_KEY=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 64 | head -n 1)
NODE_JWT_SECRET=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 64 | head -n 1)
# Create random set of 64 characters for API KEY and JWT Secret
echo -e "${RED}"
echo "****"
echo "Setting the Node Admin Key..."
echo "***"
echo -e "${NC}"
sleep 2s
echo -e "${RED}"
echo "****"
echo "The Node Admin Key is password used to enter the Dojo Maintenance Tool."
echo "***"
sleep 3s
echo -e "${NC}"
echo -e "${RED}"
echo "***"
echo "NOTICE:"
echo "See randomly generated 32 character password in Dojo Menu by using Tor Hidden Service Address option."
echo "***"
echo -e "${NC}"
sleep 5s
NODE_ADMIN_KEY=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# Create random set of 32 characters for Node Admin Key
_sleep 2
rm -rf ~/dojo/docker/my-dojo/conf/docker-node.conf.tpl
echo "
cat << EOF > "${DOJO_PATH}"/conf/docker-node.conf.tpl
#########################################
# CONFIGURATION OF NODE JS CONTAINER
#########################################
......@@ -237,18 +182,11 @@ NODE_ACTIVE_INDEXER=local_bitcoind
# FEE TYPE USED FOR FEES ESTIMATIONS BY BITCOIND
# Allowed values are ECONOMICAL or CONSERVATIVE
NODE_FEE_TYPE=ECONOMICAL
" | sudo tee -a ~/dojo/docker/my-dojo/conf/docker-node.conf.tpl
# Create new docker node conf file
rm -rf ~/dojo/docker/my-dojo/conf/docker-mysql.conf.tpl
MYSQL_ROOT_PASSWORD=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 64 | head -n 1)
MYSQL_USER=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 12 | head -n 1)
MYSQL_PASSWORD=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 64 | head -n 1)
# Create random 64 character password and username for MYSQL
#MYSQL User and Password Configuration at dojo/docker/my-dojo/conf/docker-mysql.conf.tpl
EOF
# create new docker node conf file
# websearch "bash heredoc" for info on redirection
echo "
cat << EOF > "${DOJO_PATH}"/conf/docker-mysql.conf.tpl
#########################################
# CONFIGURATION OF MYSQL CONTAINER
#########################################
......@@ -261,8 +199,9 @@ MYSQL_USER=$MYSQL_USER
# Password of of user account
# Type: alphanumeric
MYSQL_PASSWORD=$MYSQL_PASSWORD
" | sudo tee -a ~/dojo/docker/my-dojo/conf/docker-mysql.conf.tpl
# Create new mysql conf file
EOF
# create new mysql conf file
# websearch "bash heredoc" for info on redirection
# BTC-EXPLORER PASSWORD
echo -e "${RED}"
......@@ -270,37 +209,9 @@ echo "***"
echo "Installing your Dojo-backed Bitcoin Explorer..."
echo "***"
echo -e "${NC}"
sleep 1s
_sleep 2
echo -e "${RED}"
echo "***"
echo "This is a fully functioning Bitcoin Blockchain Explorer in a Web Browser."
echo "***"
echo -e "${NC}"
sleep 3s
echo -e "${RED}"
echo "***"
echo "NOTICE:"
echo "See randomly generated 16 character password in Dojo Menu by using Tor Hidden Service Address option."
echo "***"
echo -e "${NC}"
sleep 5s
if [ ! -f ~/dojo/docker/my-dojo/conf/docker-explorer.conf ]; then
EXPLORER_KEY=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1)
sleep 1s
else
echo -e "${RED}"
echo "***"
echo "Explorer is already installed!"
echo "***"
echo -e "${NC}"
fi
# install block explorer
rm -rf ~/dojo/docker/my-dojo/conf/docker-explorer.conf.tpl
echo "
cat << EOF > "${DOJO_PATH}"/conf/docker-explorer.conf.tpl
#########################################
# CONFIGURATION OF EXPLORER CONTAINER
#########################################
......@@ -313,53 +224,63 @@ EXPLORER_INSTALL=on
# Provide a value with a high entropy!
# Type: alphanumeric
EXPLORER_KEY=$EXPLORER_KEY
" | sudo tee -a ~/dojo/docker/my-dojo/conf/docker-explorer.conf.tpl
EOF
# create new block explorer conf file
# websearch "bash heredoc" for info on redirection
read -p "Do you want to install an indexer? [y/n]" yn
read -rp "Do you want to install an indexer? [y/n]" yn
case $yn in
[Y/y]* ) sudo sed -i '9d' ~/dojo/docker/my-dojo/conf/docker-indexer.conf.tpl;
sudo sed -i '9i INDEXER_INSTALL=on' ~/dojo/docker/my-dojo/conf/docker-indexer.conf.tpl;
sudo sed -i '25d' ~/dojo/docker/my-dojo/conf/docker-node.conf.tpl;
sudo sed -i '25i NODE_ACTIVE_INDEXER=local_indexer' ~/dojo/docker/my-dojo/conf/docker-node.conf.tpl;;
[Y/y]* )
sudo sed -i 's/INDEXER_INSTALL=off/INDEXER_INSTALL=on/' "${DOJO_PATH}"/conf/docker-indexer.conf.tpl
sudo sed -i 's/NODE_ACTIVE_INDEXER=local_bitcoind/NODE_ACTIVE_INDEXER=local_indexer/' "${DOJO_PATH}"/conf/docker-node.conf.tpl
;;
[N/n]* ) echo "Indexer will not be installed!";;
* ) echo "Please answer Yes or No.";;
esac
# install indexer
# install indexer prompt
read -p "Do you want to install Electrs? [y/n]" yn
read -rp "Do you want to install Electrs? [y/n]" yn
case $yn in
[Y/y]* ) bash ~/RoninDojo/Scripts/Install/install-electrs-indexer.sh;;
[N/n]* ) echo "Electrs will not be installed!";;
* ) echo "Please answer Yes or No.";;
esac
# install electrs
# install electrs prompt
echo -e "${RED}"
echo "***"
echo "See documentation at https://code.samourai.io/ronindojo/RoninDojo/-/wikis/home"
echo "Please see Wiki for FAQ, help, and so much more..."
echo "***"
echo -e "${NC}"
sleep 5s
# end dojo setup
_sleep 3
echo -e "${RED}"
echo "***"
echo "https://code.samourai.io/ronindojo/RoninDojo/-/wikis/home"
echo "***"
echo -e "${NC}"
_sleep 5
echo -e "${RED}"
echo "***"
echo "Installing Dojo..."
echo "***"
echo -e "${NC}"
sleep 2s
cd ~/dojo/docker/my-dojo
sudo ./dojo.sh install
# once dojo install reaches bitcoind logs / begins syncing then use Ctrl + C to exit and trigger the salvage attempt below
_sleep 2
cd "$DOJO_PATH" || exit
./dojo.sh install
# wait for dojo install to reach bitcoind sync
# use Ctrl + C to exit and trigger the salvage attempt below
if ls /mnt/usb | grep uninstall-salvage > /dev/null ; then
if sudo test -d /mnt/usb/uninstall-salvage; then
echo -e "${RED}"
echo "***"
echo "Blockchain data salvage starting..."
echo "***"
echo -e "${NC}"
sleep 2s
_sleep 2
echo -e "${RED}"
echo "***"
......@@ -367,39 +288,40 @@ if ls /mnt/usb | grep uninstall-salvage > /dev/null ; then
echo "***"
echo -e "${NC}"
read -n 1 -r -s
# press to continue is needed because sudo password can be requested for next steps, if user is AFK there may be timeout
cd ~/dojo/docker/my-dojo
sudo ./dojo.sh stop
sudo rm -rf /mnt/usb/docker/volumes/my-dojo_data-bitcoind/_data/chainstate
sudo rm -rf /mnt/usb/docker/volumes/my-dojo_data-bitcoind/_data/blocks
sudo mv -v /mnt/usb/uninstall-salvage/chainstate /mnt/usb/docker/volumes/my-dojo_data-bitcoind/_data/
sudo mv -v /mnt/usb/uninstall-salvage/blocks /mnt/usb/docker/volumes/my-dojo_data-bitcoind/_data/
# press to continue is needed because sudo password can be requested for next steps
# if the user is AFK there may be timeout
cd "$DOJO_PATH" || exit
./dojo.sh stop
sudo rm -rf /mnt/usb/docker/volumes/my-dojo_data-bitcoind/_data/{blocks,chainstate}
sudo mv -v /mnt/usb/uninstall-salvage/{blocks,chainstate} /mnt/usb/docker/volumes/my-dojo_data-bitcoind/_data/
# changes to dojo path, otherwise exit
# websearch "bash Logical OR (||)" for info
# stops dojo and removes new data directories
# then moves salvaged block data
echo -e "${RED}"
echo "***"
echo "Blockchain data salvage complete!"
echo "***"
echo -e "${NC}"
sleep 3s
sudo rm -rf /mnt/usb/uninstall-salvage/chainstate
sudo rm -rf /mnt/usb/uninstall-salvage/blocks
sudo chown -R 1105:1108 /mnt/usb/docker/volumes/my-dojo_data-bitcoind/_data/
sudo chmod 700 /mnt/usb/docker/volumes/my-dojo_data-bitcoind/_data/chainstate
sudo chmod 700 /mnt/usb/docker/volumes/my-dojo_data-bitcoind/_data/blocks
sudo rm -rf /mnt/usb/uninstall-salvage/
sudo rm -rf /mnt/usb/system-setup-salvage/
sudo ./dojo.sh start
else
echo "No Blockchain data found for salvage check 1..."
_sleep 3
sudo rm -rf /mnt/usb/{system-setup-salvage,uninstall-salvage}
# remove old salvage directories
cd "$DOJO_PATH" || exit
./dojo.sh start
# start dojo
fi
# check for uninstall-salvage, if not found continue
if ls /mnt/usb | grep system-setup-salvage > /dev/null ; then
if sudo test -d /mnt/usb/system-setup-salvage; then
echo -e "${RED}"
echo "***"
echo "Blockchain data salvage starting..."
echo "***"
echo -e "${NC}"
sleep 2s
_sleep 2
echo -e "${RED}"
echo "***"
......@@ -407,35 +329,29 @@ if ls /mnt/usb | grep system-setup-salvage > /dev/null ; then
echo "***"
echo -e "${NC}"
read -n 1 -r -s
cd ~/dojo/docker/my-dojo
sudo ./dojo.sh stop
sudo rm -rf /mnt/usb/docker/volumes/my-dojo_data-bitcoind/_data/chainstate
sudo rm -rf /mnt/usb/docker/volumes/my-dojo_data-bitcoind/_data/blocks
sudo mv -v /mnt/usb/system-setup-salvage/chainstate /mnt/usb/docker/volumes/my-dojo_data-bitcoind/_data/
sudo mv -v /mnt/usb/system-setup-salvage/blocks /mnt/usb/docker/volumes/my-dojo_data-bitcoind/_data/
# press to continue is needed because sudo password can be requested for next steps
# if the user is AFK there may be timeout
cd "$DOJO_PATH" || exit
./dojo.sh stop
sudo rm -rf /mnt/usb/docker/volumes/my-dojo_data-bitcoind/_data/{blocks,chainstate}
sudo mv -v /mnt/usb/system-setup-salvage/{blocks,chainstate} /mnt/usb/docker/volumes/my-dojo_data-bitcoind/_data/
# changes to dojo path, otherwise exit
# websearch "bash Logical OR (||)" for info
# stops dojo and removes new data directories
# then moves salvaged block data
echo -e "${RED}"
echo "***"
echo "Blockchain data salvage complete!"
echo "***"
echo -e "${NC}"
sleep 3s
sudo rm -rf /mnt/usb/system-setup-salvage/chainstate
sudo rm -rf /mnt/usb/system-setup-salvage/blocks
sudo chown -R 1105:1108 /mnt/usb/docker/volumes/my-dojo_data-bitcoind/_data/
sudo chmod 700 /mnt/usb/docker/volumes/my-dojo_data-bitcoind/_data/chainstate
sudo chmod 700 /mnt/usb/docker/volumes/my-dojo_data-bitcoind/_data/blocks
sudo rm -rf /mnt/usb/system-setup-salvage/
sudo rm -rf /mnt/usb/uninstall-salvage/
sudo ./dojo.sh start
else
echo "No Blockchain data found for salvage check 2..."
_sleep 3
sudo rm -rf /mnt/usb/{system-setup-salvage,uninstall-salvage}
# remove old salvage directories
cd "$DOJO_PATH" || exit
./dojo.sh start
# start dojo
fi
# check for system-setup-salvage, if not found continue
echo -e "${RED}"
echo "***"
echo "Whirlpool is ready to be installed!"
echo "***"
echo -e "${NC}"
sleep 3s
# will continue to whirlpool install, if it was selected from the install menu
#!/bin/bash
# shellcheck source=/dev/null disable=1004
RPC_USER=$(sudo cat ~/dojo/docker/my-dojo/conf/docker-bitcoind.conf.tpl | grep BITCOIND_RPC_USER= | cut -c 19-)
RPC_PASS=$(sudo cat ~/dojo/docker/my-dojo/conf/docker-bitcoind.conf.tpl | grep BITCOIND_RPC_PASSWORD= | cut -c 23-)
. "$HOME"/RoninDojo/Scripts/defaults.sh
###### Modify docker-indexer.conf.tpl to turn ON indexer ######
sudo sed -i '9d' ~/dojo/docker/my-dojo/conf/docker-indexer.conf.tpl
sudo sed -i '9i INDEXER_INSTALL=on' ~/dojo/docker/my-dojo/conf/docker-indexer.conf.tpl
RPC_USER=$(sudo grep BITCOIND_RPC_USER= "${DOJO_PATH}"/conf/docker-bitcoind.conf.tpl | cut -d '=' -f2)
RPC_PASS=$(sudo grep BITCOIND_RPC_PASSWORD= "${DOJO_PATH}"/conf/docker-bitcoind.conf.tpl | cut -d '=' -f2)
###### Modify docker-node.conf to select local_indexer ######
sudo sed -i '25d' ~/dojo/docker/my-dojo/conf/docker-node.conf.tpl
sudo sed -i '25i NODE_ACTIVE_INDEXER=local_indexer' ~/dojo/docker/my-dojo/conf/docker-node.conf.tpl
sudo sed -i 's/INDEXER_INSTALL=off/INDEXER_INSTALL=on/' "${DOJO_PATH}"/conf/docker-indexer.conf.tpl
sudo sed -i 's/NODE_ACTIVE_INDEXER=bitcoind/NODE_ACTIVE_INDEXER=local_indexer/' "${DOJO_PATH}"/conf/docker-node.conf.tpl
# modify docker-indexer.conf.tpl to turn ON indexer then select local_indexer
###### Create electrs.toml for Electrs Dockerfile ######
# use EOF to put lines one after another
touch ~/dojo/docker/my-dojo/indexer/electrs.toml
chmod 600 ~/dojo/docker/my-dojo/indexer/electrs.toml || exit 1
cat > ~/dojo/docker/my-dojo/indexer/electrs.toml <<EOF
cat > "${DOJO_PATH}"/indexer/electrs.toml <<EOF
cookie = "$RPC_USER:$RPC_PASS"
server_banner = "Welcome to your RoninDojo Electrs Server!"
EOF
###### Modify tor/restart.sh for Electrs HiddenService ######
chmod 600 "${DOJO_PATH}"/indexer/electrs.toml || exit 1
# create electrs.toml for electrs dockerfile
sudo sed -i '/\if \[ "\$EXPLORER_INSTALL\" \=\= \"on\" \]\; then/i\
if [ "$INDEXER_INSTALL" == "on" ]; then\
\ tor_options+=(--HiddenServiceDir /var/lib/tor/hsv3electrs)\
\ tor_options+=(--HiddenServiceVersion 3)\
\ tor_options+=(--HiddenServicePort "50001 172.28.1.6:50001")\
\ tor_options+=(--HiddenServiceDirGroupReadable 1)\
fi\
' "${DOJO_PATH}"/tor/restart.sh
# modify tor/restart.sh for electrs hidden service
# using the backslash \ along with sed insert command so that the spaces are not ignored
sudo sed -i '27G' ~/dojo/docker/my-dojo/tor/restart.sh
sudo sed -i '28i if [ "$INDEXER_INSTALL" == "on" ]; then' ~/dojo/docker/my-dojo/tor/restart.sh
sudo sed -i '29i \ tor_options+=(--HiddenServiceDir /var/lib/tor/hsv3electrs)' ~/dojo/docker/my-dojo/tor/restart.sh
sudo sed -i '30i \ tor_options+=(--HiddenServiceVersion 3)' ~/dojo/docker/my-dojo/tor/restart.sh
sudo sed -i '31i \ tor_options+=(--HiddenServicePort "50001 172.28.1.6:50001")' ~/dojo/docker/my-dojo/tor/restart.sh
sudo sed -i '32i \ tor_options+=(--HiddenServiceDirGroupReadable 1)' ~/dojo/docker/my-dojo/tor/restart.sh
sudo sed -i '33i fi' ~/dojo/docker/my-dojo/tor/restart.sh
# we append everything above the EXPLORER if statement
###### Add indexer to tor section of docker-compose.yaml ######
sudo sed -i '/docker-tor.conf/i\ - ./conf/docker-indexer.conf' "${DOJO_PATH}"/docker-compose.yaml
# add indexer to tor section of docker-compose.yaml
# using the backslash \ along with sed insert command so that the spaces are not ignored
sudo sed -i '80i \ - ./conf/docker-indexer.conf' ~/dojo/docker/my-dojo/docker-compose.yaml
###### Modify dojo.sh for electrs ######
# using the backslash \ along with sed insert command so that the spaces are not ignored
sudo sed -i '273i \ if [ "$INDEXER_INSTALL" == "on" ]; then' ~/dojo/docker/my-dojo/dojo.sh
sudo sed -i '274i \ V3_ADDR_ELECTRS=$( docker exec -it tor cat /var/lib/tor/hsv3electrs/hostname )' ~/dojo/docker/my-dojo/dojo.sh
sudo sed -i '275i \ echo "Electrs hidden service address (v3) = $V3_ADDR_ELECTRS"' ~/dojo/docker/my-dojo/dojo.sh
sudo sed -i '276i \ fi' ~/dojo/docker/my-dojo/dojo.sh
sudo sed -i '276G' ~/dojo/docker/my-dojo/dojo.sh
###### Modify indexer/restart.sh for Electrs ######
sudo sed -i '/onion() {/a\
\ if [ "$INDEXER_INSTALL" == "on" ]; then\
\ V3_ADDR_ELECTRS=$( docker exec -it tor cat /var/lib/tor/hsv3electrs/hostname )\
\ echo "Electrs hidden service address (v3) = $V3_ADDR_ELECTRS"\
\ fi\
' "${DOJO_PATH}"/dojo.sh
# modify dojo.sh for electrs
# using the backslash \ along with sed insert command so that the spaces are not ignored
sudo sed -i '9d' ~/dojo/docker/my-dojo/indexer/restart.sh
sudo sed -i '9i \ --electrum-rpc-addr="172.28.1.6:50001"' ~/dojo/docker/my-dojo/indexer/restart.sh
sudo sed -i '11d' ~/dojo/docker/my-dojo/indexer/restart.sh
sudo sed -i '21i electrs "${indexer_options[@]}"' ~/dojo/docker/my-dojo/indexer/restart.sh
sudo sed -i '22d' ~/dojo/docker/my-dojo/indexer/restart.sh
sudo sed -i \
-e 's/--indexer-rpc-addr=.*$/--electrum-rpc-addr="172.28.1.6:50001"/' \
-e '/--cookie=.*$/d' \
-e 's/^addrindexrs .*$/electrs "${indexer_options[@]}"/' "${DOJO_PATH}"/indexer/restart.sh
# modify indexer/restart.sh for electrs
###### Modify Indexer Dockerfile to Electrs ######
sudo rm -rf ~/dojo/docker/my-dojo/indexer/Dockerfile
cd ~/dojo/docker/my-dojo/indexer
wget https://code.samourai.io/Ronin/samourai-dojo/raw/feat_mydojo_local_indexer/docker/my-dojo/indexer/Dockerfile
wget -O "${DOJO_PATH}"/indexer/Dockerfile https://code.samourai.io/Ronin/samourai-dojo/raw/feat_mydojo_local_indexer/docker/my-dojo/indexer/Dockerfile
# replace indexer dockerfile for electrs usage
#!/bin/bash
RED='\033[0;31m'
# used for color with ${RED}
YELLOW='\033[1;33m'
# used for color with ${YELLOW}
NC='\033[0m'
# No Color
USER=$(sudo cat /etc/passwd | grep 1000 | awk -F: '{ print $1}' | cut -c 1-)
echo -e "${RED}"