btcpay: update to v1.0.5.9, NBXplorer v2.1.46 (#1760)

This commit is contained in:
openoms 2020-11-11 16:40:48 +00:00 committed by rootzoll
parent 15e2e1fcb6
commit 7c98061e9a

View File

@ -2,10 +2,16 @@
# Based on: https://gist.github.com/normandmickey/3f10fc077d15345fb469034e3697d0d0
# https://github.com/dgarage/NBXplorer/releases
NBXplorerVersion="v2.1.46"
# https://github.com/btcpayserver/btcpayserver/releases
BTCPayVersion="v1.0.5.9"
# command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "config script to switch BTCPay Server on or off"
echo "bonus.btcpayserver.sh [on|off|menu|write-tls-macaroon]"
echo "# config script to switch BTCPay Server on or off"
echo "# bonus.btcpayserver.sh [on|off|menu|write-tls-macaroon]"
echo "# installs BTCPayServer $BTCPayVersion with NBXplorer $NBXplorerVersion"
exit 1
fi
@ -78,7 +84,7 @@ fi
# show info menu
if [ "$1" = "menu" ]; then
# get LNbits status info
# get status info
echo "# collecting status info ... (please wait)"
source <(sudo /home/admin/config.scripts/bonus.btcpayserver.sh status)
@ -111,7 +117,7 @@ SHA1 ${sslFingerprintIP}"
if [ "${runBehindTor}" = "on" ] && [ ${#toraddress} -gt 0 ]; then
/home/admin/config.scripts/blitz.lcd.sh qr "${toraddress}"
text="${text}\n
TOR Browser Hidden Service address (QR see LCD):
TOR Browser Hidden Service address (see the QR onLCD):
${toraddress}"
fi
@ -137,7 +143,7 @@ MAINMENU > LNDCREDS > EXPORT > BTCPay Server"
whiptail --title " BTCPay Server " --msgbox "${text}" 17 69
/home/admin/config.scripts/blitz.lcd.sh hide
echo "please wait ..."
echo "# please wait ..."
exit 0
fi
@ -152,17 +158,17 @@ fi
# write-tls-macaroon
if [ "$1" = "write-tls-macaroon" ]; then
echo "make sure btcpay is member of lndadmin"
echo "# make sure btcpay is member of lndadmin"
sudo /usr/sbin/usermod --append --groups lndadmin btcpay
echo "make sure symlink to central app-data directory exists"
echo "# make sure symlink to central app-data directory exists"
if ! [[ -L "/home/btcpay/.lnd" ]]; then
sudo rm -rf "/home/btcpay/.lnd" # not a symlink.. delete it silently
sudo ln -s "/mnt/hdd/app-data/lnd/" "/home/btcpay/.lnd" # and create symlink
fi
# copy admin macaroon
echo "extra symlink to admin.macaroon for btcpay"
echo "# extra symlink to admin.macaroon for btcpay"
if ! [[ -L "/home/btcpay/admin.macaroon" ]]; then
sudo ln -s "/home/btcpay/.lnd/data/chain/${network}/${chain}net/admin.macaroon" "/home/btcpay/admin.macaroon"
fi
@ -171,7 +177,7 @@ if [ "$1" = "write-tls-macaroon" ]; then
FINGERPRINT=$(openssl x509 -noout -fingerprint -sha256 -inform pem -in /home/btcpay/.lnd/tls.cert | cut -d"=" -f2)
doesNetworkEntryAlreadyExists=$(sudo cat /home/btcpay/.btcpayserver/Main/settings.config | grep -c '^network=')
if [ ${doesNetworkEntryAlreadyExists} -eq 0 ]; then
echo "setting the LND TLS thumbprint for BTCPay"
echo "# setting the LND TLS thumbprint for BTCPay"
echo "
### Global settings ###
network=mainnet
@ -186,7 +192,7 @@ BTC.explorer.url=http://127.0.0.1:24444/
BTC.lightning=type=lnd-rest;server=https://127.0.0.1:8080/;macaroonfilepath=/home/btcpay/admin.macaroon;certthumbprint=$FINGERPRINT
" | sudo -u btcpay tee -a /home/btcpay/.btcpayserver/Main/settings.config
else
echo "setting new LND TLS thumbprint for BTCPay"
echo "# setting new LND TLS thumbprint for BTCPay"
s="BTC.lightning=type=lnd-rest\;server=https\://127.0.0.1:8080/\;macaroonfilepath=/home/btcpay/admin.macaroon\;"
sudo -u btcpay sed -i "s|^${s}certthumbprint=.*|${s}certthumbprint=$FINGERPRINT|g" /home/btcpay/.btcpayserver/Main/settings.config
fi
@ -199,7 +205,7 @@ fi
# switch on
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
echo "*** INSTALL BTCPAYSERVER ***"
echo "# *** INSTALL BTCPAYSERVER ***"
##################
# NGINX
@ -221,10 +227,10 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
sudo systemctl reload nginx
# open the firewall
echo "*** Updating Firewall ***"
echo "# *** Updating Firewall ***"
sudo ufw allow 23000 comment 'allow BTCPay HTTP'
sudo ufw allow 23001 comment 'allow BTCPay HTTPS'
echo ""
echo
# Hidden Service for BTCPay if Tor is active
if [ "${runBehindTor}" = "on" ]; then
@ -236,7 +242,7 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
source /mnt/hdd/raspiblitz.conf
# stop services
echo "making sure services are not running"
echo "# making sure services are not running"
sudo systemctl stop nbxplorer 2>/dev/null
sudo systemctl stop btcpayserver 2>/dev/null
@ -257,11 +263,13 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
sudo ln -s /mnt/hdd/app-data/.btcpayserver /home/btcpay/ 2>/dev/null
sudo chown -R btcpay:btcpay /home/btcpay/.btcpayserver
echo ""
echo "***"
echo "Installing .NET"
echo "***"
echo ""
echo
echo "# ***"
echo "# Installing .NET"
echo "# ***"
echo
# download dotnet-sdk
# https://dotnet.microsoft.com/download/dotnet-core/3.1
@ -288,7 +296,7 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
# check binary is was not manipulated (checksum test)
actualChecksum=$(sha512sum /home/btcpay/${dotNetName} | cut -d " " -f1)
if [ "${actualChecksum}" != "${dotNetChecksum}" ]; then
echo "!!! FAIL !!! Downloaded ${dotNetName} not matching SHA512 checksum: ${dotNetChecksum}"
echo "# !!! FAIL !!! Downloaded ${dotNetName} not matching SHA512 checksum: ${dotNetChecksum}"
exit 1
fi
@ -310,7 +318,7 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
# check binary is was not manipulated (checksum test)
actualAspNetChecksum=$(sha512sum /home/btcpay/${aspNetCoreName} | cut -d " " -f1)
if [ "${actualAspNetChecksum}" != "${AspNetChecksum=}" ]; then
echo "!!! FAIL !!! Downloaded ${aspNetCoreName} not matching SHA512 checksum: ${AspNetChecksum=}"
echo "# !!! FAIL !!! Downloaded ${aspNetCoreName} not matching SHA512 checksum: ${AspNetChecksum=}"
exit 1
fi
@ -337,18 +345,17 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
sudo -u btcpay /home/btcpay/dotnet/dotnet --info
# NBXplorer
echo ""
echo "***"
echo "Install NBXplorer"
echo "***"
echo ""
echo
echo "# ***"
echo "# Install NBXplorer"
echo "# ***"
echo
cd /home/btcpay
echo "Downloading NBXplorer source code.."
echo "# Downloading NBXplorer source code.."
sudo -u btcpay git clone https://github.com/dgarage/NBXplorer.git 2>/dev/null
cd NBXplorer
# check https://github.com/dgarage/NBXplorer/releases
sudo -u btcpay git reset --hard v2.1.44
sudo -u btcpay git reset --hard $NBXplorerVersion
# from the build.sh with path
sudo -u btcpay /home/btcpay/dotnet/dotnet build -c Release NBXplorer/NBXplorer.csproj
@ -381,26 +388,26 @@ WantedBy=multi-user.target
sudo systemctl enable nbxplorer
if [ "${state}" == "ready" ]; then
echo "Starting nbxplorer"
echo "# Starting nbxplorer"
sudo systemctl start nbxplorer
echo "Checking for nbxplorer config"
echo "# Checking for nbxplorer config"
while [ ! -f "/home/btcpay/.nbxplorer/Main/settings.config" ]
do
echo "Waiting for nbxplorer to start - CTRL+C to abort"
echo "# Waiting for nbxplorer to start - CTRL+C to abort"
sleep 10
hasFailed=$(sudo systemctl status nbxplorer | grep -c "Active: failed")
if [ ${hasFailed} -eq 1 ]; then
echo "seems like starting nbxplorer service has failed - see: systemctl status nbxplorer"
echo "maybe report here: https://github.com/rootzoll/raspiblitz/issues/214"
echo "# seems like starting nbxplorer service has failed - see: systemctl status nbxplorer"
echo "# maybe report here: https://github.com/rootzoll/raspiblitz/issues/214"
fi
done
else
echo "Because the system is not 'ready' the service 'nbxplorer' will not be started at this point .. its enabled and will start on next reboot"
echo "# Because the system is not 'ready' the service 'nbxplorer' will not be started at this point .. its enabled and will start on next reboot"
fi
echo ""
echo "***"
echo "getting RPC credentials from the bitcoin.conf"
echo
echo "# ***"
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 mv /home/btcpay/.nbxplorer/Main/settings.config /home/btcpay/.nbxplorer/Main/settings.config.backup
@ -420,18 +427,17 @@ EOF
fi
# BTCPayServer
echo ""
echo "***"
echo "Install BTCPayServer"
echo "***"
echo ""
echo
echo "# ***"
echo "# Install BTCPayServer"
echo "# ***"
echo
cd /home/btcpay
echo "Downloading BTCPayServer source code.."
echo "# Downloading BTCPayServer source code.."
sudo -u btcpay git clone https://github.com/btcpayserver/btcpayserver.git 2>/dev/null
cd btcpayserver
# check https://github.com/btcpayserver/btcpayserver/releases
sudo -u btcpay git reset --hard v1.0.5.8
sudo -u btcpay git reset --hard $BTCPayVersion
# use latest commit (v1.0.4.4+) to fix build with latest dotNet
# sudo -u btcpay git checkout f2bb24f6ab6d402af8214c67f84e08116eb650e7
# from the build.sh with path
@ -460,21 +466,21 @@ WantedBy=multi-user.target
sudo systemctl enable btcpayserver
if [ "${state}" == "ready" ]; then
echo "Starting btcpayserver"
echo "# Starting btcpayserver"
sudo systemctl start btcpayserver
echo "Checking for btcpayserver config"
echo "# Checking for btcpayserver config"
while [ ! -f "/home/btcpay/.btcpayserver/Main/settings.config" ]
do
echo "Waiting for btcpayserver to start - CTRL+C to abort"
echo "# Waiting for btcpayserver to start - CTRL+C to abort"
sleep 10
hasFailed=$(sudo systemctl status btcpayserver | grep -c "Active: failed")
if [ ${hasFailed} -eq 1 ]; then
echo "seems like starting btcpayserver service has failed - see: systemctl status btcpayserver"
echo "maybe report here: https://github.com/rootzoll/raspiblitz/issues/214"
echo "# seems like starting btcpayserver service has failed - see: systemctl status btcpayserver"
echo "# maybe report here: https://github.com/rootzoll/raspiblitz/issues/214"
fi
done
else
echo "Because the system is not 'ready' the service 'btcpayserver' will not be started at this point .. its enabled and will start on next reboot"
echo "# Because the system is not 'ready' the service 'btcpayserver' will not be started at this point .. its enabled and will start on next reboot"
fi
sudo -u btcpay mkdir -p /home/btcpay/.btcpayserver/Main/
@ -482,11 +488,11 @@ WantedBy=multi-user.target
/home/admin/config.scripts/bonus.btcpayserver.sh write-tls-macaroon
else
echo "BTCPay Server is already installed."
echo "# BTCPay Server is already installed."
if [ "${state}" == "ready" ]; then
# start service
echo "start service"
echo "# start service"
sudo systemctl start nbxplorer 2>/dev/null
sudo systemctl start btcpayserver 2>/dev/null
fi
@ -571,5 +577,5 @@ if [ "$1" = "0" ] || [ "$1" = "off" ]; then
exit 0
fi
echo "FAIL - Unknown Parameter $1"
echo "# FAIL - Unknown Parameter $1"
exit 1