diff --git a/rootfs/standard/var/pynode/device_info.py b/rootfs/standard/var/pynode/device_info.py index e1b9c06c..24d22752 100644 --- a/rootfs/standard/var/pynode/device_info.py +++ b/rootfs/standard/var/pynode/device_info.py @@ -1228,6 +1228,19 @@ def clear_mempool_cache(): os.system("sync") os.system("systemctl restart mempool") +#================================== +# LNbits Functions +#================================== +def delete_lnbits_settings(): + 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 #================================== diff --git a/rootfs/standard/var/www/mynode/api.py b/rootfs/standard/var/www/mynode/api.py index 8a66fb6d..49937232 100644 --- a/rootfs/standard/var/www/mynode/api.py +++ b/rootfs/standard/var/www/mynode/api.py @@ -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) \ No newline at end of file + 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)) + info += "\n" + data["data"] = info + data["status"] = "success" + except Exception as e: + data["data"] = str(e) + return generate_api_json_response(data) diff --git a/rootfs/standard/var/www/mynode/settings.py b/rootfs/standard/var/www/mynode/settings.py index e22adf04..ab600d33 100644 --- a/rootfs/standard/var/www/mynode/settings.py +++ b/rootfs/standard/var/www/mynode/settings.py @@ -591,6 +591,16 @@ def reset_thunderhub_config_page(): flash("Thunderhub Configuration Reset", category="message") return redirect("/settings") +@mynode_settings.route("/settings/delete-lnbits-settings") +def delete_lnbits_settings_page(): + check_logged_in() + + t = Timer(10.0, delete_lnbits_settings) + t.start() + + flash("LNbits Settings Deleted", category="message") + return redirect("/settings") + @mynode_settings.route("/settings/reset-specter-config") def reset_specter_config_page(): check_logged_in() diff --git a/rootfs/standard/var/www/mynode/templates/settings.html b/rootfs/standard/var/www/mynode/templates/settings.html index f0a1e000..d29be4eb 100644 --- a/rootfs/standard/var/www/mynode/templates/settings.html +++ b/rootfs/standard/var/www/mynode/templates/settings.html @@ -710,6 +710,18 @@ $('#loading_spinner_overlay').fadeIn(); window.location.href='/settings/toggle_setting?name=torify_apt_get&enable='+val }); + + $("#run-lnbits-cli-superuser").on("click", function() { + $("#run-lnbits-cli-superuser").prop("disabled",true); + $("#run-lnbits-cli-superuser-result").html("Loading..."); + $.get("/api/get_lnbits_superuser") + .done(function( data ) { + $("#run-lnbits-cli-superuser").prop("disabled",false); + $("#run-lnbits-cli-superuser-result").html( data["data"] ); + } + ); + }); + }); function hideAllUpgradeLogs() { @@ -1215,6 +1227,24 @@ +