2019-12-04 08:13:21 +00:00
#!/bin/bash
2020-05-01 11:34:52 +02:00
# Based on: https://gist.github.com/normandmickey/3f10fc077d15345fb469034e3697d0d0
2019-12-04 08:13:21 +00:00
2021-11-30 11:43:52 +00:00
# https://github.com/dgarage/NBXplorer/tags
v1.9.0rc3 Merge (#3742)
* cln: use default normal feerate to withdraw all
* Bugfix: bad subsititution (#3668)
Fix for error:
/home/admin/config.scripts/bonus.go.sh: line 31: ${goOSversion{}: bad substitution
* whiptail one line
* fix syntax
* lnproxy: fix api access through nginx (#3671)
* lnproxy: fix api access through nginx
* fix tor config and fit the menu
* add to the menu and provision
* merge #3682
* cln update to v23.02, backup-plugin update, add poetry (#3684)
* cln backup-plugin update, add poetry
* fix mkdir error, remove commented code, fmt #3677
* poetry and path fixes
* add terminal feedback, format #3676
* detect the full name of the plugin
* install pyln-client tqdm with pip
* git-verify: add --keyid-format LONG
to recognise if the signing key is not the main key
* cln update to v23.02
* cln-grpc: add protobuf-compiler dep
* rtl update to v0.13.6 and formatting
* C-lightningREST update to v0.10.1
* CLN FAQ update (#3666)
* improve the detection of existing cln aliases
* add the emergencyrecover instructions to CLN FAQ
* update help entries
* Update Tallycoin to version 1.8.0 (#3693)
* add tallycoin update info to CHANGES
* Fix typo in README.md (#3699)
excepted -> accepted
* #3694 add LCD info
* #3664 att timeout 30s to ln monitor calls (#3665)
* fix setting LND_REST_ENDPOINT (#3689)
* btcpay update v1.8.2, postgres database fix (#3697)
* btcpay update v1.8.0, postgres database fix
* btcpayserver update to v1.8.2
* update lnbits to 0.10.2 and use poetry instead of venv (#3703)
* fix apt update Key error for influx repo (#3711)
Co-authored-by: Patrick Scheich <patrick.scheich@syscovery.de>
* fix missing timeout value for nc cmnd (#3712)
Co-authored-by: Patrick Scheich <patrick.scheich@syscovery.de>
* #3706 Update CLN v23.02.2 (#3716)
* used patched/rolledback 23.02.2 release
* check rusty sig
* fix typo
* fix default lightning setting
* #3683 Update LIT to 0.8.6 (#3717)
* update LIT to 0.8.6
* activate lnd rpcmiddleware
* CHANGES.md
* #3667 change all up/download from sftp tp scp (#3718)
* #3722 add no hostkeys available detection (#3723)
* #1186 FinTS/HBCI interface (#3704)
* #1186 FinTS install script first draft
* only start app when blitz is ready
* improve menu
* improve dit lnbits config
* preserve edit
* improve edit
* improve edit
* fix insertion
* dont use fingerprint
* now use main repo
* add port
* show local ip
* fix typo
* show port SSL
* Update bonus.lndg.sh (#3725)
* Update bonus.lndg.sh
Changes version to v1.6.0.
Fixes update menu bug.
Cleans up code a bit (removes tabs and changes to spaces to match raspiblitz formats).
* Update bonus.lndg.sh
Cleaned up code, added requirements.txt install to updates (needed for this update, may be needed in future).
* #3725 update lndg version in CHANGES
* #3692 update lnd to v0.16.0-beta (#3732)
* update SD CARD base image info
* Clenaup CHANGES info
* RTL install fix (#3739)
* c-lightning-REST update to 0.10.2, fmt
* rtl: npm insatll with --legacy-peer-deps
* purge c-lightning-REST as well with RTL
* jam update to v0.1.5 (#3736)
* 3733 CLN GRPC > JRPC (#3741)
* change exit code
* change to cln_jrpc
* deactivate the cln_grpc settings
* set v1.9.0rc3 version
---------
Co-authored-by: openoms <oms@tuta.io>
Co-authored-by: Metallicc <72348+metallicc@users.noreply.github.com>
Co-authored-by: openoms <43343391+openoms@users.noreply.github.com>
Co-authored-by: DJ Booth <djbooth007@gmail.com>
Co-authored-by: Yuck Fou <115867254+YuckFouBTC@users.noreply.github.com>
Co-authored-by: dni ⚡ <office@dnilabs.com>
Co-authored-by: PatrickScheich <50054697+PatrickScheich@users.noreply.github.com>
Co-authored-by: Patrick Scheich <patrick.scheich@syscovery.de>
Co-authored-by: allyourbankarebelongtous <100060902+allyourbankarebelongtous@users.noreply.github.com>
2023-04-08 23:10:01 +02:00
NBXplorerVersion = "v2.3.62"
2020-11-11 16:40:48 +00:00
# https://github.com/btcpayserver/btcpayserver/releases
v1.9.0rc3 Merge (#3742)
* cln: use default normal feerate to withdraw all
* Bugfix: bad subsititution (#3668)
Fix for error:
/home/admin/config.scripts/bonus.go.sh: line 31: ${goOSversion{}: bad substitution
* whiptail one line
* fix syntax
* lnproxy: fix api access through nginx (#3671)
* lnproxy: fix api access through nginx
* fix tor config and fit the menu
* add to the menu and provision
* merge #3682
* cln update to v23.02, backup-plugin update, add poetry (#3684)
* cln backup-plugin update, add poetry
* fix mkdir error, remove commented code, fmt #3677
* poetry and path fixes
* add terminal feedback, format #3676
* detect the full name of the plugin
* install pyln-client tqdm with pip
* git-verify: add --keyid-format LONG
to recognise if the signing key is not the main key
* cln update to v23.02
* cln-grpc: add protobuf-compiler dep
* rtl update to v0.13.6 and formatting
* C-lightningREST update to v0.10.1
* CLN FAQ update (#3666)
* improve the detection of existing cln aliases
* add the emergencyrecover instructions to CLN FAQ
* update help entries
* Update Tallycoin to version 1.8.0 (#3693)
* add tallycoin update info to CHANGES
* Fix typo in README.md (#3699)
excepted -> accepted
* #3694 add LCD info
* #3664 att timeout 30s to ln monitor calls (#3665)
* fix setting LND_REST_ENDPOINT (#3689)
* btcpay update v1.8.2, postgres database fix (#3697)
* btcpay update v1.8.0, postgres database fix
* btcpayserver update to v1.8.2
* update lnbits to 0.10.2 and use poetry instead of venv (#3703)
* fix apt update Key error for influx repo (#3711)
Co-authored-by: Patrick Scheich <patrick.scheich@syscovery.de>
* fix missing timeout value for nc cmnd (#3712)
Co-authored-by: Patrick Scheich <patrick.scheich@syscovery.de>
* #3706 Update CLN v23.02.2 (#3716)
* used patched/rolledback 23.02.2 release
* check rusty sig
* fix typo
* fix default lightning setting
* #3683 Update LIT to 0.8.6 (#3717)
* update LIT to 0.8.6
* activate lnd rpcmiddleware
* CHANGES.md
* #3667 change all up/download from sftp tp scp (#3718)
* #3722 add no hostkeys available detection (#3723)
* #1186 FinTS/HBCI interface (#3704)
* #1186 FinTS install script first draft
* only start app when blitz is ready
* improve menu
* improve dit lnbits config
* preserve edit
* improve edit
* improve edit
* fix insertion
* dont use fingerprint
* now use main repo
* add port
* show local ip
* fix typo
* show port SSL
* Update bonus.lndg.sh (#3725)
* Update bonus.lndg.sh
Changes version to v1.6.0.
Fixes update menu bug.
Cleans up code a bit (removes tabs and changes to spaces to match raspiblitz formats).
* Update bonus.lndg.sh
Cleaned up code, added requirements.txt install to updates (needed for this update, may be needed in future).
* #3725 update lndg version in CHANGES
* #3692 update lnd to v0.16.0-beta (#3732)
* update SD CARD base image info
* Clenaup CHANGES info
* RTL install fix (#3739)
* c-lightning-REST update to 0.10.2, fmt
* rtl: npm insatll with --legacy-peer-deps
* purge c-lightning-REST as well with RTL
* jam update to v0.1.5 (#3736)
* 3733 CLN GRPC > JRPC (#3741)
* change exit code
* change to cln_jrpc
* deactivate the cln_grpc settings
* set v1.9.0rc3 version
---------
Co-authored-by: openoms <oms@tuta.io>
Co-authored-by: Metallicc <72348+metallicc@users.noreply.github.com>
Co-authored-by: openoms <43343391+openoms@users.noreply.github.com>
Co-authored-by: DJ Booth <djbooth007@gmail.com>
Co-authored-by: Yuck Fou <115867254+YuckFouBTC@users.noreply.github.com>
Co-authored-by: dni ⚡ <office@dnilabs.com>
Co-authored-by: PatrickScheich <50054697+PatrickScheich@users.noreply.github.com>
Co-authored-by: Patrick Scheich <patrick.scheich@syscovery.de>
Co-authored-by: allyourbankarebelongtous <100060902+allyourbankarebelongtous@users.noreply.github.com>
2023-04-08 23:10:01 +02:00
BTCPayVersion = "v1.8.2"
2020-11-11 16:40:48 +00:00
2019-12-04 08:13:21 +00:00
# command info
if [ $# -eq 0 ] || [ " $1 " = "-h" ] || [ " $1 " = "-help" ] ; then
2021-11-30 11:43:52 +00:00
echo "Config script to switch BTCPay Server on or off"
echo "Usage:"
2022-12-13 15:28:05 +01:00
echo "bonus.btcpayserver.sh [install|uninstall]"
2022-06-02 15:26:20 +01:00
echo "bonus.btcpayserver.sh [on|off|menu|write-tls-macaroon|cln-lightning-rpc-access]"
2021-11-30 11:43:52 +00:00
echo " installs BTCPayServer $BTCPayVersion with NBXplorer $NBXplorerVersion "
echo "To update to the latest release published on github run:"
echo "bonus.btcpayserver.sh update"
echo
2019-12-05 16:45:27 +00:00
exit 1
2019-12-04 08:13:21 +00:00
fi
source /mnt/hdd/raspiblitz.conf
2022-12-06 17:55:31 +00:00
# get cpu architecture (checked with 'uname -m')
2020-06-04 14:33:19 +01:00
source /home/admin/raspiblitz.info
2021-12-14 23:34:35 +01:00
source <( /home/admin/_cache.sh get state)
2019-12-04 08:13:21 +00:00
2023-02-04 12:37:59 +00:00
function NBXplorerConfig( ) {
# check the postgres database
if sudo -u postgres psql -c '\l' | grep nbxplorermainnet; then
echo "# nbxplorermainnet database already exists"
else
echo "# Generate the database for nbxplorer"
v1.9.0rc3 Merge (#3742)
* cln: use default normal feerate to withdraw all
* Bugfix: bad subsititution (#3668)
Fix for error:
/home/admin/config.scripts/bonus.go.sh: line 31: ${goOSversion{}: bad substitution
* whiptail one line
* fix syntax
* lnproxy: fix api access through nginx (#3671)
* lnproxy: fix api access through nginx
* fix tor config and fit the menu
* add to the menu and provision
* merge #3682
* cln update to v23.02, backup-plugin update, add poetry (#3684)
* cln backup-plugin update, add poetry
* fix mkdir error, remove commented code, fmt #3677
* poetry and path fixes
* add terminal feedback, format #3676
* detect the full name of the plugin
* install pyln-client tqdm with pip
* git-verify: add --keyid-format LONG
to recognise if the signing key is not the main key
* cln update to v23.02
* cln-grpc: add protobuf-compiler dep
* rtl update to v0.13.6 and formatting
* C-lightningREST update to v0.10.1
* CLN FAQ update (#3666)
* improve the detection of existing cln aliases
* add the emergencyrecover instructions to CLN FAQ
* update help entries
* Update Tallycoin to version 1.8.0 (#3693)
* add tallycoin update info to CHANGES
* Fix typo in README.md (#3699)
excepted -> accepted
* #3694 add LCD info
* #3664 att timeout 30s to ln monitor calls (#3665)
* fix setting LND_REST_ENDPOINT (#3689)
* btcpay update v1.8.2, postgres database fix (#3697)
* btcpay update v1.8.0, postgres database fix
* btcpayserver update to v1.8.2
* update lnbits to 0.10.2 and use poetry instead of venv (#3703)
* fix apt update Key error for influx repo (#3711)
Co-authored-by: Patrick Scheich <patrick.scheich@syscovery.de>
* fix missing timeout value for nc cmnd (#3712)
Co-authored-by: Patrick Scheich <patrick.scheich@syscovery.de>
* #3706 Update CLN v23.02.2 (#3716)
* used patched/rolledback 23.02.2 release
* check rusty sig
* fix typo
* fix default lightning setting
* #3683 Update LIT to 0.8.6 (#3717)
* update LIT to 0.8.6
* activate lnd rpcmiddleware
* CHANGES.md
* #3667 change all up/download from sftp tp scp (#3718)
* #3722 add no hostkeys available detection (#3723)
* #1186 FinTS/HBCI interface (#3704)
* #1186 FinTS install script first draft
* only start app when blitz is ready
* improve menu
* improve dit lnbits config
* preserve edit
* improve edit
* improve edit
* fix insertion
* dont use fingerprint
* now use main repo
* add port
* show local ip
* fix typo
* show port SSL
* Update bonus.lndg.sh (#3725)
* Update bonus.lndg.sh
Changes version to v1.6.0.
Fixes update menu bug.
Cleans up code a bit (removes tabs and changes to spaces to match raspiblitz formats).
* Update bonus.lndg.sh
Cleaned up code, added requirements.txt install to updates (needed for this update, may be needed in future).
* #3725 update lndg version in CHANGES
* #3692 update lnd to v0.16.0-beta (#3732)
* update SD CARD base image info
* Clenaup CHANGES info
* RTL install fix (#3739)
* c-lightning-REST update to 0.10.2, fmt
* rtl: npm insatll with --legacy-peer-deps
* purge c-lightning-REST as well with RTL
* jam update to v0.1.5 (#3736)
* 3733 CLN GRPC > JRPC (#3741)
* change exit code
* change to cln_jrpc
* deactivate the cln_grpc settings
* set v1.9.0rc3 version
---------
Co-authored-by: openoms <oms@tuta.io>
Co-authored-by: Metallicc <72348+metallicc@users.noreply.github.com>
Co-authored-by: openoms <43343391+openoms@users.noreply.github.com>
Co-authored-by: DJ Booth <djbooth007@gmail.com>
Co-authored-by: Yuck Fou <115867254+YuckFouBTC@users.noreply.github.com>
Co-authored-by: dni ⚡ <office@dnilabs.com>
Co-authored-by: PatrickScheich <50054697+PatrickScheich@users.noreply.github.com>
Co-authored-by: Patrick Scheich <patrick.scheich@syscovery.de>
Co-authored-by: allyourbankarebelongtous <100060902+allyourbankarebelongtous@users.noreply.github.com>
2023-04-08 23:10:01 +02:00
sudo -u postgres psql -c "CREATE DATABASE nbxplorermainnet TEMPLATE template0 LC_CTYPE 'C' LC_COLLATE 'C' ENCODING 'UTF8';"
2023-02-04 12:37:59 +00:00
sudo -u postgres psql -c "create user nbxplorer with encrypted password 'raspiblitz';"
sudo -u postgres psql -c "grant all privileges on database nbxplorermainnet to nbxplorer;"
fi
2022-12-06 17:55:31 +00:00
echo "# List databases with: sudo -u postgres psql -c '\l'"
sudo -u postgres psql -c '\l'
2022-07-12 13:02:15 +01:00
# https://docs.btcpayserver.org/Deployment/ManualDeploymentExtended/#4-create-a-configuration-file
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 -u btcpay mkdir -p /home/btcpay/.nbxplorer/Main
echo " \
network = mainnet
btc.rpc.user= ${ RPC_USER }
btc.rpc.password= ${ PASSWORD_B }
postgres = User ID = nbxplorer; Host = localhost; Port = 5432; Application Name = nbxplorer; MaxPoolSize = 20; Database = nbxplorermainnet; Password = 'raspiblitz' ;
automigrate = 1
nomigrateevts = 1
2022-12-06 17:55:31 +00:00
" | sudo -u btcpay tee /home/btcpay/.nbxplorer/Main/settings.config
2022-07-12 13:02:15 +01:00
sudo chmod 600 /home/btcpay/.nbxplorer/Main/settings.config
}
function BtcPayConfig( ) {
# set thumbprint
FINGERPRINT = $( openssl x509 -noout -fingerprint -sha256 -inform pem -in /home/btcpay/.lnd/tls.cert | cut -d"=" -f2)
2023-02-04 12:37:59 +00:00
if sudo ls /mnt/hdd/app-data/.btcpayserver/Main/sqllite.db 1>/dev/null 2>& 1; then
echo "# sqlite database exists"
databaseOption = "# keep using sqlite as /mnt/hdd/app-data/.btcpayserver/Main/sqllite.db exists (configured in the btcpayserver.service)"
else
echo "# sqlite database does not exist, using postgresql"
databaseOption = "postgres=User ID=btcpay;Host=localhost;Port=5432;Application Name=btcpay;MaxPoolSize=20;Database=btcpaymainnet;Password='raspiblitz';"
if sudo -u postgres psql -c '\l' | grep btcpaymainnet; then
echo "# btcpaymainnet database already exists"
else
echo "# Generate the database for btcpay"
v1.9.0rc3 Merge (#3742)
* cln: use default normal feerate to withdraw all
* Bugfix: bad subsititution (#3668)
Fix for error:
/home/admin/config.scripts/bonus.go.sh: line 31: ${goOSversion{}: bad substitution
* whiptail one line
* fix syntax
* lnproxy: fix api access through nginx (#3671)
* lnproxy: fix api access through nginx
* fix tor config and fit the menu
* add to the menu and provision
* merge #3682
* cln update to v23.02, backup-plugin update, add poetry (#3684)
* cln backup-plugin update, add poetry
* fix mkdir error, remove commented code, fmt #3677
* poetry and path fixes
* add terminal feedback, format #3676
* detect the full name of the plugin
* install pyln-client tqdm with pip
* git-verify: add --keyid-format LONG
to recognise if the signing key is not the main key
* cln update to v23.02
* cln-grpc: add protobuf-compiler dep
* rtl update to v0.13.6 and formatting
* C-lightningREST update to v0.10.1
* CLN FAQ update (#3666)
* improve the detection of existing cln aliases
* add the emergencyrecover instructions to CLN FAQ
* update help entries
* Update Tallycoin to version 1.8.0 (#3693)
* add tallycoin update info to CHANGES
* Fix typo in README.md (#3699)
excepted -> accepted
* #3694 add LCD info
* #3664 att timeout 30s to ln monitor calls (#3665)
* fix setting LND_REST_ENDPOINT (#3689)
* btcpay update v1.8.2, postgres database fix (#3697)
* btcpay update v1.8.0, postgres database fix
* btcpayserver update to v1.8.2
* update lnbits to 0.10.2 and use poetry instead of venv (#3703)
* fix apt update Key error for influx repo (#3711)
Co-authored-by: Patrick Scheich <patrick.scheich@syscovery.de>
* fix missing timeout value for nc cmnd (#3712)
Co-authored-by: Patrick Scheich <patrick.scheich@syscovery.de>
* #3706 Update CLN v23.02.2 (#3716)
* used patched/rolledback 23.02.2 release
* check rusty sig
* fix typo
* fix default lightning setting
* #3683 Update LIT to 0.8.6 (#3717)
* update LIT to 0.8.6
* activate lnd rpcmiddleware
* CHANGES.md
* #3667 change all up/download from sftp tp scp (#3718)
* #3722 add no hostkeys available detection (#3723)
* #1186 FinTS/HBCI interface (#3704)
* #1186 FinTS install script first draft
* only start app when blitz is ready
* improve menu
* improve dit lnbits config
* preserve edit
* improve edit
* improve edit
* fix insertion
* dont use fingerprint
* now use main repo
* add port
* show local ip
* fix typo
* show port SSL
* Update bonus.lndg.sh (#3725)
* Update bonus.lndg.sh
Changes version to v1.6.0.
Fixes update menu bug.
Cleans up code a bit (removes tabs and changes to spaces to match raspiblitz formats).
* Update bonus.lndg.sh
Cleaned up code, added requirements.txt install to updates (needed for this update, may be needed in future).
* #3725 update lndg version in CHANGES
* #3692 update lnd to v0.16.0-beta (#3732)
* update SD CARD base image info
* Clenaup CHANGES info
* RTL install fix (#3739)
* c-lightning-REST update to 0.10.2, fmt
* rtl: npm insatll with --legacy-peer-deps
* purge c-lightning-REST as well with RTL
* jam update to v0.1.5 (#3736)
* 3733 CLN GRPC > JRPC (#3741)
* change exit code
* change to cln_jrpc
* deactivate the cln_grpc settings
* set v1.9.0rc3 version
---------
Co-authored-by: openoms <oms@tuta.io>
Co-authored-by: Metallicc <72348+metallicc@users.noreply.github.com>
Co-authored-by: openoms <43343391+openoms@users.noreply.github.com>
Co-authored-by: DJ Booth <djbooth007@gmail.com>
Co-authored-by: Yuck Fou <115867254+YuckFouBTC@users.noreply.github.com>
Co-authored-by: dni ⚡ <office@dnilabs.com>
Co-authored-by: PatrickScheich <50054697+PatrickScheich@users.noreply.github.com>
Co-authored-by: Patrick Scheich <patrick.scheich@syscovery.de>
Co-authored-by: allyourbankarebelongtous <100060902+allyourbankarebelongtous@users.noreply.github.com>
2023-04-08 23:10:01 +02:00
sudo -u postgres psql -c "CREATE DATABASE btcpaymainnet TEMPLATE template0 LC_CTYPE 'C' LC_COLLATE 'C' ENCODING 'UTF8';"
2023-02-04 12:37:59 +00:00
sudo -u postgres psql -c "create user btcpay with encrypted password 'raspiblitz';"
sudo -u postgres psql -c "grant all privileges on database btcpaymainnet to btcpay;"
fi
echo "# List databases with: sudo -u postgres psql -c '\l'"
sudo -u postgres psql -c '\l'
fi
echo "# Regenerate the btcpayserver settings (includes the LND TLS thumbprint)"
2022-07-12 13:02:15 +01:00
# https://docs.btcpayserver.org/Deployment/ManualDeploymentExtended/#3-create-a-configuration-file
echo "
### Global settings ###
network = mainnet
### Server settings ###
port = 23000
bind = 127.0.0.1
externalurl = https://$BTCPayDomain
### NBXplorer settings ###
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
### Database ###
2023-02-04 12:37:59 +00:00
${ databaseOption }
2022-07-12 13:02:15 +01:00
explorer.postgres= User ID = nbxplorer; Host = localhost; Port = 5432; Application Name = nbxplorer; MaxPoolSize = 20; Database = nbxplorermainnet; Password = 'raspiblitz' ;
" | sudo -u btcpay tee /home/btcpay/.btcpayserver/Main/settings.config
2023-02-04 12:37:59 +00:00
}
function BtcPayService( ) {
if sudo ls /mnt/hdd/app-data/.btcpayserver/Main/sqllite.db 1>/dev/null 2>& 1; then
echo "# sqlite database exists"
databaseOption = " -- --sqlitefile=sqllite.db"
else
echo "# sqlite database does not exist, using postgresql"
databaseOption = ""
fi
# see the configuration options with:
# sudo -u btcpay /home/btcpay/dotnet/dotnet run --no-launch-profile --no-build -c Release --project "/home/btcpay/btcpayserver/BTCPayServer/BTCPayServer.csproj" -- -h
# run manually to debug:
# sudo -u btcpay /home/btcpay/dotnet/dotnet run --no-launch-profile --no-build -c Release --project "/home/btcpay/btcpayserver/BTCPayServer/BTCPayServer.csproj" -- --sqlitefile=sqllite.db
echo "# create the btcpayserver.service"
echo "
[ Unit]
Description = BtcPayServer daemon
Requires = nbxplorer.service
After = nbxplorer.service
[ Service]
ExecStart = /home/btcpay/dotnet/dotnet run --no-launch-profile --no-build \
-c Release --project \" /home/btcpay/btcpayserver/BTCPayServer/BTCPayServer.csproj\" ${ databaseOption }
User = btcpay
Group = btcpay
Type = simple
PIDFile = /run/btcpayserver/btcpayserver.pid
Restart = always
RestartSec = 10
# Hardening measures
PrivateTmp = true
ProtectSystem = full
NoNewPrivileges = true
PrivateDevices = true
[ Install]
WantedBy = multi-user.target
" | sudo tee /etc/systemd/system/btcpayserver.service
sudo systemctl daemon-reload
2022-07-12 13:02:15 +01:00
}
2020-07-14 23:46:06 +02:00
if [ " $1 " = "status" ] ; then
2020-07-18 13:40:41 +02:00
2022-12-14 11:54:06 +01:00
echo " version=' ${ BTCPayVersion } ' "
2023-02-04 12:37:59 +00:00
isInstalled = $( compgen -u | grep -c btcpay)
echo " prepared= ${ isInstalled } "
isActive = $( sudo ls /etc/systemd/system/btcpayserver.service 2>/dev/null | grep -c 'btcpayserver.service' )
echo " installed= ${ isActive } "
2020-07-18 13:40:41 +02:00
2022-12-13 15:28:05 +01:00
if [ " ${ BTCPayServer } " = "on" ] ; then
2020-07-18 13:40:41 +02:00
echo "switchedon=1"
2021-08-04 00:18:30 +02:00
localIP = $( hostname -I | awk '{print $1}' )
2020-07-14 23:46:06 +02:00
echo " localIP=' ${ localIP } ' "
2022-05-05 10:59:50 +02:00
echo "httpPort='23000'"
2020-07-14 23:46:06 +02:00
echo "httpsPort='23001'"
2022-05-05 10:59:50 +02:00
echo "httpsForced='1'"
echo "httpsSelfsigned='1'" # TODO: change later if IP2Tor+LetsEncrypt is active
echo "authMethod='userdefined'"
2020-07-14 23:46:06 +02:00
echo " publicIP=' ${ publicIP } ' "
2020-01-27 02:00:38 +01:00
2021-03-16 22:49:13 +00:00
# check for LetsEncryptDomain for DynDns
2020-07-14 23:46:06 +02:00
error = ""
2022-12-13 15:28:05 +01:00
source <( sudo /home/admin/config.scripts/blitz.subscriptions.ip2tor.py ip-by-tor $publicIP 2>/dev/null)
2020-07-14 23:46:06 +02:00
if [ ${# error } -eq 0 ] ; then
echo " publicDomain=' ${ domain } ' "
fi
2020-01-27 02:00:38 +01:00
2020-07-14 23:46:06 +02:00
sslFingerprintIP = $( openssl x509 -in /mnt/hdd/app-data/nginx/tls.cert -fingerprint -noout 2>/dev/null | cut -d"=" -f2)
echo " sslFingerprintIP=' ${ sslFingerprintIP } ' "
2020-01-27 02:00:38 +01:00
2020-07-14 23:46:06 +02:00
toraddress = $( sudo cat /mnt/hdd/tor/btcpay/hostname 2>/dev/null)
echo " toraddress=' ${ toraddress } ' "
2020-01-27 02:00:38 +01:00
2020-07-14 23:46:06 +02:00
sslFingerprintTOR = $( openssl x509 -in /mnt/hdd/app-data/nginx/tor_tls.cert -fingerprint -noout 2>/dev/null | cut -d"=" -f2)
echo " sslFingerprintTOR=' ${ sslFingerprintTOR } ' "
# check for IP2TOR
error = ""
source <( sudo /home/admin/config.scripts/blitz.subscriptions.ip2tor.py ip-by-tor $toraddress )
if [ ${# error } -eq 0 ] ; then
echo " ip2torType=' ${ ip2tor -v1 } ' "
echo " ip2torID=' ${ id } ' "
echo " ip2torIP=' ${ ip } ' "
echo " ip2torPort=' ${ port } ' "
# check for LetsEnryptDomain on IP2TOR
error = ""
source <( sudo /home/admin/config.scripts/blitz.subscriptions.letsencrypt.py domain-by-ip $ip )
if [ ${# error } -eq 0 ] ; then
echo " ip2torDomain=' ${ domain } ' "
2020-09-14 15:29:50 +02:00
domainWarning = $( sudo /home/admin/config.scripts/blitz.subscriptions.letsencrypt.py subscription-detail ${ domain } ${ port } | jq -r ".warning" )
if [ ${# domainWarning } -gt 0 ] ; then
echo " ip2torWarn=' ${ domainWarning } ' "
fi
2020-07-14 23:46:06 +02:00
fi
2020-06-25 18:57:05 +02:00
fi
2020-07-14 23:46:06 +02:00
# check for error
isDead = $( sudo systemctl status btcpayserver | grep -c 'inactive (dead)' )
if [ ${ isDead } -eq 1 ] ; then
echo "error='Service Failed'"
2020-06-25 19:58:22 +02:00
fi
2020-07-14 23:46:06 +02:00
else
2020-07-18 13:40:41 +02:00
echo "switchedon=0"
2020-07-14 23:46:06 +02:00
fi
exit 0
fi
# show info menu
if [ " $1 " = "menu" ] ; then
2020-11-11 16:40:48 +00:00
# get status info
2020-07-14 23:46:06 +02:00
echo "# collecting status info ... (please wait)"
source <( sudo /home/admin/config.scripts/bonus.btcpayserver.sh status)
2020-07-18 13:40:41 +02:00
if [ ${ switchedon } -eq 0 ] ; then
2023-02-04 12:37:59 +00:00
whiptail --title " BTCPay Server " --msgbox "BTCPay Server is not activated." 7 36
exit 0
2020-07-18 13:40:41 +02:00
fi
if [ ${ installed } -eq 0 ] ; then
2023-02-04 12:37:59 +00:00
whiptail --title " BTCPay Server " --msgbox "BTCPay Server needs to be re-installed.\nPress OK to start process." 8 45
/home/admin/config.scripts/bonus.btcpayserver.sh on
exit 0
2020-07-18 13:40:41 +02:00
fi
2020-11-23 21:27:39 +01:00
# display possible problems with IP2TOR setup
2020-09-14 15:29:50 +02:00
if [ ${# ip2torWarn } -gt 0 ] ; then
2020-11-23 21:27:39 +01:00
whiptail --title " Warning " \
2023-02-04 12:37:59 +00:00
--yes-button "Back" \
--no-button "Continue Anyway" \
--yesno " Your IP2TOR+LetsEncrypt may have problems:\n ${ ip2torWarn } \n\nCheck if locally responding: https:// ${ localIP } : ${ httpsPort } \n\nCheck if service is reachable over Tor:\n ${ toraddress } " 14 72
2020-11-23 21:27:39 +01:00
if [ " $? " != "1" ] ; then
exit 0
2023-02-04 12:37:59 +00:00
fi
2020-09-14 15:29:50 +02:00
fi
2021-08-19 21:06:27 +01:00
text = " Local Web Browser: https:// ${ localIP } : ${ httpsPort } "
2020-07-14 23:46:06 +02:00
if [ ${# publicDomain } -gt 0 ] ; then
2023-02-04 12:37:59 +00:00
text = " ${ text }
2020-07-14 23:46:06 +02:00
Public Domain: https://${ publicDomain } :${ httpsPort }
2021-12-14 23:34:35 +01:00
port forwarding on router needs to be active & may change port"
2020-07-14 23:46:06 +02:00
fi
text = " ${ text }
2021-12-14 23:34:35 +01:00
SHA1 ${ sslFingerprintIP } "
2020-07-14 23:46:06 +02:00
if [ " ${ runBehindTor } " = "on" ] && [ ${# toraddress } -gt 0 ] ; then
2022-02-13 12:23:34 +00:00
sudo /home/admin/config.scripts/blitz.display.sh qr " ${ toraddress } "
2020-07-14 23:46:06 +02:00
text = " ${ text } \n
2020-11-11 16:40:48 +00:00
TOR Browser Hidden Service address ( see the QR onLCD) :
2020-07-14 23:46:06 +02:00
${ toraddress } "
fi
2021-12-14 23:34:35 +01:00
2020-07-14 23:46:06 +02:00
if [ ${# ip2torDomain } -gt 0 ] ; then
text = " ${ text } \n
IP2TOR+LetsEncrypt: https://${ ip2torDomain } :${ ip2torPort }
SHA1 ${ sslFingerprintTOR } "
elif [ ${# ip2torIP } -gt 0 ] ; then
text = " ${ text } \n
IP2TOR: https://${ ip2torIP } :${ ip2torPort }
SHA1 ${ sslFingerprintTOR }
go MAINMENU > SUBSCRIBE and add LetsEncrypt HTTPS Domain"
2023-02-03 17:44:24 +01:00
elif [ ${# publicDomain } -eq 0 ] ; then
text = " ${ text } \n
To enable easy reachability with normal browser from the outside
consider adding a IP2TOR Bridge: MAINMENU > SUBSCRIBE > IP2TOR"
2020-01-27 02:00:38 +01:00
fi
2023-02-04 12:37:59 +00:00
text = " ${ text } \n
2020-09-17 16:53:44 +02:00
To get the 'Connection String' to activate Lightning Payments:
2021-04-18 18:04:59 +02:00
MAINMENU > CONNECT > BTCPay Server"
2020-09-17 16:53:44 +02:00
whiptail --title " BTCPay Server " --msgbox " ${ text } " 17 69
2021-12-14 23:34:35 +01:00
2022-02-13 12:23:34 +00:00
sudo /home/admin/config.scripts/blitz.display.sh hide
2020-11-11 16:40:48 +00:00
echo "# please wait ..."
2020-01-27 02:00:38 +01:00
exit 0
fi
2020-04-28 14:14:17 +01:00
# write-tls-macaroon
2020-04-28 14:40:09 +01:00
if [ " $1 " = "write-tls-macaroon" ] ; then
2020-05-01 11:34:52 +02:00
2020-11-11 16:40:48 +00:00
echo "# make sure btcpay is member of lndadmin"
2020-05-01 11:39:29 +02:00
sudo /usr/sbin/usermod --append --groups lndadmin btcpay
2020-11-11 16:40:48 +00:00
echo "# make sure symlink to central app-data directory exists"
2020-05-01 11:34:52 +02:00
if ! [ [ -L "/home/btcpay/.lnd" ] ] ; then
2023-02-04 12:37:59 +00:00
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
2020-05-01 11:34:52 +02:00
fi
2020-04-28 14:14:17 +01:00
# copy admin macaroon
2020-11-11 16:40:48 +00:00
echo "# extra symlink to admin.macaroon for btcpay"
2020-05-01 11:34:52 +02:00
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
2022-07-12 13:02:15 +01:00
BtcPayConfig
2021-12-14 23:34:35 +01:00
2020-07-18 22:49:26 +02:00
if [ " ${ state } " = = "ready" ] ; then
sudo systemctl restart btcpayserver
fi
2020-04-28 14:14:17 +01:00
exit 0
fi
2022-06-02 15:26:20 +01:00
# cln-lightning-rpc-access
if [ " $1 " = "cln-lightning-rpc-access" ] ; then
if [ " ${ cl } " = "on" ] ; then
source <( /home/admin/config.scripts/network.aliases.sh getvars cl mainnet)
2023-02-04 12:37:59 +00:00
if [ $( grep -c "^rpc-file-mode=0660" <${ CLCONF } ) -eq 0 ] ; then
2022-06-02 15:26:20 +01:00
echo "rpc-file-mode=0660" | tee -a ${ CLCONF }
if [ " ${ state } " = = "ready" ] ; then
sudo systemctl restart lightningd
fi
fi
echo "# make sure btcpay is member of the bitcoin group"
sudo /usr/sbin/usermod --append --groups bitcoin btcpay
if [ " ${ state } " = = "ready" ] ; then
sudo systemctl restart btcpayserver
fi
else
echo "# Install CLN first"
exit 1
fi
echo "
2022-07-12 13:02:15 +01:00
In the BTCPayServer Lightning Wallet settings 'Connect to a Lightning node' page
2022-06-02 15:26:20 +01:00
fill in the 'Connection configuration for your custom Lightning node:' box on with:
type = clightning; server = unix:///home/bitcoin/.lightning/bitcoin/lightning-rpc
"
exit 0
fi
2022-12-13 15:28:05 +01:00
########################################
# INSTALL (just user, code & compile)
########################################
if [ " $1 " = "install" ] ; then
# check if code is already installed
isInstalled = $( compgen -u | grep -c btcpay)
if [ " ${ isInstalled } " != "0" ] ; then
echo "# already installed"
exit 0
fi
echo "# create btcpay user"
sudo adduser --disabled-password --gecos "" btcpay
cd /home/btcpay || exit 1
echo "# install .NET"
# https://dotnet.microsoft.com/en-us/download/dotnet/6.0
sudo apt-get -y install libunwind8 gettext libssl1.0
cpu = $( uname -m)
if [ " ${ cpu } " = "aarch64" ] ; then
binaryVersion = "arm64"
dotNetdirectLink = "https://download.visualstudio.microsoft.com/download/pr/d43345e2-f0d7-4866-b56e-419071f30ebe/68debcece0276e9b25a65ec5798cf07b/dotnet-sdk-6.0.101-linux-arm64.tar.gz"
dotNetChecksum = "04cd89279f412ae6b11170d1724c6ac42bb5d4fae8352020a1f28511086dd6d6af2106dd48ebe3b39d312a21ee8925115de51979687a9161819a3a29e270a954"
elif [ " ${ cpu } " = "x86_64" ] ; then
binaryVersion = "x64"
dotNetdirectLink = "https://download.visualstudio.microsoft.com/download/pr/ede8a287-3d61-4988-a356-32ff9129079e/bdb47b6b510ed0c4f0b132f7f4ad9d5a/dotnet-sdk-6.0.101-linux-x64.tar.gz"
dotNetChecksum = "ca21345400bcaceadad6327345f5364e858059cfcbc1759f05d7df7701fec26f1ead297b6928afa01e46db6f84e50770c673146a10b9ff71e4c7f7bc76fbf709"
else
echo " # FAIL! CPU ( ${ cpu } ) not supported. "
echo "result='dotnet cpu not supported'"
exit 1
fi
dotNetName = " dotnet-sdk-6.0.101-linux- ${ binaryVersion } .tar.gz "
sudo rm /home/btcpay/${ dotnetName } 2>/dev/null
sudo -u btcpay wget " ${ dotNetdirectLink } " -O " ${ dotNetName } "
# 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 "result='dotnet wrong checksum'"
exit 1
fi
sudo -u btcpay mkdir /home/btcpay/dotnet
sudo -u btcpay tar -xvf ${ dotNetName } -C /home/btcpay/dotnet
sudo rm -f *.tar.gz*
echo "DOTNET_CLI_TELEMETRY_OPTOUT=1" | sudo tee -a /etc/environment
# NBXplorer
2023-02-04 12:37:59 +00:00
echo " # Install NBXplorer $NBXplorerVersion "
2022-12-13 15:28:05 +01:00
cd /home/btcpay || exit 1
2023-02-04 12:37:59 +00:00
echo " # Download the NBXplorer source code $NBXplorerVersion "
2022-12-13 15:28:05 +01:00
sudo -u btcpay git clone https://github.com/dgarage/NBXplorer.git 2>/dev/null
cd NBXplorer || exit 1
sudo -u btcpay git reset --hard $NBXplorerVersion
# PGP verify
PGPsigner = "nicolasdorier"
PGPpubkeyLink = "https://keybase.io/nicolasdorier/pgp_keys.asc"
PGPpubkeyFingerprint = "AB4CFA9895ACA0DBE27F6B346618763EF09186FE"
sudo -u btcpay /home/admin/config.scripts/blitz.git-verify.sh " ${ PGPsigner } " " ${ PGPpubkeyLink } " " ${ PGPpubkeyFingerprint } " || exit 1
2023-02-04 12:37:59 +00:00
echo " # Build NBXplorer $NBXplorerVersion "
2022-12-13 15:28:05 +01:00
# from the build.sh with path
2023-02-07 20:32:22 +00:00
sudo -u btcpay /home/btcpay/dotnet/dotnet build -c Release NBXplorer/NBXplorer.csproj || exit 1
2022-12-13 15:28:05 +01:00
# BTCPayServer
echo "# Install BTCPayServer"
cd /home/btcpay || exit 1
2023-02-04 12:37:59 +00:00
echo " # Download the BTCPayServer source code $BTCPayVersion "
2022-12-13 15:28:05 +01:00
sudo -u btcpay git clone https://github.com/btcpayserver/btcpayserver.git 2>/dev/null
cd btcpayserver || exit 1
sudo -u btcpay git reset --hard $BTCPayVersion
#sudo -u btcpay /home/admin/config.scripts/blitz.git-verify.sh "web-flow" "https://github.com/web-flow.gpg" "4AEE18F83AFDEB23" || exit 1
PGPsigner = "nicolasdorier"
PGPpubkeyLink = "https://keybase.io/nicolasdorier/pgp_keys.asc"
PGPpubkeyFingerprint = "AB4CFA9895ACA0DBE27F6B346618763EF09186FE"
#PGPsigner="Kukks"
#PGPpubkeyLink="https://github.com/${PGPsigner}.gpg"
#PGPpubkeyFingerprint="8E5530D9D1C93097"
sudo -u btcpay /home/admin/config.scripts/blitz.git-verify.sh " ${ PGPsigner } " " ${ PGPpubkeyLink } " " ${ PGPpubkeyFingerprint } " || exit 1
2023-02-04 12:37:59 +00:00
echo " # Build BTCPayServer $BTCPayVersion "
2022-12-13 15:28:05 +01:00
# from the build.sh with path
2023-02-04 12:37:59 +00:00
sudo -u btcpay /home/btcpay/dotnet/dotnet build -c Release \
2023-02-07 20:32:22 +00:00
/home/btcpay/btcpayserver/BTCPayServer/BTCPayServer.csproj || exit 1
2022-12-13 15:28:05 +01:00
exit 0
fi
########################################
# UNINSTALL (remove from system)
########################################
if [ " $1 " = "uninstall" ] ; then
isActive = $( sudo ls /etc/systemd/system/btcpayserver.service 2>/dev/null | grep -c 'btcpayserver.service' )
if [ " ${ isActive } " != "0" ] ; then
echo "# cannot uninstall if still 'on'"
exit 1
fi
# clear dotnet cache
/home/btcpay/dotnet/dotnet nuget locals all --clear
# remove dotnet
sudo rm -rf /usr/share/dotnet
# nuke user
sudo userdel -rf btcpay 2>/dev/null
exit 0
fi
########################################
# ON (activate & config)
########################################
2019-12-04 08:13:21 +00:00
if [ " $1 " = "1" ] || [ " $1 " = "on" ] ; then
2019-12-05 13:37:33 +00:00
2022-12-13 15:28:05 +01:00
# check if already active
isActive = $( sudo ls /etc/systemd/system/btcpayserver.service 2>/dev/null | grep -c 'btcpayserver.service' )
if [ " ${ isActive } " != "0" ] ; then
echo "result='already active'"
exit 1
fi
# check if code is already installed
isInstalled = $( compgen -u | grep -c btcpay)
if [ " ${ isInstalled } " = = "0" ] ; then
echo "# Installing code base & dependencies first .."
/home/admin/config.scripts/bonus.btcpayserver.sh install || exit 1
fi
echo "# ACTIVATE BTCPAYSERVER"
echo "# install postreSQL"
sudo /home/admin/config.scripts/bonus.postgresql.sh on || exit 1
2020-06-11 18:15:42 +01:00
# setup nginx symlinks
if ! [ -f /etc/nginx/sites-available/btcpay_ssl.conf ] ; then
2023-02-04 12:37:59 +00:00
sudo cp /home/admin/assets/nginx/sites-available/btcpay_ssl.conf /etc/nginx/sites-available/btcpay_ssl.conf
2020-06-11 18:15:42 +01:00
fi
if ! [ -f /etc/nginx/sites-available/btcpay_tor.conf ] ; then
2023-02-04 12:37:59 +00:00
sudo cp /home/admin/assets/nginx/sites-available/btcpay_tor.conf /etc/nginx/sites-available/btcpay_tor.conf
2020-06-11 18:15:42 +01:00
fi
if ! [ -f /etc/nginx/sites-available/btcpay_tor_ssl.conf ] ; then
2023-02-04 12:37:59 +00:00
sudo cp /home/admin/assets/nginx/sites-available/btcpay_tor_ssl.conf /etc/nginx/sites-available/btcpay_tor_ssl.conf
2020-06-11 18:15:42 +01:00
fi
sudo ln -sf /etc/nginx/sites-available/btcpay_ssl.conf /etc/nginx/sites-enabled/
sudo ln -sf /etc/nginx/sites-available/btcpay_tor.conf /etc/nginx/sites-enabled/
sudo ln -sf /etc/nginx/sites-available/btcpay_tor_ssl.conf /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
2021-12-14 23:34:35 +01:00
2020-06-11 18:15:42 +01:00
# open the firewall
2021-03-16 22:49:13 +00:00
echo "# Updating the firewall"
2020-06-11 18:15:42 +01:00
sudo ufw allow 23000 comment 'allow BTCPay HTTP'
sudo ufw allow 23001 comment 'allow BTCPay HTTPS'
2020-11-11 16:40:48 +00:00
echo
2020-06-11 18:15:42 +01:00
# Hidden Service for BTCPay if Tor is active
if [ " ${ runBehindTor } " = "on" ] ; then
2021-12-14 23:34:35 +01:00
# make sure to keep in sync with tor.network.sh script
/home/admin/config.scripts/tor.onion-service.sh btcpay 80 23002 443 23003
2020-01-28 17:54:28 +01:00
fi
2020-01-28 16:30:08 +01:00
2020-01-13 15:00:22 +00:00
# check for $BTCPayDomain
source /mnt/hdd/raspiblitz.conf
2022-12-13 15:28:05 +01:00
if [ " ${ BTCPayDomain } " = = "off" ] ; then
BTCPayDomain = ""
fi
2019-12-05 13:37:33 +00:00
2020-04-28 14:14:17 +01:00
# stop services
2020-11-11 16:40:48 +00:00
echo "# making sure services are not running"
2020-04-28 14:14:17 +01:00
sudo systemctl stop nbxplorer 2>/dev/null
sudo systemctl stop btcpayserver 2>/dev/null
2022-12-13 15:28:05 +01:00
cd /home/btcpay || exit 1
2020-06-04 14:33:19 +01:00
2022-12-13 15:28:05 +01:00
# store BTCpay data on HDD
sudo mkdir /mnt/hdd/app-data/.btcpayserver 2>/dev/null
2020-05-01 11:34:52 +02:00
2022-12-13 15:28:05 +01:00
# move old btcpay data to app-data
sudo mv -f /mnt/hdd/.btcpayserver/* /mnt/hdd/app-data/.btcpayserver/ 2>/dev/null
sudo rm -rf /mnt/hdd/.btcpayserver 2>/dev/null
2020-05-01 11:34:52 +02:00
2022-12-13 15:28:05 +01:00
sudo chown -R btcpay:btcpay /mnt/hdd/app-data/.btcpayserver
sudo ln -s /mnt/hdd/app-data/.btcpayserver /home/btcpay/ 2>/dev/null
sudo chown -R btcpay:btcpay /home/btcpay/.btcpayserver
2020-05-01 11:34:52 +02:00
2022-12-13 15:28:05 +01:00
## see the configuration options with:
# sudo -u btcpay /home/btcpay/dotnet/dotnet run --no-launch-profile --no-build -c Release --project "NBXplorer/NBXplorer.csproj" -c /home/btcpay/.nbxplorer/Main/settings.config -h
##sudo systenmct run manually to debug:
# sudo su - btcpay
# cd NBXplorer
# /home/btcpay/dotnet/dotnet run --no-launch-profile --no-build -c Release --project "NBXplorer/NBXplorer.csproj" -- $@
echo "# create the nbxplorer.service"
echo "
2019-12-04 08:13:21 +00:00
[ Unit]
Description = NBXplorer daemon
Requires = bitcoind.service
After = bitcoind.service
[ Service]
2021-09-17 00:26:35 +01:00
WorkingDirectory = /home/btcpay/NBXplorer
ExecStart = /home/btcpay/dotnet/dotnet run --no-launch-profile --no-build \
2022-07-12 13:02:15 +01:00
-c Release --project \" NBXplorer/NBXplorer.csproj\" -- \$ @
2019-12-04 08:13:21 +00:00
User = btcpay
Group = btcpay
2020-01-15 11:23:32 +01:00
Type = simple
2019-12-04 08:13:21 +00:00
PIDFile = /run/nbxplorer/nbxplorer.pid
Restart = on-failure
2022-07-12 13:02:15 +01:00
RestartSec = 20
2019-12-04 08:13:21 +00:00
2021-08-04 00:18:30 +02:00
# Hardening measures
2019-12-04 08:13:21 +00:00
PrivateTmp = true
ProtectSystem = full
NoNewPrivileges = true
PrivateDevices = true
[ Install]
WantedBy = multi-user.target
2020-01-13 15:00:22 +00:00
" | sudo tee /etc/systemd/system/nbxplorer.service
2020-05-01 11:34:52 +02:00
2022-12-13 15:28:05 +01:00
sudo systemctl daemon-reload
# start to create settings.config
sudo systemctl enable nbxplorer
2020-07-24 00:42:56 +02:00
2022-12-13 15:28:05 +01:00
if [ " ${ state } " = = "ready" ] ; then
echo "# Starting nbxplorer"
sudo systemctl start nbxplorer
echo "# Checking for nbxplorer config"
2023-02-04 12:37:59 +00:00
while [ ! -f "/home/btcpay/.nbxplorer/Main/settings.config" ] ; do
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"
fi
2022-12-13 15:28:05 +01:00
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"
fi
2020-05-01 11:34:52 +02:00
2022-12-13 15:28:05 +01:00
NBXplorerConfig
2021-11-30 11:43:52 +00:00
2022-12-13 15:28:05 +01:00
# whitelist localhost in bitcoind
2023-02-04 12:37:59 +00:00
if ! sudo grep -Eq "^whitelist=127.0.0.1" /mnt/hdd/bitcoin/bitcoin.conf; then
2022-12-13 15:28:05 +01:00
echo "whitelist=127.0.0.1" | sudo tee -a /mnt/hdd/bitcoin/bitcoin.conf
bitcoindRestart = yes
fi
if [ " ${ state } " = = "ready" ] ; then
if [ " ${ bitcoindRestart } " = = "yes" ] ; then
echo "# Restarting bitcoind"
sudo systemctl restart bitcoind
2021-12-14 23:34:35 +01:00
fi
2022-12-13 15:28:05 +01:00
sudo systemctl restart nbxplorer
fi
2020-05-01 11:34:52 +02:00
2023-02-04 12:37:59 +00:00
BtcPayConfig
2019-12-04 08:13:21 +00:00
2023-02-04 12:37:59 +00:00
BtcPayService
2021-08-04 00:18:30 +02:00
2021-03-16 22:49:13 +00:00
sudo systemctl enable btcpayserver
2022-12-13 15:28:05 +01:00
if [ " ${ state } " = = "ready" ] ; then
echo "# Starting btcpayserver"
sudo systemctl start btcpayserver
echo "# Checking for btcpayserver config"
while [ ! -f "/home/btcpay/.btcpayserver/Main/settings.config" ] ; do
echo "# Waiting for btcpayserver to start - CTRL+C to abort .."
sleep 30
2023-02-04 12:37:59 +00:00
hasFailed = $( sudo systemctl status btcpayserver | grep -c "Active: failed" )
2022-12-13 15:28:05 +01:00
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"
fi
done
2020-05-01 11:34:52 +02:00
else
2023-02-04 12:37:59 +00:00
echo "# Because the system is not 'ready' the service 'btcpayserver' will not be started at this point .. it is enabled and will start on next reboot"
2022-12-13 15:28:05 +01:00
fi
sudo -u btcpay mkdir -p /home/btcpay/.btcpayserver/Main/
if [ " ${ lnd } " = on ] ; then
/home/admin/config.scripts/bonus.btcpayserver.sh write-tls-macaroon
fi
if [ " ${ cl } " = on ] ; then
/home/admin/config.scripts/bonus.btcpayserver.sh cln-lightning-rpc-access
2020-05-01 11:34:52 +02:00
fi
2019-12-05 15:31:07 +00:00
# setting value in raspi blitz config
2021-12-14 23:34:35 +01:00
/home/admin/config.scripts/blitz.conf.sh set BTCPayServer "on"
2022-05-05 10:59:50 +02:00
2022-05-10 10:01:26 +01:00
# needed for API/WebUI as signal that install ran thru
2022-05-05 10:59:50 +02:00
echo "result='OK'"
2019-12-04 08:13:21 +00:00
exit 0
fi
2022-12-13 15:28:05 +01:00
########################################
# OFF (deactivate)
########################################
2019-12-04 08:13:21 +00:00
if [ " $1 " = "0" ] || [ " $1 " = "off" ] ; then
2020-07-23 23:54:25 +02:00
# check for second parameter: should data be deleted?
deleteData = 0
if [ " $2 " = "--delete-data" ] ; then
deleteData = 1
elif [ " $2 " = "--keep-data" ] ; then
deleteData = 0
else
2020-10-14 23:25:39 +02:00
if ( whiptail --title " DELETE DATA? " --yesno "Do you want to delete\nthe BTCPay Server Data?" 8 30) ; then
2020-07-23 23:54:25 +02:00
deleteData = 1
2023-02-04 12:37:59 +00:00
else
2020-07-23 23:54:25 +02:00
deleteData = 0
fi
fi
2020-07-23 23:58:34 +02:00
echo " # deleteData( ${ deleteData } ) "
2020-07-23 23:54:25 +02:00
2019-12-04 08:13:21 +00:00
# setting value in raspi blitz config
2021-12-14 23:34:35 +01:00
/home/admin/config.scripts/blitz.conf.sh set BTCPayServer "off"
2019-12-04 08:13:21 +00:00
2020-07-12 20:05:41 +02:00
# Hidden Service if Tor is active
if [ " ${ runBehindTor } " = "on" ] ; then
2021-12-14 23:34:35 +01:00
/home/admin/config.scripts/tor.onion-service.sh off btcpay
2020-07-12 20:05:41 +02:00
fi
2022-12-13 15:28:05 +01:00
# removing service: btcpay
sudo systemctl stop btcpayserver
sudo systemctl disable btcpayserver
sudo rm /etc/systemd/system/btcpayserver.service
2022-05-05 10:59:50 +02:00
2022-12-13 15:28:05 +01:00
# removing service: nbxplorer
2022-05-28 19:44:52 +01:00
sudo systemctl stop nbxplorer
sudo systemctl disable nbxplorer
sudo rm /etc/systemd/system/nbxplorer.service
2022-12-13 15:28:05 +01:00
2022-05-28 19:44:52 +01:00
# clear app config (not user data)
sudo rm -f /home/btcpay/.nbxplorer/Main/settings.config
sudo rm -f /home/btcpay/.btcpayserver/Main/settings.config
2022-12-13 15:28:05 +01:00
2022-05-28 19:44:52 +01:00
# clear nginx config (from btcpaysetdomain)
sudo rm -f /etc/nginx/sites-enabled/btcpayserver
sudo rm -f /etc/nginx/sites-available/btcpayserver
2022-12-13 15:28:05 +01:00
2022-05-28 19:44:52 +01:00
# remove nginx symlinks
sudo rm -f /etc/nginx/sites-enabled/btcpay_ssl.conf
sudo rm -f /etc/nginx/sites-enabled/btcpay_tor.conf
sudo rm -f /etc/nginx/sites-enabled/btcpay_tor_ssl.conf
sudo rm -f /etc/nginx/sites-available/btcpay_ssl.conf
sudo rm -f /etc/nginx/sites-available/btcpay_tor.conf
sudo rm -f /etc/nginx/sites-available/btcpay_tor_ssl.conf
sudo nginx -t
sudo systemctl reload nginx
2022-12-13 15:28:05 +01:00
2022-05-28 19:44:52 +01:00
if [ ${ deleteData } -eq 1 ] ; then
echo "# deleting data"
2022-07-12 13:02:15 +01:00
sudo -u postgres psql -c "drop database nbxplorermainnet;"
sudo -u postgres psql -c "drop user nbxplorer;"
v1.9.0rc3 Merge (#3742)
* cln: use default normal feerate to withdraw all
* Bugfix: bad subsititution (#3668)
Fix for error:
/home/admin/config.scripts/bonus.go.sh: line 31: ${goOSversion{}: bad substitution
* whiptail one line
* fix syntax
* lnproxy: fix api access through nginx (#3671)
* lnproxy: fix api access through nginx
* fix tor config and fit the menu
* add to the menu and provision
* merge #3682
* cln update to v23.02, backup-plugin update, add poetry (#3684)
* cln backup-plugin update, add poetry
* fix mkdir error, remove commented code, fmt #3677
* poetry and path fixes
* add terminal feedback, format #3676
* detect the full name of the plugin
* install pyln-client tqdm with pip
* git-verify: add --keyid-format LONG
to recognise if the signing key is not the main key
* cln update to v23.02
* cln-grpc: add protobuf-compiler dep
* rtl update to v0.13.6 and formatting
* C-lightningREST update to v0.10.1
* CLN FAQ update (#3666)
* improve the detection of existing cln aliases
* add the emergencyrecover instructions to CLN FAQ
* update help entries
* Update Tallycoin to version 1.8.0 (#3693)
* add tallycoin update info to CHANGES
* Fix typo in README.md (#3699)
excepted -> accepted
* #3694 add LCD info
* #3664 att timeout 30s to ln monitor calls (#3665)
* fix setting LND_REST_ENDPOINT (#3689)
* btcpay update v1.8.2, postgres database fix (#3697)
* btcpay update v1.8.0, postgres database fix
* btcpayserver update to v1.8.2
* update lnbits to 0.10.2 and use poetry instead of venv (#3703)
* fix apt update Key error for influx repo (#3711)
Co-authored-by: Patrick Scheich <patrick.scheich@syscovery.de>
* fix missing timeout value for nc cmnd (#3712)
Co-authored-by: Patrick Scheich <patrick.scheich@syscovery.de>
* #3706 Update CLN v23.02.2 (#3716)
* used patched/rolledback 23.02.2 release
* check rusty sig
* fix typo
* fix default lightning setting
* #3683 Update LIT to 0.8.6 (#3717)
* update LIT to 0.8.6
* activate lnd rpcmiddleware
* CHANGES.md
* #3667 change all up/download from sftp tp scp (#3718)
* #3722 add no hostkeys available detection (#3723)
* #1186 FinTS/HBCI interface (#3704)
* #1186 FinTS install script first draft
* only start app when blitz is ready
* improve menu
* improve dit lnbits config
* preserve edit
* improve edit
* improve edit
* fix insertion
* dont use fingerprint
* now use main repo
* add port
* show local ip
* fix typo
* show port SSL
* Update bonus.lndg.sh (#3725)
* Update bonus.lndg.sh
Changes version to v1.6.0.
Fixes update menu bug.
Cleans up code a bit (removes tabs and changes to spaces to match raspiblitz formats).
* Update bonus.lndg.sh
Cleaned up code, added requirements.txt install to updates (needed for this update, may be needed in future).
* #3725 update lndg version in CHANGES
* #3692 update lnd to v0.16.0-beta (#3732)
* update SD CARD base image info
* Clenaup CHANGES info
* RTL install fix (#3739)
* c-lightning-REST update to 0.10.2, fmt
* rtl: npm insatll with --legacy-peer-deps
* purge c-lightning-REST as well with RTL
* jam update to v0.1.5 (#3736)
* 3733 CLN GRPC > JRPC (#3741)
* change exit code
* change to cln_jrpc
* deactivate the cln_grpc settings
* set v1.9.0rc3 version
---------
Co-authored-by: openoms <oms@tuta.io>
Co-authored-by: Metallicc <72348+metallicc@users.noreply.github.com>
Co-authored-by: openoms <43343391+openoms@users.noreply.github.com>
Co-authored-by: DJ Booth <djbooth007@gmail.com>
Co-authored-by: Yuck Fou <115867254+YuckFouBTC@users.noreply.github.com>
Co-authored-by: dni ⚡ <office@dnilabs.com>
Co-authored-by: PatrickScheich <50054697+PatrickScheich@users.noreply.github.com>
Co-authored-by: Patrick Scheich <patrick.scheich@syscovery.de>
Co-authored-by: allyourbankarebelongtous <100060902+allyourbankarebelongtous@users.noreply.github.com>
2023-04-08 23:10:01 +02:00
sudo -u postgres psql -c "drop database btcpaymainnet;"
sudo -u postgres psql -c "drop user btcpay;"
2022-05-28 19:44:52 +01:00
sudo rm -R /mnt/hdd/app-data/.btcpayserver/
else
echo "# keeping data"
fi
2023-02-04 12:37:59 +00:00
echo "# OK BTCPayServer deactivated."
echo "# delete the btcpay user home directory"
sudo userdel -rf btcpay 2>/dev/null
2022-05-28 19:44:52 +01:00
2022-05-10 10:01:26 +01:00
# needed for API/WebUI as signal that install ran thru
2022-05-05 10:59:50 +02:00
echo "result='OK'"
2022-05-28 19:44:52 +01:00
exit 0
2019-12-04 08:13:21 +00:00
fi
2021-11-30 11:43:52 +00:00
if [ " $1 " = "update" ] ; then
2023-02-04 12:37:59 +00:00
# prevent the git error 'detected dubious ownership in repository'
git config --global --add safe.directory /home/btcpay/NBXplorer
git config --global --add safe.directory /home/btcpay/btcpayserver
2022-07-12 13:02:15 +01:00
echo "# Update NBXplorer"
cd /home/btcpay || exit 1
cd NBXplorer || exit 1
# fetch latest master
if [ " $( sudo -u btcpay git fetch 2>& 1 | grep -c "Please tell me who you are" ) " -gt 0 ] ; then
sudo -u btcpay git config user.email "you@example.com"
sudo -u btcpay git config user.name "Your Name"
fi
sudo -u btcpay git fetch
# unset $1
set --
UPSTREAM = ${ 1 :- '@{u}' }
LOCAL = $( git rev-parse @)
REMOTE = $( git rev-parse " $UPSTREAM " )
if [ $LOCAL = $REMOTE ] ; then
TAG = $( git tag | sort -V | tail -1)
echo " # Up-to-date on version $TAG "
else
2023-02-04 12:37:59 +00:00
echo "# Pulling the latest changes..."
2022-07-12 13:02:15 +01:00
sudo -u btcpay git pull -p
TAG = $( git tag | sort -V | tail -1)
echo " # Reset to the latest release tag: $TAG "
sudo -u btcpay git reset --hard $TAG
PGPsigner = "nicolasdorier"
PGPpubkeyLink = "https://keybase.io/nicolasdorier/pgp_keys.asc"
PGPpubkeyFingerprint = "AB4CFA9895ACA0DBE27F6B346618763EF09186FE"
2023-02-04 12:37:59 +00:00
2022-07-12 13:02:15 +01:00
sudo -u btcpay /home/admin/config.scripts/blitz.git-verify.sh \
2023-02-04 12:37:59 +00:00
" ${ PGPsigner } " " ${ PGPpubkeyLink } " " ${ PGPpubkeyFingerprint } " || exit 1
echo " # Build NBXplorer $TAG "
2022-07-12 13:02:15 +01:00
# from the build.sh with path
sudo systemctl stop nbxplorer
2023-02-07 20:32:22 +00:00
sudo -u btcpay /home/btcpay/dotnet/dotnet build -c Release NBXplorer/NBXplorer.csproj || exit 1
2022-07-12 13:02:15 +01:00
# whitelist localhost in bitcoind
2023-02-04 12:37:59 +00:00
if ! sudo grep -Eq "^whitelist=127.0.0.1" /mnt/hdd/bitcoin/bitcoin.conf; then
2022-07-12 13:02:15 +01:00
echo "whitelist=127.0.0.1" | sudo tee -a /mnt/hdd/bitcoin/bitcoin.conf
echo "# Restarting bitcoind"
sudo systemctl restart bitcoind
fi
NBXplorerConfig
sudo systemctl start nbxplorer
echo " # Updated NBXplorer to $TAG "
fi
# always stop to BtcPayConfig
sudo systemctl stop btcpayserver
2021-11-30 11:43:52 +00:00
2022-07-12 13:02:15 +01:00
BtcPayConfig
2021-11-30 11:43:52 +00:00
2023-02-04 12:37:59 +00:00
# always update the btcpayserver.service
BtcPayService
2021-11-30 11:43:52 +00:00
echo "# Update BTCPayServer"
cd /home/btcpay || exit 1
cd btcpayserver || exit 1
# fetch latest master
if [ " $( sudo -u btcpay git fetch 2>& 1 | grep -c "Please tell me who you are" ) " -gt 0 ] ; then
sudo -u btcpay git config user.email "you@example.com"
sudo -u btcpay git config user.name "Your Name"
fi
sudo -u btcpay git fetch
# unset $1
set --
UPSTREAM = ${ 1 :- '@{u}' }
LOCAL = $( git rev-parse @)
REMOTE = $( git rev-parse " $UPSTREAM " )
2022-05-10 10:01:26 +01:00
2021-11-30 11:43:52 +00:00
if [ $LOCAL = $REMOTE ] ; then
TAG = $( git tag | grep v1 | sort -V | tail -1)
echo " # Up-to-date on version $TAG "
else
echo "# Pulling latest changes..."
sudo -u btcpay git pull -p
TAG = $( git tag | grep v1 | sort -V | tail -1)
echo " # Reset to the latest release tag: $TAG "
sudo -u btcpay git reset --hard $TAG
2022-03-14 15:40:56 +00:00
# PGP verify - disabled for the update
# https://github.com/rootzoll/raspiblitz/issues/3025
# sudo -u btcpay /home/admin/config.scripts/blitz.git-verify.sh \
# "${PGPsigner}" "${PGPpubkeyLink}" "${PGPpubkeyFingerprint}" || exit 1
2023-02-04 12:37:59 +00:00
echo " # Build BTCPayServer $TAG "
2021-11-30 11:43:52 +00:00
# from the build.sh with path
sudo systemctl stop btcpayserver
2023-02-07 20:32:22 +00:00
sudo -u btcpay /home/btcpay/dotnet/dotnet build -c Release /home/btcpay/btcpayserver/BTCPayServer/BTCPayServer.csproj || exit 1
2021-11-30 11:43:52 +00:00
sudo systemctl start btcpayserver
echo " # Updated BTCPayServer to $TAG "
fi
2022-07-12 13:02:15 +01:00
# always start after BtcPayConfig
sudo systemctl start btcpayserver
2021-11-30 11:43:52 +00:00
exit 0
fi
2020-11-11 16:40:48 +00:00
echo " # FAIL - Unknown Parameter $1 "
2019-12-23 19:03:00 +01:00
exit 1