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 736541a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 91 deletions.
43 changes: 29 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,38 @@
#!/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

# debug Disable
sed -i "s|^DEBUG=.*|DEBUG=false|g" /mnt/hdd/mynode/lnbits/.env
# debug Enable
# sed -i "s|^DEBUG=.*|DEBUG=true|g" /mnt/hdd/mynode/lnbits/.env

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

# Update env with mynode lnd REST ip and port
sed -i "s|^LND_REST_ENDPOINT=.*|LND_REST_ENDPOINT=https\:\/\/172.17.0.1:10080\/|g" /mnt/hdd/mynode/lnbits/.env

# Update env 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 736541a

Please sign in to comment.