Skip to content

Commit

Permalink
Add LNbits lnbits-cli delete-settings and superuser
Browse files Browse the repository at this point in the history
add LNbits to settings page, fetch superuser usr and reset database
  • Loading branch information
tlindi committed Mar 7, 2024
1 parent 736541a commit d9cc901
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 1 deletion.
13 changes: 13 additions & 0 deletions rootfs/standard/var/pynode/device_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
#==================================
Expand Down
20 changes: 19 additions & 1 deletion rootfs/standard/var/www/mynode/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
info += "\n"
data["data"] = info
data["status"] = "success"
except Exception as e:
data["data"] = str(e)
return generate_api_json_response(data)
10 changes: 10 additions & 0 deletions rootfs/standard/var/www/mynode/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
30 changes: 30 additions & 0 deletions rootfs/standard/var/www/mynode/templates/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -1215,6 +1227,24 @@
</div>


<div class="settings_block">
<a id="lnbits"></a>
<div class="settings_block_header">LNbits</div>

<div class="settings_block_subheader">Reset LNbits Settings</div>
This will delete your LNbits settings from database. This should not impact users, wallets and installed extension data stored in LNbits. When applied LNbits will read its default settings from .env file to database. Use this also if you need reset super user username and password.
<br/>
<a href="/settings/delete-lnbits-settings" class="ui-button ui-widget ui-corner-all settings_button">Delete Settings</a>

<div class="divider"></div>

<div class="settings_block_subheader">Show LNbits superuser ID</div>
Run lnbits-cli superuser command and show usr ID. It is needed to access LNbits admin UI.
<br/>
<button id="run-lnbits-cli-superuser" class="ui-button ui-widget ui-corner-all settings_button">Show superuser ID</button>
<pre id="run-lnbits-cli-superuser-result"></pre>
</div>

<div class="settings_block">
<a id="specter"></a>
<div class="settings_block_header">Specter</div>
Expand Down

0 comments on commit d9cc901

Please sign in to comment.