-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LNbits 0.12.x fixes #854
base: master
Are you sure you want to change the base?
LNbits 0.12.x fixes #854
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typically, I would create a version number to track config updates so that it doesn't update automatically each upgrade / lnbits version change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't the .env template be updated on each update so new options and defaults would be corrected on update too? There are version files from Application Management related to installed, latest and available version. Could those be used as reference here too? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It normally doesn't need to be updated for each new release. Normally, the software should account for "missing" settings in the config file to use the default anyway. Keeping the file around makes it easy to update the default settings and control how the app runs. Those files just control the application version and not the settings files. There are examples in a few places, like pre_rtl.sh.
|
||
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 |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1228,6 +1228,19 @@ def clear_mempool_cache(): | |
os.system("sync") | ||
os.system("systemctl restart mempool") | ||
|
||
#================================== | ||
# LNbits Functions | ||
#================================== | ||
def delete_lnbits_settings(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also don't think this would work. It looks like this launches a new container rather than running a command in the existing lnbits container. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have you tried it? It may work by launching a second container. Alternatively, you could exec into the running container to run the command, but I guess that would only clear the settings if lnbits was actively running. |
||
os.system("rm -rf /mnt/hdd/mynode/lnbits/.super_user") | ||
os.system("/usr/bin/docker run --rm \ | ||
--name lnbits-delete-settings \ | ||
--volume /mnt/hdd/mynode/lnbits/.env:/app/.env \ | ||
--volume /mnt/hdd/mynode/lnbits/:/app/data \ | ||
lnbits poetry run lnbits-cli delete-settings") | ||
if is_service_enabled("lnbits"): | ||
restart_service("lnbits") | ||
|
||
#================================== | ||
# Specter Functions | ||
#================================== | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -313,4 +313,22 @@ def api_get_usb_info(): | |
data["status"] = "success" | ||
except Exception as e: | ||
data["data"] = str(e) | ||
return generate_api_json_response(data) | ||
return generate_api_json_response(data) | ||
|
||
@mynode_api.route("/api/get_lnbits_superuser") | ||
def api_get_lnbits_superuser(): | ||
check_logged_in() | ||
|
||
data = {} | ||
data["status"] = "error" | ||
data["data"] = "UNKNOWN" | ||
try: | ||
info = "" | ||
|
||
info += to_string(subprocess.check_output("cat /mnt/hdd/mynode/lnbits/.super_user", shell=True)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where does this file that stored the super_user info get created? I only see it getting read/deleted. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, it looks like it file is created by lnbits. |
||
info += "\n" | ||
data["data"] = info | ||
data["status"] = "success" | ||
except Exception as e: | ||
data["data"] = str(e) | ||
return generate_api_json_response(data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather not get rid of this file since I can control it a bit better and reference the config. Can it just be updated with the latest version from the lnbits repo? If I do have to put in default settings, this file (/usr/share/mynode/lnbits/env) is a nice way to do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will fix the way you suggested