Skip to content

Commit

Permalink
Fix LNbits .env creation
Browse files Browse the repository at this point in the history
use .env.example from LNbits package as .env template
  • Loading branch information
tlindi committed Mar 7, 2024
1 parent 3758364 commit 11dbe85
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 91 deletions.
33 changes: 19 additions & 14 deletions rootfs/standard/usr/bin/service_scripts/pre_lnbits.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
#!/bin/bash

set -x
source /usr/share/mynode/mynode_app_versions.sh

# Copy config file
if [ ! -f /mnt/hdd/mynode/lnbits/.env ]; then
cp /usr/share/mynode/lnbits.env /mnt/hdd/mynode/lnbits/.env
# Delete old myNode .env file created before 0.12.x
if [ -f /usr/share/mynode/lnbits.env ]; then
rm -f /usr/share/mynode/lnbits.env
fi

# if current LNbits version config is missign create .env from .env.example
if [ ! -f /mnt/hdd/mynode/lnbits/update_config_$LNBITS_VERSION ]; then
rm -f /mnt/hdd/mynode/lnbits/update_config_*
touch /mnt/hdd/mynode/lnbits/update_config_$LNBITS_VERSION

cp -f /opt/mynode/lnbits/.env.example /mnt/hdd/mynode/lnbits/.env
chown bitcoin:bitcoin /mnt/hdd/mynode/lnbits/.env

# Use ADMIN_UI
sed -i "s|^LNBITS_ADMIN_UI=.*|LNBITS_ADMIN_UI=true|g" /mnt/hdd/mynode/lnbits/.env

# Update env file with files mapped in lnbits.service
sed -i "s|^LND_REST_CERT=.*|LND_REST_CERT=\"/app/tls.cert\"|g" /mnt/hdd/mynode/lnbits/.env
sed -i "s|^LND_REST_MACAROON=.*|LND_REST_MACAROON=\"/app/admin.macaroon\"|g" /mnt/hdd/mynode/lnbits/.env
fi

# Force update of LNBits config file (increment to force new update)
# LNBITS_CONFIG_UPDATE_NUM=1
# if [ ! -f /mnt/hdd/mynode/lnbits/update_config_$LNBITS_CONFIG_UPDATE_NUM ]; then
# cp -f /usr/share/mynode/lnbits.env /mnt/hdd/mynode/lnbits/.env
# chown bitcoin:bitcoin /mnt/hdd/mynode/lnbits/.env
# touch /mnt/hdd/mynode/lnbits/update_config_$LNBITS_CONFIG_UPDATE_NUM
# fi

# Generate hex macaroons
#macaroonAdminHex=$(xxd -ps -u -c 1000 /mnt/hdd/mynode/lnd/data/chain/bitcoin/mainnet/admin.macaroon)

# Update env file
sed -i "s|^LND_REST_MACAROON=.*|LND_REST_MACAROON=\"/app/admin.macaroon\"|g" /mnt/hdd/mynode/lnbits/.env
77 changes: 0 additions & 77 deletions rootfs/standard/usr/share/mynode/lnbits.env

This file was deleted.

0 comments on commit 11dbe85

Please sign in to comment.