2019-12-11 13:44:29 +00:00
|
|
|
# config script to make BTC-RPC-Explorer use Electrs if both active
|
|
|
|
|
|
|
|
source /mnt/hdd/raspiblitz.conf
|
|
|
|
|
|
|
|
if [ "${BTCRPCexplorer}" = "on" ] & [ "${ElectRS}" = "on" ]; then
|
|
|
|
## Enable BTCEXP_ADDRESS_API if BTC-RPC-Explorer is active
|
|
|
|
if [ $(sudo -u electrs lsof -i | grep -c 50001) -gt 0 ]; then
|
|
|
|
echo "electrs is active - switching address API support on in BTC-RPC-Explorer"
|
2020-03-10 13:11:54 +00:00
|
|
|
sudo -u btcrpcexplorer sed -i 's/^BTCEXP_ADDRESS_API=none/BTCEXP_ADDRESS_API=electrumx/g' /home/btcrpcexplorer/.config/btc-rpc-explorer.env
|
2019-12-11 13:44:29 +00:00
|
|
|
|
2020-03-10 13:11:54 +00:00
|
|
|
# create ExecStart=/home/admin/btc-rpc-explorer.run.sh
|
2019-12-11 13:44:29 +00:00
|
|
|
cat > /home/admin/btc-rpc-explorer.run.sh <<EOF
|
|
|
|
#!/bin/bash
|
|
|
|
echo "Waiting Electrs on port 50001..."
|
|
|
|
while [ $(sudo -u electrs lsof -i | grep -c 50001) -eq 0 ]; do
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
echo "Electrs started, launching BTC-RPC-Explorer..."
|
2020-03-10 13:11:54 +00:00
|
|
|
cd /home/btcrpcexplorer/btc-rpc-explorer
|
|
|
|
sudo -u btcrpcexplorer /usr/bin/npm start
|
2019-12-11 13:44:29 +00:00
|
|
|
EOF
|
2020-03-10 13:11:54 +00:00
|
|
|
sudo chmod +x /home/admin/btc-rpc-explorer.run.sh
|
2019-12-11 13:44:29 +00:00
|
|
|
|
2020-03-10 13:11:54 +00:00
|
|
|
sudo sed -i "s/^ExecStart=\/usr\/bin\/npm start/ExecStart=\/home\/admin\/btc-rpc-explorer.run.sh/g" /etc/systemd/system/btc-rpc-explorer.service
|
|
|
|
sudo sed -i "s/^User=.*/User=admin/g" /etc/systemd/system/btc-rpc-explorer.service
|
2019-12-11 13:44:29 +00:00
|
|
|
sudo systemctl daemon-reload
|
|
|
|
sudo systemctl restart btc-rpc-explorer
|
|
|
|
|
|
|
|
else
|
|
|
|
echo "electrs is not active - switching address API support off in BTC-RPC-Explorer"
|
2020-03-10 13:11:54 +00:00
|
|
|
sudo -u btcrpcexplorer sed -i 's/^BTCEXP_ADDRESS_API=electrumx/BTCEXP_ADDRESS_API=none/g' /home/btcrpcexplorer/.config/btc-rpc-explorer.env
|
2019-12-11 13:44:29 +00:00
|
|
|
|
2020-03-10 13:11:54 +00:00
|
|
|
sudo sed -i "s/^ExecStart=\/home\/admin\/btc-rpc-explorer.run.sh/ExecStart=\/usr\/bin\/npm start/g" /etc/systemd/system/btc-rpc-explorer.service
|
|
|
|
sudo sed -i "s/^User=.*/User=btcrpcexplorer/g" /etc/systemd/system/btc-rpc-explorer.service
|
2019-12-11 13:44:29 +00:00
|
|
|
sudo systemctl daemon-reload
|
|
|
|
sudo systemctl restart btc-rpc-explorer
|
|
|
|
fi
|
2019-12-11 14:21:34 +00:00
|
|
|
|
2019-12-11 13:44:29 +00:00
|
|
|
else
|
|
|
|
## Disable BTCEXP_ADDRESS_API if BTC-RPC-Explorer is active
|
|
|
|
if [ "${BTCRPCexplorer}" = "on" ]; then
|
|
|
|
echo "electrs is not active - switching address API support off in BTC-RPC-Explorer"
|
2020-03-10 13:11:54 +00:00
|
|
|
sudo -u btcrpcexplorer sed -i 's/^BTCEXP_ADDRESS_API=electrumx/BTCEXP_ADDRESS_API=none/g' /home/btcrpcexplorer/.config/btc-rpc-explorer.env
|
2019-12-11 13:44:29 +00:00
|
|
|
|
2020-03-10 13:11:54 +00:00
|
|
|
sudo sed -i "s/^ExecStart=\/home\/admin\/btc-rpc-explorer.run.sh/ExecStart=\/usr\/bin\/npm start/g" /etc/systemd/system/btc-rpc-explorer.service
|
|
|
|
sudo sed -i "s/^User=.*/User=btcrpcexplorer/g" /etc/systemd/system/btc-rpc-explorer.service
|
2019-12-11 13:44:29 +00:00
|
|
|
sudo systemctl daemon-reload
|
|
|
|
sudo systemctl restart btc-rpc-explorer
|
|
|
|
fi
|
|
|
|
fi
|