mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-04-11 21:29:29 +02:00
update lnbits.sh
This commit is contained in:
parent
9dc514817a
commit
de84e62441
@ -463,7 +463,7 @@ if [ ${macaroonExists} -eq 0 ]; then
|
||||
fi
|
||||
|
||||
# copy macaroons to all needed users
|
||||
sudo /home/admin/config.scripts/lnd.check.sh update-credentials
|
||||
sudo /home/admin/config.scripts/lnd.credentials.sh sync
|
||||
echo "OK - LND Macaroons created and copied"
|
||||
echo ""
|
||||
|
||||
|
@ -79,23 +79,20 @@ if [ "$1" = "write-macaroons" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# copy macaroons and for lnbits environment
|
||||
# set tls.cert path
|
||||
sudo -u lnbits sed -i "s/^LND_CERT=.*/LND_CERT=\/home\/admin\/.lnd\/tls.cert/g" /home/lnbits/lnbits/.env
|
||||
# copy macaroons
|
||||
echo "copy macaroons to lnbits user"
|
||||
sudo -u lnbits mkdir -p /home/lnbits/.lnd/data/chain/${network}/${chain}net/
|
||||
sudo cp /home/bitcoin/.lnd/data/chain/${network}/${chain}net/admin.macaroon /home/lnbits/.lnd/data/chain/${network}/${chain}net/
|
||||
sudo cp /home/bitcoin/.lnd/data/chain/${network}/${chain}net/invoice.macaroon /home/lnbits/.lnd/data/chain/${network}/${chain}net/
|
||||
sudo cp /home/bitcoin/.lnd/data/chain/${network}/${chain}net/readonly.macaroon /home/lnbits/.lnd/data/chain/${network}/${chain}net/
|
||||
sudo chown lnbits:lnbits -R /home/lnbits/.lnd/data/chain/${network}/${chain}net/*.macaroon
|
||||
sudo chmod 600 /home/lnbits/.lnd/data/chain/${network}/${chain}net/*.macaroon
|
||||
echo "OK DONE"
|
||||
#set macaroons paths in .env
|
||||
sudo -u lnbits sed -i "s/^LND_ADMIN_MACAROON=.*/LND_ADMIN_MACAROON=\/home\/lnbits\/.lnd\/data\/chain\/${network}\/${chain}net\/admin.macaroon/g" /home/lnbits/lnbits/.env
|
||||
sudo -u lnbits sed -i "s/^LND_INVOICE_MACAROON=.*/LND_INVOICE_MACAROON=\/home\/lnbits\/.lnd\/data\/chain\/${network}\/${chain}net\/invoice.macaroon/g" /home/lnbits/lnbits/.env
|
||||
sudo -u lnbits sed -i "s/^LND_READ_MACAROON=.*/LND_READ_MACAROON=\/home\/lnbits\/.lnd\/data\/chain\/${network}\/${chain}net\/read.macaroon/g" /home/lnbits/lnbits/.env
|
||||
echo "# OK - macaroons written to /home/lnbits/lnbits/.env"
|
||||
echo "make sure symlink to central app-data directory exists"
|
||||
if ! [[ -L "/home/lnbits/.lnd" ]]; then
|
||||
sudo rm -rf "/home/lnbits/.lnd" # not a symlink.. delete it silently
|
||||
sudo ln -s "/mnt/hdd/app-data/lnd/" "/home/lnbits/.lnd" # and create symlink
|
||||
fi
|
||||
|
||||
# set tls.cert path (use | as separator to avoid escaping file path slashes)
|
||||
sudo -u lnbits sed -i "s|^LND_CERT=.*|LND_CERT=/home/lnbits/.lnd/tls.cert|g" /home/lnbits/lnbits/.env
|
||||
|
||||
# set macaroon path info in .env
|
||||
sudo -u lnbits sed -i "s|^LND_ADMIN_MACAROON=.*|LND_ADMIN_MACAROON=/home/lnbits/.lnd/data/chain/${network}/${chain}net/admin.macaroon|g" /home/lnbits/lnbits/.env
|
||||
sudo -u lnbits sed -i "s|^LND_INVOICE_MACAROON=.*|LND_INVOICE_MACAROON=/home/lnbits/.lnd/data/chain/${network}/${chain}net/invoice.macaroon|g" /home/lnbits/lnbits/.env
|
||||
sudo -u lnbits sed -i "s|^LND_READ_MACAROON=.*|LND_READ_MACAROON=/home/lnbits/.lnd/data/chain/${network}/${chain}net/read.macaroon|g" /home/lnbits/lnbits/.env
|
||||
echo "# OK - macaroon path info written to /home/lnbits/lnbits/.env"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
@ -1,17 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
# command info
|
||||
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "-help" ]; then
|
||||
echo "# script to check LND states"
|
||||
echo "# lnd.check.sh basic-setup"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# load raspiblitz conf
|
||||
source /home/admin/raspiblitz.info # ToDo(frennkie) I don't think this is needed
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
|
||||
# check basic LND setup
|
||||
if [ "$1" == "basic-setup" ]; then # ToDo(frennkie) If there is only one option.. just run it by default?!
|
||||
if [ "$1" == "basic-setup" ]; then
|
||||
|
||||
# check TLS exits
|
||||
tlsExists=$(sudo ls /mnt/hdd/lnd/tls.cert 2>/dev/null | grep -c 'tls.cert')
|
||||
@ -175,16 +175,6 @@ if [ "$1" == "basic-setup" ]; then # ToDo(frennkie) If there is only one option.
|
||||
echo "rpcpasscorrect=${rpcpasscorrect}"
|
||||
|
||||
else
|
||||
echo "# FAIL: parameter not known"
|
||||
echo "# FAIL: parameter not known - run with -h for help"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# ToDo(frennkie)
|
||||
#$: grep lnd.check.sh *
|
||||
#00raspiblitz.sh: source <(sudo /home/admin/config.scripts/lnd.check.sh basic-setup)
|
||||
#10setupBlitz.sh: source <(sudo /home/admin/config.scripts/lnd.check.sh basic-setup)
|
||||
#80scanLND.sh: lndErrorFull=$(sudo /home/admin/config.scripts/lnd.check.sh basic-setup | grep "err=" | tail -1)
|
||||
#80scanLND.sh: sudo /home/admin/config.scripts/lnd.check.sh basic-setup | grep "err="
|
||||
#80scanLND.sh: source <(sudo /home/admin/config.scripts/lnd.check.sh basic-setup)
|
||||
#80scanLND.sh: lndSetupErrorCount=$(sudo /home/admin/config.scripts/lnd.check.sh basic-setup | grep -c "err=")
|
||||
|
||||
#70initLND.sh:sudo /home/admin/config.scripts/lnd.check.sh update-credentials
|
||||
|
@ -3,17 +3,10 @@
|
||||
# command info
|
||||
if [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
||||
echo "tool to reset or sync credentials (e.g. macaroons)"
|
||||
echo "lnd.credentials [reset|sync]"
|
||||
|
||||
echo "lnd.credentials.sh [reset|sync]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# some vars will be sourced (e.g. from config) - make them known here for
|
||||
# cleaner linting/shellchecking.
|
||||
network=
|
||||
chain=
|
||||
rpcpassword=
|
||||
|
||||
# load data from config
|
||||
source /mnt/hdd/raspiblitz.conf
|
||||
|
||||
@ -35,7 +28,6 @@ function copy_mac_set_perms() {
|
||||
###########################
|
||||
# RESET Macaroons and TLS
|
||||
###########################
|
||||
|
||||
if [ "$1" = "reset" ]; then
|
||||
clear
|
||||
echo "###### RESET MACAROONS AND TLS.cert ######"
|
||||
@ -62,12 +54,10 @@ if [ "$1" = "reset" ]; then
|
||||
copy_mac_set_perms readonly.macaroon lndreadonly "${network}" "${chain}"
|
||||
echo "OK DONE"
|
||||
|
||||
fi
|
||||
|
||||
###########################
|
||||
# SYNC
|
||||
###########################
|
||||
if [ "$1" = "sync" ]; then
|
||||
elif [ "$1" = "sync" ]; then
|
||||
echo "###### SYNCING MACAROONS, RPC Password AND TLS Certificate ######"
|
||||
|
||||
echo "# make sure LND app-data directories exist"
|
||||
@ -92,12 +82,18 @@ if [ "$1" = "sync" ]; then
|
||||
echo "# WARN: could not get value 'rpcpass' from network config (e.g. bitcoin.conf)"
|
||||
fi
|
||||
|
||||
echo "# make sure TLS certificate is symlinked and readable"
|
||||
if ! [[ -L "/mnt/hdd/app-data/lnd/tls.cert" ]]; then
|
||||
sudo rm -rf "/mnt/hdd/app-data/lnd/tls.cert" # not a symlink.. delete it silently
|
||||
sudo ln -s /mnt/hdd/lnd/tls.cert /home/admin/.lnd/tls.cert # and create symlink
|
||||
fi
|
||||
echo "# make sure TLS certificate is readable and symlinked"
|
||||
sudo chmod 664 "/mnt/hdd/lnd/tls.cert"
|
||||
sudo chown bitcoin:bitcoin "/mnt/hdd/lnd/tls.cert"
|
||||
if ! [[ -L "/mnt/hdd/app-data/lnd/tls.cert" ]]; then
|
||||
sudo rm -rf "/mnt/hdd/app-data/lnd/tls.cert" # not a symlink.. delete it silently
|
||||
sudo ln -s "/mnt/hdd/lnd/tls.cert" "/home/admin/.lnd/tls.cert" # and create symlink
|
||||
fi
|
||||
|
||||
###########################
|
||||
# UNKNOWN
|
||||
###########################
|
||||
else
|
||||
echo "# FAIL: parameter not known - run with -h for help"
|
||||
exit 1
|
||||
fi
|
||||
|
@ -36,4 +36,4 @@ echo "OK TLS certs are fresh"
|
||||
|
||||
# ToDo(frennkie) why doesn't this start lnd again? - I assume as _background will start it anyway?!
|
||||
# ToDo(frennkie) the way LND generates the x509 certificate is not ideal -
|
||||
# it may be better to simply run openssl and create a cert with ou settings...
|
||||
# it may be better to simply run openssl and create a cert with our settings...
|
||||
|
Loading…
x
Reference in New Issue
Block a user