Merge branch 'master' into v1.5

This commit is contained in:
rootzoll 2020-03-16 21:15:30 -07:00
commit 3a804b4602
5 changed files with 94 additions and 120 deletions

View file

@ -1,19 +0,0 @@
# Raspibolt RTL: systemd unit for RTL
# /etc/systemd/system/RTL.service
[Unit]
Description=RTL daemon
Wants=lnd.service
After=lnd.service
[Service]
ExecStart=/usr/bin/node /home/admin/RTL/rtl --lndir /home/admin/.lnd/data/chain/bitcoin/mainnet
User=root
Restart=always
TimeoutSec=120
RestartSec=30
StandardOutput=null
StandardError=journal
[Install]
WantedBy=multi-user.target

View file

@ -208,21 +208,25 @@ elif [ "${abcd}" = "b" ]; then
# RTL - keep settings from current RTL-Config.json
if [ "${rtlWebinterface}" == "on" ]; then
echo "# changing RTL password"
cp /home/admin/RTL/RTL-Config.json /home/admin/RTL/backup-RTL-Config.json
cp /home/rtl/RTL/RTL-Config.json /home/rtl/RTL/backup-RTL-Config.json
# remove hashed old password
#sed -i "/\b\(multiPassHashed\)\b/d" ./RTL-Config.json
# set new password
chmod 600 /home/admin/RTL/RTL-Config.json || exit 1
node > /home/admin/RTL/RTL-Config.json <<EOF
cp /home/rtl/RTL/RTL-Config.json /home/admin/RTL-Config.json
chown admin:admin /home/admin/RTL-Config.json
chmod 600 /home/admin/RTL-Config.json || exit 1
node > /home/admin/RTL-Config.json <<EOF
//Read data
var data = require('/home/admin/RTL/backup-RTL-Config.json');
var data = require('/home/rtl/RTL/backup-RTL-Config.json');
//Manipulate data
data.multiPassHashed = null;
data.multiPass = '$newPassword';
//Output data
console.log(JSON.stringify(data, null, 2));
EOF
rm -f /home/admin/RTL/backup-RTL-Config.json
rm -f /home/rtl/RTL/backup-RTL-Config.json
mv /home/admin/RTL-Config.json /home/rtl/RTL/
chown rtl:rtl /home/rtl/RTL/RTL-Config.json
fi
# electrs
@ -235,9 +239,8 @@ EOF
# BTC-RPC-Explorer
if [ "${BTCRPCexplorer}" = "on" ]; then
echo "# changing BTCRPCEXPLORER password"
sed -i "s/^BTCEXP_BITCOIND_URI=$network:\/\/$RPC_USER:.*@127.0.0.1:8332?timeout=10000/BTCEXP_BITCOIND_URI=$network:\/\/$RPC_USER:${newPassword}@127.0.0.1:8332\?timeout=10000/g" /home/bitcoin/.config/btc-rpc-explorer.env 2>/dev/null
sed -i "s/^BTCEXP_BITCOIND_PASS=.*/BTCEXP_BITCOIND_PASS=${newPassword}/g" /home/bitcoin/.config/btc-rpc-explorer.env 2>/dev/null
sed -i "s/^BTCEXP_BASIC_AUTH_PASSWORD=.*/BTCEXP_BASIC_AUTH_PASSWORD=${newPassword}/g" /home/bitcoin/.config/btc-rpc-explorer.env 2>/dev/null
sed -i "s/^BTCEXP_BITCOIND_PASS=.*/BTCEXP_BITCOIND_PASS=${newPassword}/g" /home/btcrpcexplorer/.config/btc-rpc-explorer.env 2>/dev/null
sed -i "s/^BTCEXP_BASIC_AUTH_PASSWORD=.*/BTCEXP_BASIC_AUTH_PASSWORD=${newPassword}/g" /home/btcrpcexplorer/.config/btc-rpc-explorer.env 2>/dev/null
fi
# BTCPayServer

View file

@ -88,30 +88,6 @@ if [ "$1" = "status" ]; then
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
@ -128,8 +104,16 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
# make sure that txindex of blockchain is switched on
/home/admin/config.scripts/network.txindex.sh on
# add btcrpcexplorer user
sudo adduser --disabled-password --gecos "" btcrpcexplorer
npm install -g btc-rpc-explorer@1.1.8
# install btc-rpc-explorer
cd /home/btcrpcexplorer
sudo -u btcrpcexplorer git clone https://github.com/janoside/btc-rpc-explorer.git
cd btc-rpc-explorer
sudo -u btcrpcexplorer git reset --hard v1.1.9
sudo -u btcrpcexplorer npm install
# prepare .env file
echo "getting RPC credentials from the ${network}.conf"
@ -137,27 +121,25 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
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
sudo 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
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=$network://$RPC_USER:$PASSWORD_B@127.0.0.1:8332?timeout=10000
#BTCEXP_BITCOIND_HOST=127.0.0.1
#BTCEXP_BITCOIND_PORT=8332
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
BTCEXP_BITCOIND_RPC_TIMEOUT=10000
# Password protection for site via basic auth (enter any username, only the password is checked)
# Default: none
BTCEXP_BASIC_AUTH_PASSWORD=$PASSWORD_B
@ -169,8 +151,8 @@ BTCEXP_BASIC_AUTH_PASSWORD=$PASSWORD_B
BTCEXP_ADDRESS_API=none
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
sudo mv /home/admin/btc-rpc-explorer.env /home/btcrpcexplorer/.config/btc-rpc-explorer.env
sudo chown btcrpcexplorer:btcrpcexplorer /home/btcrpcexplorer/.config/btc-rpc-explorer.env
# open firewall
echo "*** Updating Firewall ***"
@ -189,13 +171,13 @@ Wants=${network}d.service
After=${network}d.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
WorkingDirectory=/home/btcrpcexplorer/btc-rpc-explorer
ExecStart=/usr/bin/npm start
User=btcrpcexplorer
# Restart on failure but no more than 2 time every 10 minutes (600 seconds). Otherwise stop
Restart=on-failure
StartLimitIntervalSec=600
StartLimitBurst=2
[Install]
WantedBy=multi-user.target
@ -241,7 +223,8 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
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
sudo rm -rf /home/btcrpcexplorer/btc-rpc-explorer
sudo rm -f /home/btcrpcexplorer/.config/btc-rpc-explorer.env
echo "OK BTC-RPC-explorer removed."
else
echo "BTC-RPC-explorer is not installed."

View file

@ -2,36 +2,13 @@
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')
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
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"
sudo -u bitcoin sed -i 's/^BTCEXP_ADDRESS_API=none/BTCEXP_ADDRESS_API=electrumx/g' /home/bitcoin/.config/btc-rpc-explorer.env
sudo -u btcrpcexplorer sed -i 's/^BTCEXP_ADDRESS_API=none/BTCEXP_ADDRESS_API=electrumx/g' /home/btcrpcexplorer/.config/btc-rpc-explorer.env
# create ExecStart=/home/bitcoin/btc-rpc-explorer.run.sh
# create ExecStart=/home/admin/btc-rpc-explorer.run.sh
cat > /home/admin/btc-rpc-explorer.run.sh <<EOF
#!/bin/bash
echo "Waiting Electrs on port 50001..."
@ -39,21 +16,22 @@ while [ $(sudo -u electrs lsof -i | grep -c 50001) -eq 0 ]; do
sleep 1
done
echo "Electrs started, launching BTC-RPC-Explorer..."
/usr/local/lib/nodejs/node-$(node -v)-$DISTRO/bin/btc-rpc-explorer
cd /home/btcrpcexplorer/btc-rpc-explorer
sudo -u btcrpcexplorer /usr/bin/npm start
EOF
sudo mv /home/admin/btc-rpc-explorer.run.sh /home/bitcoin/btc-rpc-explorer.run.sh
sudo chown bitcoin:bitcoin /home/bitcoin/btc-rpc-explorer.run.sh
sudo chmod +x /home/bitcoin/btc-rpc-explorer.run.sh
sudo chmod +x /home/admin/btc-rpc-explorer.run.sh
sudo sed -i "s/^ExecStart=\/usr\/local\/lib\/nodejs\/node-$(node -v)-$DISTRO\/bin\/btc-rpc-explorer/ExecStart=\/home\/bitcoin\/btc-rpc-explorer.run.sh/g" /etc/systemd/system/btc-rpc-explorer.service
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
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"
sudo -u bitcoin sed -i 's/^BTCEXP_ADDRESS_API=electrumx/BTCEXP_ADDRESS_API=none/g' /home/bitcoin/.config/btc-rpc-explorer.env
sudo -u btcrpcexplorer sed -i 's/^BTCEXP_ADDRESS_API=electrumx/BTCEXP_ADDRESS_API=none/g' /home/btcrpcexplorer/.config/btc-rpc-explorer.env
sudo sed -i "s/^ExecStart=\/home\/bitcoin\/btc-rpc-explorer.run.sh/ExecStart=\/usr\/local\/lib\/nodejs\/node-$(node -v)-$DISTRO\/bin\/btc-rpc-explorer/g" /etc/systemd/system/btc-rpc-explorer.service
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
sudo systemctl daemon-reload
sudo systemctl restart btc-rpc-explorer
fi
@ -62,9 +40,10 @@ 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"
sudo -u bitcoin sed -i 's/^BTCEXP_ADDRESS_API=electrumx/BTCEXP_ADDRESS_API=none/g' /home/bitcoin/.config/btc-rpc-explorer.env
sudo -u btcrpcexplorer sed -i 's/^BTCEXP_ADDRESS_API=electrumx/BTCEXP_ADDRESS_API=none/g' /home/btcrpcexplorer/.config/btc-rpc-explorer.env
sudo sed -i "s/^ExecStart=\/home\/bitcoin\/btc-rpc-explorer.run.sh/ExecStart=\/usr\/local\/lib\/nodejs\/node-$(node -v)-$DISTRO\/bin\/btc-rpc-explorer/g" /etc/systemd/system/btc-rpc-explorer.service
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
sudo systemctl daemon-reload
sudo systemctl restart btc-rpc-explorer
fi

View file

@ -75,17 +75,21 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
sudo apt-get install -y python2
fi
# create rtl user
sudo adduser --disabled-password --gecos "" rtl
# 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.6.7
rm -rf /home/admin/RTL 2>/dev/null
sudo -u rtl rm -rf /home/rtl/RTL 2>/dev/null
sudo -u rtl git clone https://github.com/ShahanaFarooqui/RTL.git /home/rtl/RTL
cd /home/rtl/RTL
sudo -u rtl git reset --hard v0.6.7
# from https://github.com/Ride-The-Lightning/RTL/commits/master
# git checkout 917feebfa4fb583360c140e817c266649307ef72
# git fetch origin
# git checkout feature/0.6.5
if [ -d "/home/admin/RTL" ]; then
if [ -d "/home/rtl/RTL" ]; then
echo "OK - RTL code copy looks good"
else
echo "FAIL - code copy did not run correctly"
@ -97,10 +101,10 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
# install
echo "*** Run: npm install ***"
export NG_CLI_ANALYTICS=false
npm install --only=production
sudo -u rtl npm install --only=production
cd ..
# check if node_modules exist now
if [ -d "/home/admin/RTL/node_modules" ]; then
if [ -d "/home/rtl/RTL/node_modules" ]; then
echo "OK - RTL install looks good"
else
echo "FAIL - npm install did not run correctly"
@ -117,23 +121,26 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
# prepare RTL-Config.json file
echo "*** RTL.conf ***"
# change of config: https://github.com/Ride-The-Lightning/RTL/tree/v0.6.4
cp /home/admin/RTL/sample-RTL-Config.json /home/admin/RTL/RTL-Config.json
chmod 600 /home/admin/RTL/RTL-Config.json || exit 1
sudo cp /home/rtl/RTL/sample-RTL-Config.json /home/admin/RTL-Config.json
sudo chown admin:admin /home/admin/RTL-Config.json
sudo chmod 600 /home/admin/RTL-Config.json || exit 1
PASSWORD_B=$(sudo cat /mnt/hdd/${network}/${network}.conf | grep rpcpassword | cut -c 13-)
# modify sample-RTL-Config.json and save in RTL-Config.json
node > /home/admin/RTL/RTL-Config.json <<EOF
# modify sample-RTL-Config.json and save in RTL-Config.json
sudo node > /home/admin/RTL-Config.json <<EOF
//Read data
var data = require('/home/admin/RTL/sample-RTL-Config.json');
var data = require('/home/rtl/RTL/sample-RTL-Config.json');
//Manipulate data
data.nodes[0].lnNode = '$hostname'
data.nodes[0].Authentication.macaroonPath = '/mnt/hdd/lnd/data/chain/${network}/${chain}net/';
data.nodes[0].Authentication.macaroonPath = '/home/admin/.lnd/data/chain/${network}/${chain}net/';
data.nodes[0].Authentication.configPath = '/mnt/hdd/lnd/lnd.conf';
data.multiPass = '$PASSWORD_B';
data.nodes[0].Settings.userPersona = 'OPERATOR'
data.nodes[0].Settings.channelBackupPath = 'RTL-SCB-backup-$hostname'
data.nodes[0].Settings.channelBackupPath = '/home/rtl/RTL-SCB-backup-$hostname'
//Output data
console.log(JSON.stringify(data, null, 2));
EOF
sudo mv /home/admin/RTL-Config.json /home/rtl/RTL/
sudo chown rtl:rtl /home/rtl/RTL/RTL-Config.json
echo ""
# open firewall
@ -144,11 +151,32 @@ EOF
# install service
echo "*** Install RTL systemd for ${network} on ${chain} ***"
sudo cp /home/admin/assets/RTL.service /etc/systemd/system/RTL.service
cat > /home/admin/RTL.service <<EOF
# Systemd unit for RTL
# /etc/systemd/system/RTL.service
[Unit]
Description=RTL daemon
Wants=lnd.service
After=lnd.service
[Service]
ExecStart=/usr/bin/node /home/rtl/RTL/rtl --lndir /home/admin/.lnd/data/chain/bitcoin/mainnet
User=rtl
Restart=always
TimeoutSec=120
RestartSec=30
StandardOutput=null
StandardError=journal
[Install]
WantedBy=multi-user.target
EOF
sudo mv /home/admin/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 - the RTL service is now enabled"
fi
# setting value in raspi blitz config
@ -175,7 +203,7 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
sudo systemctl stop RTL
sudo systemctl disable RTL
sudo rm /etc/systemd/system/RTL.service
sudo rm -r /home/admin/RTL
sudo rm -rf /home/rtl/RTL
echo "OK RTL removed."
else
echo "RTL is not installed."