mirror of
https://github.com/rootzoll/raspiblitz.git
synced 2025-02-24 14:51:03 +01:00
add BTC-RPC-Explorer and update RTL (#867)
Separated the NodeJS install script. Update RTL to v0.5.4 and added automatic Hidden Service setup if Tor Active * add install script for BTC-RPC-Explorer * sets up a Hidden Service automatically * supports Electrs to look up addresses if installed * added a small script to enable txindex (needed for BTC-RPC-Explorer) Detailed changes: * nodeJS: add separate install script * RTL: add Tor support and update * BTC-RPC-Explorer: add install script * btc-rpc-explorer: add script to activate txindex * RTL: restart service if already installed * RTL: opt out of data collection, start if installed * rtl,btc-rpc-exp: Tor to forward to port 80 * btc-rpc-exp: add to SERVICES menu
This commit is contained in:
parent
ff18754707
commit
bf480bd721
5 changed files with 481 additions and 91 deletions
|
@ -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
|
||||
|
|
220
home.admin/config.scripts/bonus.btc-rpc-explorer.sh
Normal file
220
home.admin/config.scripts/bonus.btc-rpc-explorer.sh
Normal file
|
@ -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 <<EOF
|
||||
# Host/Port to bind to
|
||||
# Defaults: shown
|
||||
BTCEXP_HOST=0.0.0.0
|
||||
#BTCEXP_PORT=3002
|
||||
# Bitcoin RPC Credentials (URI -OR- HOST/PORT/USER/PASS)
|
||||
# Defaults:
|
||||
# - [host/port]: 127.0.0.1:8332
|
||||
# - [username/password]: none
|
||||
# - cookie: '~/.bitcoin/.cookie'
|
||||
# - timeout: 5000 (ms)
|
||||
BTCEXP_BITCOIND_URI=bitcoin://$RPC_USER:$PASSWORD_B@127.0.0.1:8332?timeout=10000
|
||||
#BTCEXP_BITCOIND_HOST=127.0.0.1
|
||||
#BTCEXP_BITCOIND_PORT=8332
|
||||
BTCEXP_BITCOIND_USER=$RPC_USER
|
||||
BTCEXP_BITCOIND_PASS=$PASSWORD_B
|
||||
#BTCEXP_BITCOIND_COOKIE=/path/to/bitcoind/.cookie
|
||||
BTCEXP_BITCOIND_RPC_TIMEOUT=5000
|
||||
# Password protection for site via basic auth (enter any username, only the password is checked)
|
||||
# Default: none
|
||||
BTCEXP_BASIC_AUTH_PASSWORD=$PASSWORD_B
|
||||
# Select optional "address API" to display address tx lists and balances
|
||||
# Options: electrumx, blockchain.com, blockchair.com, blockcypher.com
|
||||
# If electrumx set, the BTCEXP_ELECTRUMX_SERVERS variable must also be
|
||||
# set.
|
||||
# Default: none
|
||||
# BTCEXP_ADDRESS_API=electrumx
|
||||
# BTCEXP_ELECTRUMX_SERVERS=tcp://127.0.0.1:50001
|
||||
EOF
|
||||
sudo mv /home/admin/btc-rpc-explorer.env /home/bitcoin/.config/btc-rpc-explorer.env
|
||||
sudo chown bitcoin:bitcoin /home/bitcoin/.config/btc-rpc-explorer.env
|
||||
|
||||
# open firewall
|
||||
echo "*** Updating Firewall ***"
|
||||
sudo ufw allow 3002
|
||||
sudo ufw --force enable
|
||||
echo ""
|
||||
|
||||
# install service
|
||||
echo "*** Install btc-rpc-explorer systemd ***"
|
||||
cat > /home/admin/btc-rpc-explorer.service <<EOF
|
||||
# systemd unit for BTC RPC Explorer
|
||||
|
||||
[Unit]
|
||||
Description=btc-rpc-explorer
|
||||
Wants=bitcoind.service
|
||||
After=bitcoind.service
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/local/lib/nodejs/node-$(node -v)-$DISTRO/bin/btc-rpc-explorer
|
||||
User=bitcoin
|
||||
Restart=always
|
||||
TimeoutSec=120
|
||||
RestartSec=30
|
||||
StandardOutput=null
|
||||
StandardError=journal
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
sudo mv /home/admin/btc-rpc-explorer.service /etc/systemd/system/btc-rpc-explorer.service
|
||||
sudo systemctl enable btc-rpc-explorer
|
||||
echo "OK - the BTC-RPC-explorer service is now enabled"
|
||||
|
||||
else
|
||||
echo "BTC-RPC-explorer already installed."
|
||||
fi
|
||||
|
||||
# Enable BTCEXP_ADDRESS_API if electrs is active
|
||||
if [ $(sudo -u bitcoin lsof -i | grep -c 50001) -eq 1 ]; then
|
||||
echo "electrs is active - switching support on"
|
||||
sudo -u bitcoin sed -i '/BTCEXP_ADDRESS_API=electrumx/s/^#//g' /home/bitcoin/.config/btc-rpc-explorer.env
|
||||
sudo -u bitcoin sed -i '/BTCEXP_ELECTRUMX_SERVERS=/s/^#//g' /home/bitcoin/.config/btc-rpc-explorer.env
|
||||
else
|
||||
echo "electrs is not active - switching support off"
|
||||
sudo -u bitcoin sed -i '/BTCEXP_ADDRESS_API=electrumx/s/^/#/g' /home/bitcoin/.config/btc-rpc-explorer.env
|
||||
sudo -u bitcoin sed -i '/BTCEXP_ELECTRUMX_SERVERS=/s/^/#/g' /home/bitcoin/.config/btc-rpc-explorer.env
|
||||
fi
|
||||
|
||||
# start service
|
||||
echo "Starting service"
|
||||
sudo systemctl start btc-rpc-explorer 2>/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
|
96
home.admin/config.scripts/bonus.nodejs.sh
Normal file
96
home.admin/config.scripts/bonus.nodejs.sh
Normal file
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
40
home.admin/config.scripts/network.txindex.sh
Normal file
40
home.admin/config.scripts/network.txindex.sh
Normal file
|
@ -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
|
Loading…
Add table
Reference in a new issue