diff --git a/home.admin/00settingsMenuServices.sh b/home.admin/00settingsMenuServices.sh index f305b9a3e..0c992657d 100644 --- a/home.admin/00settingsMenuServices.sh +++ b/home.admin/00settingsMenuServices.sh @@ -10,6 +10,7 @@ if [ ${#autoPilot} -eq 0 ]; then autoPilot="off"; fi if [ ${#autoUnlock} -eq 0 ]; then autoUnlock="off"; fi if [ ${#runBehindTor} -eq 0 ]; then runBehindTor="off"; fi if [ ${#rtlWebinterface} -eq 0 ]; then rtlWebinterface="off"; fi +if [ ${#BTCRPCexplorer} -eq 0 ]; then BTCRPCexplorer="off"; fi if [ ${#chain} -eq 0 ]; then chain="main"; fi if [ ${#autoNatDiscovery} -eq 0 ]; then autoNatDiscovery="off"; fi if [ ${#networkUPnP} -eq 0 ]; then networkUPnP="off"; fi @@ -52,23 +53,25 @@ fi echo "run dialog ..." if [ "${runBehindTor}" = "on" ]; then -CHOICES=$(dialog --title ' Additional Services ' --checklist ' use spacebar to activate/de-activate ' 15 45 8 \ -1 'Channel Autopilot' ${autoPilot} \ -2 'Testnet' ${chainValue} \ -3 ${dynDomainMenu} ${domainValue} \ -4 'Run behind TOR' ${runBehindTor} \ -5 'RTL Webinterface' ${rtlWebinterface} \ -6 'LND Auto-Unlock' ${autoUnlock} \ -9 'Touchscreen' ${tochscreenMenu} \ -r 'LCD Rotate' ${lcdrotateMenu} \ -2>&1 >/dev/tty) -else CHOICES=$(dialog --title ' Additional Services ' --checklist ' use spacebar to activate/de-activate ' 16 45 9 \ 1 'Channel Autopilot' ${autoPilot} \ 2 'Testnet' ${chainValue} \ 3 ${dynDomainMenu} ${domainValue} \ 4 'Run behind TOR' ${runBehindTor} \ 5 'RTL Webinterface' ${rtlWebinterface} \ +b 'BTC-RPC-Explorer' ${BTCRPCexplorer} \ +6 'LND Auto-Unlock' ${autoUnlock} \ +9 'Touchscreen' ${tochscreenMenu} \ +r 'LCD Rotate' ${lcdrotateMenu} \ +2>&1 >/dev/tty) +else +CHOICES=$(dialog --title ' Additional Services ' --checklist ' use spacebar to activate/de-activate ' 17 45 10 \ +1 'Channel Autopilot' ${autoPilot} \ +2 'Testnet' ${chainValue} \ +3 ${dynDomainMenu} ${domainValue} \ +4 'Run behind TOR' ${runBehindTor} \ +5 'RTL Webinterface' ${rtlWebinterface} \ +b 'BTC-RPC-Explorer' ${BTCRPCexplorer} \ 6 'LND Auto-Unlock' ${autoUnlock} \ 7 'BTC UPnP (AutoNAT)' ${networkUPnP} \ 8 'LND UPnP (AutoNAT)' ${autoNatDiscovery} \ @@ -266,28 +269,84 @@ if [ ${check} -eq 1 ]; then choice="on"; fi if [ "${rtlWebinterface}" != "${choice}" ]; then echo "RTL Webinterface Setting changed .." anychange=1 - sudo /home/admin/config.scripts/bonus.rtl.sh ${choice} + /home/admin/config.scripts/bonus.rtl.sh ${choice} errorOnInstall=$? if [ "${choice}" = "on" ]; then if [ ${errorOnInstall} -eq 0 ]; then localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/') - l1="RTL web service will be ready AFTER NEXT REBOOT:" - l2="Try to open the following URL in your local web browser" - l3="and login with your PASSWORD B." - l4="---> http://${localip}:3000" - dialog --title 'OK' --msgbox "${l1}\n${l2}\n${l3}\n${l4}" 11 65 + if [ "${runBehindTor}" = "on" ]; then + TOR_ADDRESS=$(sudo cat /mnt/hdd/tor/RTL/hostname) + l1="Open the following URL in your local web browser" + l2="and login with your PASSWORD B." + l3="---> http://${localip}:3000" + l4="" + l5="The Hidden Service address to be used in the Tor Browser:" + l6="${TOR_ADDRESS}" + dialog --title 'OK' --msgbox "${l1}\n${l2}\n${l3}\n${l4}\n${l5}\n${l6}" 11 66 + else + l1="Open the following URL in your local web browser" + l2="and login with your PASSWORD B." + l3="---> http://${localip}:3000" + dialog --title 'OK' --msgbox "${l1}\n${l2}\n${l3}\n${l4}" 7 65 + fi else l1="!!! FAIL on RTL install !!!" - l2="Try manual install on terminal after rebootwith:" - l3="sudo /home/admin/config.scripts/bonus.rtl.sh on" - dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 10 65 + l2="Try manual install on terminal after reboot with:" + l3="/home/admin/config.scripts/bonus.rtl.sh on" + dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65 fi fi - needsReboot=1 + needsReboot=0 else echo "RTL Webinterface Setting unchanged." fi +# BTC-RPC-Explorer process choice +choice="off"; check=$(echo "${CHOICES}" | grep -c "b") +if [ ${check} -eq 1 ]; then choice="on"; fi +if [ "${BTCRPCexplorer}" != "${choice}" ]; then + echo "RTL Webinterface Setting changed .." + anychange=1 + /home/admin/config.scripts/bonus.btc-rpc-explorer.sh ${choice} + errorOnInstall=$? + if [ "${choice}" = "on" ]; then + if [ ${errorOnInstall} -eq 0 ]; then + localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/') + if [ "${runBehindTor}" = "on" ]; then + TOR_ADDRESS=$(sudo cat /mnt/hdd/tor/btc-rpc-explorer/hostname) + l1="The txindex needs to be created before BTC-RPC-Explorer can be active" + l2="Takes ~7 h on a RPi4 with SSD. Monitor with:" + l3="'sudo tail -f -n 100 -f /mnt/hdd/bitcoin/debug.log | grep txindex'" + l4="" + l5="Open the following URL in your local web browser" + l6="To login leave the username empty and use your PASSWORD B" + l7="---> http://${localip}:3002" + l8="" + l9="The Hidden Service address to be used in the Tor Browser:" + l10="${TOR_ADDRESS}" + dialog --title 'OK' --msgbox "${l1}\n${l2}\n${l3}\n${l4}\n${l5}\n${l6}\n${l7}\n${l8}\n${l9}\n${l10}" 15 75 + else + l1="The txindex needs to be created before BTC-RPC-Explorer can be active" + l2="Takes ~7 h on a RPi4 with SSD. Monitor with:" + l3="'sudo tail -f -n 100 -f /mnt/hdd/bitcoin/debug.log | grep txindex'" + l4="" + l5="When finished open the following URL in your local web browser" + l6="To login leave the username empty and use your PASSWORD B" + l7="---> http://${localip}:3002" + dialog --title 'OK' --msgbox "${l1}\n${l2}\n${l3}\n${l4}\n${l5}\n${l6}\n${l7}" 11 75 + fi + else + l1="!!! FAIL on BTC-RPC-Explorer install !!!" + l2="Try manual install on terminal after reboot with:" + l3="/home/admin/config.scripts/bonus.btc-rpc-explorer.sh on" + dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 7 65 + fi + fi + needsReboot=0 +else + echo "BTC-RPC-Explorer Setting unchanged." +fi + # LND Auto-Unlock choice="off"; check=$(echo "${CHOICES}" | grep -c "6") if [ ${check} -eq 1 ]; then choice="on"; fi diff --git a/home.admin/config.scripts/bonus.btc-rpc-explorer.sh b/home.admin/config.scripts/bonus.btc-rpc-explorer.sh new file mode 100644 index 000000000..e6e9e1614 --- /dev/null +++ b/home.admin/config.scripts/bonus.btc-rpc-explorer.sh @@ -0,0 +1,220 @@ +#!/bin/bash + +# https://github.com/janoside/btc-rpc-explorer +# ~/.config/btc-rpc-explorer.env +# https://github.com/janoside/btc-rpc-explorer/blob/master/.env-sample + +# command info +if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then + echo "small config script to switch BTC-RPC-explorer on or off" + echo "bonus.btc-rcp-explorer.sh [on|off]" + exit 1 +fi + +source /mnt/hdd/raspiblitz.conf + +# determine nodeJS DISTRO +isARM=$(uname -m | grep -c 'arm') +isAARCH64=$(uname -m | grep -c 'aarch64') +isX86_64=$(uname -m | grep -c 'x86_64') +isX86_32=$(uname -m | grep -c 'i386\|i486\|i586\|i686\|i786') +# get checksums from -> https://nodejs.org/dist/vx.y.z/SHASUMS256.txt +if [ ${isARM} -eq 1 ] ; then +DISTRO="linux-armv7l" +fi +if [ ${isAARCH64} -eq 1 ] ; then +DISTRO="linux-arm64" +fi +if [ ${isX86_64} -eq 1 ] ; then +DISTRO="linux-x64" +fi +if [ ${isX86_32} -eq 1 ] ; then +echo "FAIL: No X86 32bit build available - will abort setup" +exit 1 +fi +if [ ${#DISTRO} -eq 0 ]; then +echo "FAIL: Was not able to determine architecture" +exit 1 +fi + +# add default value to raspi config if needed +if [ ${#BTCRPCexplorer} -eq 0 ]; then + echo "BTCRPCexplorer=off" >> /mnt/hdd/raspiblitz.conf +fi + +# stop service +echo "making sure services are not running" +sudo systemctl stop btc-rpc-explorer 2>/dev/null + +# switch on +if [ "$1" = "1" ] || [ "$1" = "on" ]; then + echo "*** INSTALL BTC-RPC-EXPLORER ***" + + isInstalled=$(sudo ls /etc/systemd/system/btc-rpc-explorer.service 2>/dev/null | grep -c 'btc-rpc-explorer.service') + if [ ${isInstalled} -eq 0 ]; then + + # install nodeJS + /home/admin/config.scripts/bonus.nodejs.sh + + /home/admin/config.scripts/network.txindex.sh on + + npm install -g btc-rpc-explorer + + # prepare .env file + echo "getting RPC credentials from the bitcoin.conf" + + RPC_USER=$(sudo cat /mnt/hdd/bitcoin/bitcoin.conf | grep rpcuser | cut -c 9-) + PASSWORD_B=$(sudo cat /mnt/hdd/bitcoin/bitcoin.conf | grep rpcpassword | cut -c 13-) + + sudo -u bitcoin mkdir /home/bitcoin/.config/ 2>/dev/null + touch /home/admin/btc-rpc-explorer.env + chmod 600 /home/admin/btc-rpc-explorer.env || exit 1 + cat > /home/admin/btc-rpc-explorer.env < /home/admin/btc-rpc-explorer.service </dev/null + + # setting value in raspi blitz config + sudo sed -i "s/^BTCRPCexplorer=.*/BTCRPCexplorer=on/g" /mnt/hdd/raspiblitz.conf + + echo "needs to finish creating txindex to be functional" + echo "monitor with: sudo tail -n 20 -f /mnt/hdd/bitcoin/debug.log" + + # Hidden Service for BTC-RPC-explorer if Tor is active + source /mnt/hdd/raspiblitz.conf + if [ "${runBehindTor}" = "on" ]; then + isBtcRpcExplorerTor=$(sudo cat /etc/tor/torrc 2>/dev/null | grep -c 'btc-rpc-explorer') + if [ ${isBtcRpcExplorerTor} -eq 0 ]; then + echo " +# Hidden Service for BTC-RPC-explorer +HiddenServiceDir /mnt/hdd/tor/btc-rpc-explorer +HiddenServiceVersion 3 +HiddenServicePort 80 127.0.0.1:3002 + " | sudo tee -a /etc/tor/torrc + + sudo systemctl restart tor + sleep 2 + else + echo "The Hidden Service is already installed" + fi + TOR_ADDRESS=$(sudo cat /mnt/hdd/tor/btc-rpc-explorer/hostname) + if [ -z "$TOR_ADDRESS" ]; then + echo "Waiting for the Hidden Service" + sleep 10 + TOR_ADDRESS=$(sudo cat /mnt/hdd/tor/btc-rpc-explorer/hostname) + if [ -z "$TOR_ADDRESS" ]; then + echo " FAIL - The Hidden Service address could not be found - Tor error?" + exit 1 + fi + fi + echo "" + echo "***" + echo "The Tor Hidden Service address for btc-rpc-explorer is:" + echo "$TOR_ADDRESS" + echo "***" + echo "" + fi + exit 0 +fi + +# switch off +if [ "$1" = "0" ] || [ "$1" = "off" ]; then + + # setting value in raspi blitz config + sudo sed -i "s/^BTCRPCexplorer=.*/BTCRPCexplorer=off/g" /mnt/hdd/raspiblitz.conf + + isInstalled=$(sudo ls /etc/systemd/system/btc-rpc-explorer.service 2>/dev/null | grep -c 'btc-rpc-explorer.service') + if [ ${isInstalled} -eq 1 ]; then + echo "*** REMOVING BTC-RPC-explorer ***" + sudo systemctl stop btc-rpc-explorer + sudo systemctl disable btc-rpc-explorer + sudo rm /etc/systemd/system/btc-rpc-explorer.service + sudo rm -r /usr/local/lib/nodejs/node-$(node -v)-$DISTRO/bin/btc-rpc-explorer + echo "OK BTC-RPC-explorer removed." + else + echo "BTC-RPC-explorer is not installed." + fi + exit 0 +fi + +echo "FAIL - Unknown Parameter $1" +exit 1 \ No newline at end of file diff --git a/home.admin/config.scripts/bonus.nodejs.sh b/home.admin/config.scripts/bonus.nodejs.sh new file mode 100644 index 000000000..33eb22508 --- /dev/null +++ b/home.admin/config.scripts/bonus.nodejs.sh @@ -0,0 +1,96 @@ +#!/bin/bash + +# command info +if [ "$1" = "-h" ] || [ "$1" = "-help" ]; then + echo "small config script to install NodeJs" + echo "bonus.nodejs.sh" + exit 1 +fi + +source /mnt/hdd/raspiblitz.conf + +# add default value to raspi config if needed +if [ ${#nodeJS} -eq 0 ]; then + echo "nodeJS=off" >> /mnt/hdd/raspiblitz.conf +fi + +# check if nodeJS was installed +nodeJSInstalled=$(node -v | grep -c "v1.") +if [ ${nodeJSInstalled} -eq 0 ]; then + + # determine nodeJS VERSION and DISTRO + echo "Detect CPU architecture ..." + isARM=$(uname -m | grep -c 'arm') + isAARCH64=$(uname -m | grep -c 'aarch64') + isX86_64=$(uname -m | grep -c 'x86_64') + isX86_32=$(uname -m | grep -c 'i386\|i486\|i586\|i686\|i786') + VERSION="v10.16.0" + + # get checksums from -> https://nodejs.org/dist/vx.y.z/SHASUMS256.txt + if [ ${isARM} -eq 1 ] ; then + DISTRO="linux-armv7l" + CHECKSUM="3a3710722a1ce49b4c72c4af3155041cce3c4f632260ec8533be3fc7fd23f92c" + fi + if [ ${isAARCH64} -eq 1 ] ; then + DISTRO="linux-arm64" + CHECKSUM="ae2e74ab2f5dbff96bf0b7d8457004bf3538233916f8834740bbe2d5a35442e5" + fi + if [ ${isX86_64} -eq 1 ] ; then + DISTRO="linux-x64" + CHECKSUM="1827f5b99084740234de0c506f4dd2202a696ed60f76059696747c34339b9d48" + fi + if [ ${isX86_32} -eq 1 ] ; then + echo "FAIL: No X86 32bit build available - will abort setup" + exit 1 + fi + if [ ${#DISTRO} -eq 0 ]; then + echo "FAIL: Was not able to determine architecture" + exit 1 + fi + echo "VERSION: ${VERSION}" + echo "DISTRO: ${DISTRO}" + echo "CHECKSUM: ${CHECKSUM}" + echo "" + + # install latest nodejs + # https://github.com/nodejs/help/wiki/Installation + echo "*** Install NodeJS $VERSION-$DISTRO ***" + + # download + wget https://nodejs.org/dist/$VERSION/node-$VERSION-$DISTRO.tar.xz + # checksum + isChecksumValid=$(sha256sum node-$VERSION-$DISTRO.tar.xz | grep -c "${CHECKSUM}") + if [ ${isChecksumValid} -eq 0 ]; then + echo "FAIL: The checksum of node-$VERSION-$DISTRO.tar.xz is NOT ${CHECKSUM}" + exit 1 + fi + echo "OK CHECKSUM of nodeJS is OK" + sleep 3 + + # install + sudo mkdir -p /usr/local/lib/nodejs + sudo tar -xJvf node-$VERSION-$DISTRO.tar.xz -C /usr/local/lib/nodejs + export PATH=/usr/local/lib/nodejs/node-$VERSION-$DISTRO/bin:$PATH + sudo ln -s /usr/local/lib/nodejs/node-$VERSION-$DISTRO/bin/node /usr/bin/node + sudo ln -s /usr/local/lib/nodejs/node-$VERSION-$DISTRO/bin/npm /usr/bin/npm + sudo ln -s /usr/local/lib/nodejs/node-$VERSION-$DISTRO/bin/npx /usr/bin/npx + # add to PATH permanently + sudo bash -c "echo 'PATH=\$PATH:/usr/local/lib/nodejs/node-\$VERSION-\$DISTRO/bin/' >> /etc/profile" + echo "" + + # check if nodeJS was installed + nodeJSInstalled=$(node -v | grep -c "v1.") + if [ ${nodeJSInstalled} -eq 0 ]; then + echo "FAIL - Was not able to install nodeJS" + echo "ABORT - nodeJs install" + exit 1 + fi +else + echo "nodeJS is already installed" +fi + +# setting value in raspi blitz config +sudo sed -i "s/^nodeJS=.*/nodeJS=on/g" /mnt/hdd/raspiblitz.conf +echo "Installed nodeJS $(node -v)" +exit 0 + diff --git a/home.admin/config.scripts/bonus.rtl.sh b/home.admin/config.scripts/bonus.rtl.sh index 35f036489..011b9f3b4 100755 --- a/home.admin/config.scripts/bonus.rtl.sh +++ b/home.admin/config.scripts/bonus.rtl.sh @@ -32,78 +32,15 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then isInstalled=$(sudo ls /etc/systemd/system/RTL.service 2>/dev/null | grep -c 'RTL.service') if [ ${isInstalled} -eq 0 ]; then - # determine nodeJS VERSION and DISTRO - echo "Detect CPU architecture ..." - isARM=$(uname -m | grep -c 'arm') - isAARCH64=$(uname -m | grep -c 'aarch64') - isX86_64=$(uname -m | grep -c 'x86_64') - isX86_32=$(uname -m | grep -c 'i386\|i486\|i586\|i686\|i786') - VERSION="v10.16.0" - # get checksums from -> https://nodejs.org/dist/vx.y.z/SHASUMS256.txt - if [ ${isARM} -eq 1 ] ; then - DISTRO="linux-armv7l" - CHECKSUM="3a3710722a1ce49b4c72c4af3155041cce3c4f632260ec8533be3fc7fd23f92c" - fi - if [ ${isAARCH64} -eq 1 ] ; then - DISTRO="linux-arm64" - CHECKSUM="ae2e74ab2f5dbff96bf0b7d8457004bf3538233916f8834740bbe2d5a35442e5" - fi - if [ ${isX86_64} -eq 1 ] ; then - DISTRO="linux-x64" - CHECKSUM="1827f5b99084740234de0c506f4dd2202a696ed60f76059696747c34339b9d48" - fi - if [ ${isX86_32} -eq 1 ] ; then - echo "FAIL: No X86 32bit build available - will abort setup" - exit 1 - fi - if [ ${#DISTRO} -eq 0 ]; then - echo "FAIL: Was not able to determine architecture" - exit 1 - fi - echo "VERSION: ${VERSION}" - echo "DISTRO: ${DISTRO}" - echo "CHECKSUM: ${CHECKSUM}" - echo "" - - # install latest nodejs - # https://github.com/nodejs/help/wiki/Installation - echo "*** Install NodeJS $VERSION-$DISTRO ***" - - # download - wget https://nodejs.org/dist/$VERSION/node-$VERSION-$DISTRO.tar.xz - - # checksum - isChecksumValid=$(sha256sum node-$VERSION-$DISTRO.tar.xz | grep -c "${CHECKSUM}") - if [ ${isChecksumValid} -eq 0 ]; then - echo "FAIL: The checksum of node-$VERSION-$DISTRO.tar.xz is NOT ${CHECKSUM}" - exit 1 - fi - echo "OK CHECKSUM of nodeJS is OK" - sleep 3 - - # install - sudo mkdir -p /usr/local/lib/nodejs - sudo tar -xJvf node-$VERSION-$DISTRO.tar.xz -C /usr/local/lib/nodejs - export PATH=/usr/local/lib/nodejs/node-$VERSION-$DISTRO/bin:$PATH - sudo ln -s /usr/local/lib/nodejs/node-$VERSION-$DISTRO/bin/node /usr/bin/node - sudo ln -s /usr/local/lib/nodejs/node-$VERSION-$DISTRO/bin/npm /usr/bin/npm - sudo ln -s /usr/local/lib/nodejs/node-$VERSION-$DISTRO/bin/npx /usr/bin/npx - echo "" - - # check if nodeJS was installed - nodeJSInstalled=$(node -v | grep -c "v1.") - if [ ${nodeJSInstalled} -eq 0 ]; then - echo "FAIL - Was not able to install nodeJS" - echo "ABORT - RTL install" - exit 1 - fi + # check and install NodeJS + /home/admin/config.scripts/bonus.nodejs.sh # download source code and set to tag release echo "*** Get the RTL Source Code ***" rm -r /home/admin/RTL 2>/dev/null git clone https://github.com/ShahanaFarooqui/RTL.git /home/admin/RTL cd /home/admin/RTL - git reset --hard v0.4.2 + git reset --hard v0.5.4 # check if node_modles exists now if [ -d "/home/admin/RTL" ]; then echo "OK - RTL code copy looks good" @@ -117,6 +54,7 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then # install echo "*** Run: npm install ***" + export NG_CLI_ANALYTICS=false npm install cd .. # check if node_modles exists now @@ -149,16 +87,53 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then sudo cp /home/admin/assets/RTL.service /etc/systemd/system/RTL.service sudo sed -i "s|chain/bitcoin/mainnet|chain/${network}/${chain}net|" /etc/systemd/system/RTL.service sudo systemctl enable RTL - echo "OK - RTL is now ACTIVE" + echo "OK - the RTL service is now enabled" else echo "RTL already installed." fi + + # start service + echo "Starting service" + sudo systemctl start RTL 2>/dev/null # setting value in raspi blitz config sudo sed -i "s/^rtlWebinterface=.*/rtlWebinterface=on/g" /mnt/hdd/raspiblitz.conf - echo "needs reboot to activate new setting" + # Hidden Service for RTL if Tor is active + if [ "${runBehindTor}" = "on" ]; then + isRTLTor=$(sudo cat /etc/tor/torrc 2>/dev/null | grep -c 'RTL') + if [ ${isRTLTor} -eq 0 ]; then + echo " +# Hidden Service for RTL +HiddenServiceDir /mnt/hdd/tor/RTL +HiddenServiceVersion 3 +HiddenServicePort 80 127.0.0.1:3000 + " | sudo tee -a /etc/tor/torrc + + sudo systemctl restart tor + sleep 2 + else + echo "The Hidden Service is already installed" + fi + + TOR_ADDRESS=$(sudo cat /mnt/hdd/tor/RTL/hostname) + if [ -z "$TOR_ADDRESS" ]; then + echo "Waiting for the Hidden Service" + sleep 10 + TOR_ADDRESS=$(sudo cat /mnt/hdd/tor/RTL/hostname) + if [ -z "$TOR_ADDRESS" ]; then + echo " FAIL - The Hidden Service address could not be found - Tor error?" + exit 1 + fi + fi + echo "" + echo "***" + echo "The Tor Hidden Service address for RTL is:" + echo "$TOR_ADDRESS" + echo "***" + echo "" + fi exit 0 fi @@ -184,6 +159,6 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then exit 0 fi -echo "FAIL - Unknown Paramter $1" -echo "may needs reboot to run normal again" +echo "FAIL - Unknown Parameter $1" +echo "may need reboot to run normal again" exit 1 diff --git a/home.admin/config.scripts/network.txindex.sh b/home.admin/config.scripts/network.txindex.sh new file mode 100644 index 000000000..91de84bd2 --- /dev/null +++ b/home.admin/config.scripts/network.txindex.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# command info +if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then + echo "config script to switch txindex on or off" + echo "network.txindex.sh [on|off]" + exit 1 +fi + +source /mnt/hdd/bitcoin/bitcoin.conf + +# add default value to bitcoin.conf if needed +if [ ${#txindex} -eq 0 ]; then + echo "txindex=0" >> /mnt/hdd/bitcoin/bitcoin.conf +fi + +# switch on +if [ "$1" = "1" ] || [ "$1" = "on" ]; then + if [ ${txindex} == 0 ]; then + sudo sed -i "s/^txindex=.*/txindex=1/g" /mnt/hdd/bitcoin/bitcoin.conf + echo "switching txindex=1 and restarting bitcoind" + sudo systemctl restart bitcoind + echo "The indexing takes ~7h on an RPi4 with SSD" + echo "monitor with: sudo tail -n 20 -f /mnt/hdd/bitcoin/debug.log" + exit 0 + else + echo "txindex is already active" + exit 0 + fi +fi + +# switch off +if [ "$1" = "0" ] || [ "$1" = "off" ]; then + sudo sed -i "s/^txindex=.*/txindex=0/g" /mnt/hdd/bitcoin/bitcoin.conf + sudo systemctl restart bitcoind + exit 0 +fi + +echo "FAIL - Unknown Parameter $1" +exit 1 \ No newline at end of file