#!/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 [status|on|off]" exit 1 fi # add default value to raspi config if needed source /mnt/hdd/raspiblitz.conf if [ ${#BTCRPCexplorer} -eq 0 ]; then echo "BTCRPCexplorer=off" >> /mnt/hdd/raspiblitz.conf source /mnt/hdd/raspiblitz.conf fi # status if [ "$1" = "status" ]; then if [ "${BTCRPCexplorer}" = "on" ]; then echo "configured=1" # check indexing source <(sudo /home/admin/config.scripts/network.txindex.sh status) echo "isIndexed=${isIndexed}" echo "indexInfo='${indexInfo}'" else echo "configured=0" fi exit 0 fi # 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 # 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 # make sure that txindex of blockchain is switched on /home/admin/config.scripts/network.txindex.sh on npm install -g btc-rpc-explorer@1.1.3 # prepare .env file echo "getting RPC credentials from the ${network}.conf" RPC_USER=$(sudo cat /mnt/hdd/${network}/${network}.conf | grep rpcuser | cut -c 9-) PASSWORD_B=$(sudo cat /mnt/hdd/${network}/${network}.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 <