diff --git a/rootfs/standard/var/www/mynode/api.py b/rootfs/standard/var/www/mynode/api.py index 5ed7ac30..58fe3257 100644 --- a/rootfs/standard/var/www/mynode/api.py +++ b/rootfs/standard/var/www/mynode/api.py @@ -6,8 +6,6 @@ from bitcoin_info import * from lightning_info import * from electrum_info import * from device_info import * -from dojo import get_dojo_status -from whirlpool import get_whirlpool_status from thread_functions import * from systemctl_info import * from application_info import * @@ -68,61 +66,14 @@ def api_get_service_status(): data = {} data["status"] = "gray" data["color"] = "" - data["ready"] = None + data["sso_token"] = "" service = request.args.get('service') - if service == "electrs": - data["status"], data["color"] = get_electrs_status_and_color() - elif service == "bitcoin": - data["status"], data["color"] = get_bitcoin_status_and_color() - elif service == "lnd": - data["status"], data["color"] = get_lnd_status_and_color() - elif service == "loop": - data["status"], data["color"] = get_loop_status_and_color() - elif service == "pool": - data["status"], data["color"] = get_pool_status_and_color() - elif service == "lit": - data["status"], data["color"] = get_lit_status_and_color() - elif service == "dojo": - data["status"], data["color"], dojo_initialized = get_dojo_status() - elif service == "rtl": - data["status"], data["color"] = get_rtl_status_and_color() - elif service == "mempool": - data["status"], data["color"] = get_mempool_status_and_color() - elif service == "whirlpool": - data["status"], data["color"], whirlpool_initialized = get_whirlpool_status() - elif service == "btcpayserver": - data["status"], data["color"] = get_btcpayserver_status_and_color() - elif service == "lndhub": - data["status"], data["color"] = get_lndhub_status_and_color() - elif service == "lndconnect": - data["status"], data["color"] = get_lndconnect_status_and_color() - elif service == "btcrpcexplorer": - data["status"], data["color"], data["ready"] = get_btcrpcexplorer_status_and_color_and_ready() - data["sso_token"] = get_btcrpcexplorer_sso_token() - elif service == "caravan": - data["status"], data["color"] = get_caravan_status_and_color() - elif service == "specter": - data["status"], data["color"] = get_specter_status_and_color() - elif service == "lnbits": - data["status"], data["color"] = get_lnbits_status_and_color() - elif service == "thunderhub": - data["status"], data["color"] = get_thunderhub_status_and_color() - data["sso_token"] = get_thunderhub_sso_token() - elif service == "ckbunker": - data["status"], data["color"] = get_ckbunker_status_and_color() - elif service == "sphinxrelay": - data["status"], data["color"] = get_sphinxrelay_status_and_color() - elif service == "tor": - data["status"] = "Private Connections" - data["color"] = get_service_status_color("tor@default") - elif service == "vpn": - data["status"], data["color"] = get_vpn_status_and_color() - elif service == "webssh2": - data["status"], data["color"] = get_webssh2_status_and_color() - else: - data["status"] = "unknown service" + # Try standard status API + data["status"] = get_application_status(service) + data["color"] = get_application_status_color(service) + data["sso_token"] = get_application_sso_token(service) return jsonify(data) @mynode_api.route("/api/get_device_info") @@ -135,6 +86,7 @@ def api_get_device_info(): data["ram"] = get_ram_usage() data["temp"] = get_device_temp() data["is_installing_docker_images"] = is_installing_docker_images() + data["is_electrs_active"] = is_electrs_active() return jsonify(data) diff --git a/rootfs/standard/var/www/mynode/application_info.py b/rootfs/standard/var/www/mynode/application_info.py index e3742e09..d0d95aeb 100644 --- a/rootfs/standard/var/www/mynode/application_info.py +++ b/rootfs/standard/var/www/mynode/application_info.py @@ -18,34 +18,68 @@ def is_installed(current_version): def create_application(name="NAME", short_name="SHORT_NAME", + app_tile_name=None, is_premium=False, can_reinstall=True, can_uninstall=False, + requires_lightning=False, + requires_electrs=False, + requires_bitcoin=False, + requires_docker_image_installation=False, + supports_testnet=False, show_on_homepage=False, show_on_application_page=True, can_enable_disable=True, - icon="TODO", + homepage_order=9999, + homepage_section="", + app_tile_button_text=None, + app_tile_default_status_text="", + app_tile_running_status_text="", + app_tile_button_href="#", status="UNKNOWN", log_file=None, - journalctl_log_name=None): + journalctl_log_name=None, + ): app = {} app["name"] = name app["short_name"] = short_name + if app_tile_name != None: + app["app_tile_name"] = app_tile_name + else: + app["app_tile_name"] = name app["is_premium"] = is_premium app["current_version"] = get_app_current_version(short_name) app["latest_version"] = get_app_latest_version(short_name) app["is_installed"] = is_installed(app["current_version"]) app["can_reinstall"] = can_reinstall app["can_uninstall"] = can_uninstall + app["requires_lightning"] = requires_lightning + app["requires_electrs"] = requires_electrs + app["requires_bitcoin"] = requires_bitcoin + app["requires_docker_image_installation"] = requires_docker_image_installation + app["supports_testnet"] = supports_testnet app["show_on_homepage"] = show_on_homepage app["show_on_application_page"] = show_on_application_page app["can_enable_disable"] = can_enable_disable app["is_enabled"] = is_service_enabled(short_name) - app["icon"] = icon #app["status"] = status # Should status be optional to include? Takes lots of time. #app["status_color"] = get_service_status_color(short_name) app["log_file"] = log_file app["journalctl_log_name"] = journalctl_log_name + app["homepage_order"] = homepage_order + app["homepage_section"] = homepage_section + if app["homepage_section"] == "" and app["show_on_homepage"]: + app["homepage_section"] = "apps" + if app_tile_button_text != None: + app["app_tile_button_text"] = app_tile_button_text + else: + app["app_tile_button_text"] = app["app_tile_name"] + app["app_tile_default_status_text"] = app_tile_default_status_text + if app_tile_running_status_text != "": + app["app_tile_running_status_text"] = app_tile_running_status_text + else: + app["app_tile_running_status_text"] = app_tile_default_status_text + app["app_tile_button_href"] = app_tile_button_href return app def update_application(app): @@ -61,34 +95,75 @@ def initialize_applications(): apps.append(create_application( name="Bitcoin", short_name="bitcoin", + app_tile_running_status_text="Running", log_file=get_bitcoin_log_file() )) apps.append(create_application( name="LND", short_name="lnd", + app_tile_running_status_text="Running", )) apps.append(create_application( name="Loop", short_name="loop", + requires_lightning=True, )) apps.append(create_application( name="Pool", short_name="pool", + requires_lightning=True, )) apps.append(create_application( name="Lightning Terminal", short_name="lit", + requires_lightning=True, + )) + apps.append(create_application( + name="Ride the Lightning", + short_name="rtl", + app_tile_name="RTL", + app_tile_default_status_text="Lightning Wallet", + show_on_homepage=True, + requires_lightning=True, + supports_testnet=True, + homepage_order=11 )) apps.append(create_application( name="Electrum Server", short_name="electrs", + app_tile_button_text="Info", + app_tile_button_href="/electrum-server", + app_tile_default_status_text="", + app_tile_running_status_text="Running", can_reinstall=False, - show_on_homepage=True + show_on_homepage=True, + supports_testnet=True, + homepage_order=12 )) apps.append(create_application( - name="BTC RPC Explorer", - short_name="btcrpcexplorer", - show_on_homepage=True + name="BTCPay Server", + short_name="btcpayserver", + app_tile_default_status_text="Merchant Tool", + requires_lightning=True, + show_on_homepage=True, + homepage_order=13 + )) + apps.append(create_application( + name="Mempool", + short_name="mempool", + app_tile_default_status_text="Mempool Viewer", + show_on_homepage=True, + supports_testnet=True, + requires_docker_image_installation=True, + homepage_order=14 + )) + apps.append(create_application( + name="LND Hub", + short_name="lndhub", + app_tile_default_status_text="BlueWallet Backend", + requires_lightning=True, + show_on_homepage=True, + homepage_order=15 )) apps.append(create_application( name="Corsproxy", @@ -101,88 +176,118 @@ def initialize_applications(): short_name="lndconnect", )) apps.append(create_application( - name="LND Hub", - short_name="lndhub", - show_on_homepage=True - )) - apps.append(create_application( - name="Ride the Lightning", - short_name="rtl", - show_on_homepage=True - )) - apps.append(create_application( - name="BTCPay Server", - short_name="btcpayserver", - show_on_homepage=True - )) - apps.append(create_application( - name="Mempool", - short_name="mempool", - show_on_homepage=True - )) - apps.append(create_application( - name="Whirlpool", - short_name="whirlpool", - show_on_homepage=True + name="BTC RPC Explorer", + short_name="btcrpcexplorer", + app_tile_name="Explorer", + app_tile_default_status_text="BTC RPC Explorer", + requires_bitcoin=True, + show_on_homepage=True, + supports_testnet=True, + requires_electrs=True, + homepage_order=21 )) apps.append(create_application( name="Dojo", short_name="dojo", + app_tile_button_text="Info", + app_tile_button_href="/dojo", + app_tile_default_status_text="Mixing Tool", show_on_application_page=True, - show_on_homepage=True + show_on_homepage=True, + requires_electrs=True, + requires_docker_image_installation=True, + homepage_order=22 )) apps.append(create_application( - name="Joinmarket", - short_name="joinmarket", + name="Whirlpool", + short_name="whirlpool", + app_tile_button_text="Info", + app_tile_button_href="/whirlpool", + app_tile_default_status_text="Mixing Tool", show_on_homepage=True, - is_premium=True + homepage_order=23 )) apps.append(create_application( name="JoininBox", short_name="joininbox", + app_tile_button_text="Info", + app_tile_button_href="/joininbox", + app_tile_default_status_text="JoinMarket Mixing", show_on_homepage=True, + homepage_order=24, can_enable_disable=False, is_premium=True, )) apps.append(create_application( - name="Thunderhub", - short_name="thunderhub", - show_on_homepage=True, + name="Joinmarket", + short_name="joinmarket", is_premium=True )) apps.append(create_application( - name="LNbits", - short_name="lnbits", + name="Thunderhub", + short_name="thunderhub", + app_tile_default_status_text="Lightning Wallet", + requires_lightning=True, + supports_testnet=True, show_on_homepage=True, + homepage_order=25, is_premium=True )) apps.append(create_application( name="Caravan", short_name="caravan", + requires_bitcoin=True, + app_tile_button_text="Info", + app_tile_button_href="/caravan", + app_tile_default_status_text="Multisig Tool", show_on_homepage=True, + homepage_order=31, + supports_testnet=True, is_premium=True )) apps.append(create_application( name="Specter", short_name="specter", + requires_bitcoin=True, + app_tile_default_status_text="Multisig Tool", show_on_homepage=True, + homepage_order=32, + supports_testnet=True, is_premium=True )) apps.append(create_application( name="CKBunker", short_name="ckbunker", + requires_bitcoin=True, + app_tile_default_status_text="Coldcard Signing Tool", show_on_homepage=True, + homepage_order=33, + supports_testnet=True, is_premium=True )) apps.append(create_application( name="Sphinx Relay", short_name="sphinxrelay", + app_tile_button_text="Info", + app_tile_button_href="/sphinxrelay", + app_tile_default_status_text="Chat", + requires_lightning=True, show_on_homepage=True, + homepage_order=34, + is_premium=True + )) + apps.append(create_application( + name="LNbits", + short_name="lnbits", + requires_lightning=True, + app_tile_default_status_text="Lightning Wallet", + show_on_homepage=True, + homepage_order=35, is_premium=True )) apps.append(create_application( name="Web SSH", - short_name="webssh2" + short_name="webssh2", )) apps.append(create_application( name="Netdata", @@ -192,15 +297,28 @@ def initialize_applications(): apps.append(create_application( name="Tor", short_name="tor", + can_enable_disable=False, + app_tile_button_text="Tor Services", + app_tile_default_status_text="Private Connections", + app_tile_button_href="/tor", + show_on_homepage=True, show_on_application_page=False, - journalctl_log_name="tor@default" + journalctl_log_name="tor@default", + homepage_section="remote_services", + supports_testnet=True, + is_premium=True, )) apps.append(create_application( name="VPN", short_name="vpn", - show_on_homepage=True, can_reinstall=False, - show_on_application_page=False + app_tile_button_text="Info", + app_tile_button_href="/vpn-info", + show_on_homepage=True, + show_on_application_page=False, + homepage_section="remote_services", + supports_testnet=True, + is_premium=True, )) apps.append(create_application( name="NGINX", @@ -232,6 +350,8 @@ def get_all_applications(order_by="none"): apps = copy.deepcopy(mynode_applications) if order_by == "alphabetic": apps.sort(key=lambda x: x["name"]) + elif order_by == "homepage": + apps.sort(key=lambda x: x["homepage_order"]) return apps @@ -272,6 +392,118 @@ def get_application_log(short_name): else: return "ERROR: App or log not found ({})".format(short_name) +def get_application_status_special(short_name): + if short_name == "bitcoin": + return get_bitcoin_status() + elif short_name == "lnd": + return get_lnd_status() + elif short_name == "vpn": + if os.path.isfile("/home/pivpn/ovpns/mynode_vpn.ovpn"): + return "Running" + else: + return "Setting up..." + elif short_name == "electrs": + return get_electrs_status() + elif short_name == "whirlpool": + if not os.path.isfile("/mnt/hdd/mynode/whirlpool/whirlpool-cli-config.properties"): + return "Waiting for initialization..." + elif short_name == "dojo": + try: + dojo_initialized = subprocess.check_output("docker inspect --format={{.State.Running}} db", shell=True).strip() + except: + dojo_initialized = "" + if dojo_initialized != "true": + return "Error" + return "" + +def get_application_status(short_name): + # Make sure app is valid + if not is_application_valid(short_name): + return "APP NOT FOUND" + + # Get application + app = get_application(short_name) + + # Check Disabled, Testnet, Lightning, Electrum requirements... + if is_testnet_enabled() and not app["supports_testnet"]: + return "Requires Mainnet" + if app["requires_docker_image_installation"] and is_installing_docker_images(): + return "Installing..." + if not app["is_enabled"]: + return app["app_tile_default_status_text"] + if app["requires_bitcoin"] and not is_bitcoin_synced(): + return "Waiting on Bitcoin" + if app["requires_lightning"] and not is_lnd_ready(): + return "Waiting on Lightning" + if app["requires_electrs"] and not is_electrs_active(): + return "Waiting on Electrum" + + # Check special cases + special_status = get_application_status_special(short_name) + if special_status != "": + return special_status + + # Return + return app["app_tile_running_status_text"] + +def get_application_status_color_special(short_name): + if short_name == "lnd": + return get_lnd_status_color() + elif short_name == "joininbox": + return "clear" + elif short_name == "whirlpool": + if not os.path.isfile("/mnt/hdd/mynode/whirlpool/whirlpool-cli-config.properties"): + return "yellow" + elif short_name == "dojo": + try: + dojo_initialized = subprocess.check_output("docker inspect --format={{.State.Running}} db", shell=True).strip() + except: + dojo_initialized = "" + if dojo_initialized != "true": + return "red" + return "" + +def get_application_status_color(short_name): + # Make sure app is valid + if not is_application_valid(short_name): + return "gray" + + # Get application + app = get_application(short_name) + + # Check Disabled, Testnet, Lightning, Electrum requirements... + if is_testnet_enabled() and not app["supports_testnet"]: + return "gray" + if app["requires_docker_image_installation"] and is_installing_docker_images(): + return "yellow" + if app["can_enable_disable"] and not app["is_enabled"]: + return "gray" + if app["requires_bitcoin"] and not is_bitcoin_synced(): + return "yellow" + if app["requires_lightning"] and not is_lnd_ready(): + return "yellow" + if app["requires_electrs"] and not is_electrs_active(): + return "yellow" + + # Check special cases + special_status_color = get_application_status_color_special(short_name) + if special_status_color != "": + return special_status_color + + # Return service operational status + return get_service_status_color(short_name) + +def get_application_sso_token(short_name): + # Make sure app is valid + if not is_application_valid(short_name): + return "APP NOT FOUND" + + if short_name == "btcrpcexplorer": + return get_btcrpcexplorer_sso_token() + if short_name == "thunderhub": + return get_thunderhub_sso_token() + return "" + def restart_application(short_name): try: subprocess.check_output('systemctl restart {}'.format(short_name), shell=True) diff --git a/rootfs/standard/var/www/mynode/device_info.py b/rootfs/standard/var/www/mynode/device_info.py index a6e773a1..c8fd8a01 100644 --- a/rootfs/standard/var/www/mynode/device_info.py +++ b/rootfs/standard/var/www/mynode/device_info.py @@ -1,13 +1,13 @@ from config import * from threading import Timer from werkzeug.routing import RequestRedirect -from flask import flash +from flask import flash, redirect from utilities import * from enable_disable_functions import * -from lightning_info import is_lnd_ready, get_lnd_status, get_lnd_status_color +from lightning_info import is_lnd_ready from systemctl_info import * from electrum_info import get_electrs_status, is_electrs_active -from bitcoin_info import get_bitcoin_status, is_bitcoin_synced +from bitcoin_info import is_bitcoin_synced from datetime import timedelta import time import json @@ -460,227 +460,6 @@ def get_drive_info(drive): return data -#================================== -# Specific Service Status / Colors -#================================== -def get_bitcoin_status_and_color(): - status = "" - color = "gray" - if get_service_status_code("bitcoin") == 0: - status = get_bitcoin_status() - color = "green" - else: - status = "Error" - color = "red" - return status,color - -def get_lnd_status_and_color(): - status = get_lnd_status() - color = get_lnd_status_color() - return status,color - -def get_loop_status_and_color(): - status = "Not Displayed" - color = "gray" - if is_lnd_ready(): - color = get_service_status_color("loop") - return status,color - -def get_pool_status_and_color(): - status = "Not Displayed" - color = "gray" - if is_lnd_ready(): - color = get_service_status_color("loop") - return status,color - -def get_lit_status_and_color(): - status = "Not Displayed" - color = "gray" - if is_lnd_ready(): - color = get_service_status_color("loop") - return status,color - -def get_lndconnect_status_and_color(): - status = "Not Displayed" - color = get_service_status_color("lndconnect") - return status,color - -def get_vpn_status_and_color(): - status = "" - color = "gray" - if is_service_enabled("vpn"): - color = get_service_status_color("vpn") - status_code = get_service_status_code("vpn") - if status_code != 0: - status = "Unknown" - else: - if os.path.isfile("/home/pivpn/ovpns/mynode_vpn.ovpn"): - status = "Running" - else: - status = "Setting up..." - return status,color - -def get_rtl_status_and_color(): - status = "Lightning Wallet" - color = "gray" - if is_lnd_ready(): - if is_service_enabled("rtl"): - status_code = get_service_status_code("rtl") - if status_code != 0: - color = "red" - else: - color = "green" - else: - status = "Waiting on Lightning" - return status,color - -def get_lnbits_status_and_color(): - color = "gray" - status = "Lightning Wallet" - if is_testnet_enabled(): - return "Requires Mainnet", "gray" - if is_lnd_ready(): - if is_service_enabled("lnbits"): - status_code = get_service_status_code("lnbits") - if status_code != 0: - color = "red" - else: - color = "green" - else: - status = "Waiting on Lightning" - return status,color - -def get_thunderhub_status_and_color(): - color = "gray" - status = "Lightning Wallet" - if is_lnd_ready(): - if is_service_enabled("thunderhub"): - status_code = get_service_status_code("thunderhub") - if status_code != 0: - color = "red" - else: - color = "green" - else: - status = "Waiting on Lightning" - return status,color - -def get_ckbunker_status_and_color(): - status = "Coldcard Signing Tool" - color = "gray" - if is_bitcoin_synced(): - if is_service_enabled("ckbunker"): - color = get_service_status_color("ckbunker") - else: - status = "Waiting on Bitcoin" - return status,color - -def get_sphinxrelay_status_and_color(): - color = "gray" - status = "Chat" - if is_testnet_enabled(): - return "Requires Mainnet", "gray" - if is_lnd_ready(): - if is_service_enabled("sphinxrelay"): - status_code = get_service_status_code("sphinxrelay") - if status_code != 0: - color = "red" - else: - color = "green" - else: - status = "Waiting on Lightning" - return status,color - -def get_lndhub_status_and_color(): - status = "BlueWallet Backend" - color = "gray" - if is_testnet_enabled(): - return "Requires Mainnet", "gray" - if is_lnd_ready(): - if is_service_enabled("lndhub"): - color = get_service_status_color("lndhub") - else: - status = "Waiting on Lightning" - return status,color - -def get_btcpayserver_status_and_color(): - status = "Merchant Tool" - color = "gray" - if is_testnet_enabled(): - return "Requires Mainnet", "gray" - if is_lnd_ready(): - color = get_service_status_color("btcpayserver") - else: - status = "Waiting on Lightning" - return status,color - -def get_electrs_status_and_color(): - status = "" - color = "gray" - if is_service_enabled("electrs"): - status_code = get_service_status_code("electrs") - color = get_service_status_color("electrs") - if status_code == 0: - status = get_electrs_status() - return status,color - -def get_btcrpcexplorer_status_and_color_and_ready(): - status = "BTC RPC Explorer" - color = "gray" - ready = False - if is_service_enabled("btcrpcexplorer"): - if is_bitcoin_synced(): - if is_electrs_active(): - color = get_service_status_color("btcrpcexplorer") - status_code = get_service_status_code("btcrpcexplorer") - if status_code == 0: - ready = True - else: - color = "yellow" - status = "Waiting on Electrum" - else: - color = "yellow" - status = "Waiting on Bitcoin" - return status,color,ready - -def get_caravan_status_and_color(): - status = "" - color = "gray" - if is_service_enabled("caravan"): - color = get_service_status_color("caravan") - status = "Running" - return status,color - -def get_specter_status_and_color(): - status = "" - color = "gray" - if is_service_enabled("specter"): - color = get_service_status_color("specter") - status = "Running" - return status,color - -def get_mempool_status_and_color(): - status = "Mempool Viewer" - color = "gray" - if is_service_enabled("mempool"): - if is_installing_docker_images(): - color = "yellow" - status = "Installing..." - else: - color = get_service_status_color("mempool") - return status,color - -def get_webssh2_status_and_color(): - status = "Web SSH" - color = "gray" - if is_service_enabled("webssh2"): - if is_installing_docker_images(): - color = "yellow" - status = "Installing..." - else: - color = get_service_status_color("webssh2") - return status,color - - #================================== # UI Functions #================================== diff --git a/rootfs/standard/var/www/mynode/dojo.py b/rootfs/standard/var/www/mynode/dojo.py index af1ca85f..57abeeb9 100644 --- a/rootfs/standard/var/www/mynode/dojo.py +++ b/rootfs/standard/var/www/mynode/dojo.py @@ -5,6 +5,7 @@ from user_management import check_logged_in from enable_disable_functions import * from bitcoin_info import get_mynode_block_height from electrum_info import get_electrs_status, is_electrs_active +from application_info import * import subprocess import re import os @@ -12,6 +13,15 @@ import os mynode_dojo = Blueprint('mynode_dojo',__name__) ## Status and color +def is_dojo_initialized(): + try: + dojo_initialized = subprocess.check_output("docker inspect --format={{.State.Running}} db", shell=True) + dojo_initialized = dojo_initialized.strip() + except: + dojo_initialized = "" + + return dojo_initialized == "true" + def get_dojo_status(): # Find dojo status dojo_status = "Disabled" @@ -20,22 +30,17 @@ def get_dojo_status(): if is_installing_docker_images(): dojo_status = "Installing..." dojo_status_color = "yellow" - dojo_initialized = "" - return dojo_status, dojo_status_color, dojo_initialized + return dojo_status, dojo_status_color if is_testnet_enabled(): dojo_status = "Requires Mainnet" dojo_status_color = "gray" - dojo_initialized = "" - return dojo_status, dojo_status_color, dojo_initialized + return dojo_status, dojo_status_color + + init = is_dojo_initialized() - try: - dojo_initialized = subprocess.check_output("docker inspect --format={{.State.Running}} db", shell=True) - dojo_initialized = dojo_initialized.strip() - except: - dojo_initialized = "" if is_service_enabled("dojo"): - if dojo_initialized != "false": + if init: if is_electrs_active(): dojo_status = "Running" dojo_status_color = "green" @@ -45,9 +50,8 @@ def get_dojo_status(): else: dojo_status = "Issue Starting" dojo_status_color = "red" - dojo_initialized = "" - return dojo_status, dojo_status_color, dojo_initialized + return dojo_status, dojo_status_color def get_dojo_tracker_status(): try: @@ -116,7 +120,12 @@ def dojo_page(): admin_key = get_dojo_admin_key() dojo_v3_addr = get_dojo_addr() - dojo_status, dojo_status_color, dojo_initialized = get_dojo_status() + dojo_status = "Running" + dojo_status_code = get_service_status_code("dojo") + if not is_dojo_initialized(): + dojo_status = "Issue Starting" + elif dojo_status_code != 0: + dojo_status = "Error" # Load page templateData = { @@ -125,9 +134,7 @@ def dojo_page(): "is_dojo_installed": is_dojo_installed(), "dojo_status": dojo_status, "dojo_version": get_dojo_version(), - "dojo_status_color": dojo_status_color, "dojo_enabled": is_service_enabled("dojo"), - "dojo_initialized": dojo_initialized, "dojo_tracker_status": get_dojo_tracker_status(), "electrs_status": get_electrs_status(), "NODE_ADMIN_KEY": admin_key, @@ -138,6 +145,5 @@ def dojo_page(): @mynode_dojo.route("/restart-dojo") def page_restart_dojo(): check_logged_in() - disable_dojo() - enable_dojo() + restart_service("dojo") return redirect("/dojo") diff --git a/rootfs/standard/var/www/mynode/enable_disable_functions.py b/rootfs/standard/var/www/mynode/enable_disable_functions.py index dc028709..4b3f7563 100644 --- a/rootfs/standard/var/www/mynode/enable_disable_functions.py +++ b/rootfs/standard/var/www/mynode/enable_disable_functions.py @@ -1,15 +1,16 @@ import os import subprocess +from werkzeug.routing import RequestRedirect from config import * from systemctl_info import * # Generic Enable / Disable Function def enable_service(short_name): - enable_actions(short_name) os.system("systemctl enable {} --no-pager".format(short_name)) os.system("systemctl start {} --no-pager".format(short_name)) open("/mnt/hdd/mynode/settings/{}_enabled".format(short_name), 'a').close() # touch file clear_service_enabled_cache() + enable_actions(short_name) def disable_service(short_name): enabled_file = "/mnt/hdd/mynode/settings/{}_enabled".format(short_name) @@ -22,7 +23,10 @@ def disable_service(short_name): # Functions to handle special enable/disable cases def enable_actions(short_name): - pass + if short_name == "dojo": + if not is_dojo_installed(): + install_dojo() + raise RequestRedirect("/settings/reboot-device") def disable_actions(short_name): if short_name == "electrs": @@ -33,7 +37,9 @@ def disable_actions(short_name): os.system("systemctl stop openvpn --no-pager") os.system("systemctl disable openvpn --no-pager") - +# Function to restart service +def restart_service(short_name): + os.system("systemctl restart {} --no-pager".format(short_name)) # Dojo install / uninstall functions.... future work to abstract this @@ -47,6 +53,6 @@ def install_dojo(): def uninstall_dojo(): os.system("rm -f " + DOJO_INSTALL_FILE) os.system("rf -f /mnt/hdd/mynode/settings/dojo_url") - disable_dojo() + disable_service("dojo") os.system("sync") diff --git a/rootfs/standard/var/www/mynode/mynode.py b/rootfs/standard/var/www/mynode/mynode.py index 5c52590d..d7d7a7bc 100644 --- a/rootfs/standard/var/www/mynode/mynode.py +++ b/rootfs/standard/var/www/mynode/mynode.py @@ -4,8 +4,8 @@ from flask import Flask, render_template, Markup, send_from_directory, redirect, from user_management import * from api import mynode_api from bitcoin import mynode_bitcoin -from whirlpool import mynode_whirlpool, get_whirlpool_status -from dojo import mynode_dojo, get_dojo_status +from whirlpool import mynode_whirlpool +from dojo import mynode_dojo from joininbox import mynode_joininbox from caravan import mynode_caravan from sphinxrelay import mynode_sphinxrelay @@ -456,10 +456,6 @@ def index(): } return render_template('syncing.html', **templateData) - # Find tor status - tor_status_color = get_service_status_color("tor@default") - tor_status = "Private Connections" - # Find bitcoid status bitcoin_info = get_bitcoin_blockchain_info() bitcoin_peers = get_bitcoin_peers() @@ -480,52 +476,6 @@ def index(): if int(re.sub("[^0-9]", "", drive_usage)) > 95: low_drive_space_error = True - - # Find lndhub status - lndhub_status, lndhub_status_color = get_lndhub_status_and_color() - - # Find RTL status - rtl_status, rtl_status_color = get_rtl_status_and_color() - - # Find LNbits status - lnbits_status, lnbits_status_color = get_lnbits_status_and_color() - - # Find Thunderhub status - thunderhub_status, thunderhub_status_color = get_thunderhub_status_and_color() - - # Find CKBunker status - ckbunker_status, ckbunker_status_color = get_ckbunker_status_and_color() - - # Find Sphinx Relay status - sphinxrelay_status, sphinxrelay_status_color = get_sphinxrelay_status_and_color() - - # Find electrs status - electrs_status, electrs_status_color = get_electrs_status_and_color() - - # Find btc-rpc-explorer status - btcrpcexplorer_status, btcrpcexplorer_status_color, btcrpcexplorer_ready = get_btcrpcexplorer_status_and_color_and_ready() - - # Find mempool space status - mempool_status, mempool_status_color = get_mempool_status_and_color() - - # Find btcpayserver status - btcpayserver_status, btcpayserver_status_color = get_btcpayserver_status_and_color() - - # Find VPN status - vpn_status, vpn_status_color = get_vpn_status_and_color() - - # Find whirlpool status - whirlpool_status, whirlpool_status_color, whirlpool_initialized = get_whirlpool_status() - - # Find dojo status - dojo_status, dojo_status_color, dojo_initialized = get_dojo_status() - - # Find caravan status - caravan_status, caravan_status_color = get_caravan_status_and_color() - - # Find specter status - specter_status, specter_status_color = get_specter_status_and_color() - # Check for new version of software upgrade_available = False current = get_current_version() @@ -544,7 +494,7 @@ def index(): "title": "myNode Home", "refresh_rate": refresh_rate, "config": CONFIG, - "apps": get_all_applications(order_by="alphabetic"), + "apps": get_all_applications(order_by="homepage"), "bitcoin_status_color": bitcoin_status_color, "bitcoin_status": Markup(bitcoin_status), "current_block": current_block, @@ -562,63 +512,10 @@ def index(): "lnd_version": get_lnd_version(), "lnd_deposit_address": get_lnd_deposit_address(), "lnd_channels": get_lightning_channels(), + "electrs_active": electrs_active, "is_testnet_enabled": is_testnet_enabled(), - "tor_status_color": tor_status_color, - "tor_status": tor_status, "is_installing_docker_images": is_installing_docker_images(), "is_device_from_reseller": is_device_from_reseller(), - "electrs_status_color": electrs_status_color, - "electrs_status": Markup(electrs_status), - "electrs_enabled": is_service_enabled("electrs"), - "electrs_active": electrs_active, - "rtl_status_color": rtl_status_color, - "rtl_status": rtl_status, - "rtl_enabled": is_service_enabled("rtl"), - "lnbits_status_color": lnbits_status_color, - "lnbits_status": lnbits_status, - "lnbits_enabled": is_service_enabled("lnbits"), - "thunderhub_status_color": thunderhub_status_color, - "thunderhub_status": thunderhub_status, - "thunderhub_enabled": is_service_enabled("thunderhub"), - "thunderhub_sso_token": get_thunderhub_sso_token(), - "ckbunker_status_color": ckbunker_status_color, - "ckbunker_status": ckbunker_status, - "ckbunker_enabled": is_service_enabled("ckbunker"), - "sphinxrelay_status_color": sphinxrelay_status_color, - "sphinxrelay_status": sphinxrelay_status, - "sphinxrelay_enabled": is_service_enabled("sphinxrelay"), - "lndhub_status_color": lndhub_status_color, - "lndhub_status": lndhub_status, - "lndhub_enabled": is_service_enabled("lndhub"), - "btcrpcexplorer_ready": btcrpcexplorer_ready, - "btcrpcexplorer_status_color": btcrpcexplorer_status_color, - "btcrpcexplorer_status": btcrpcexplorer_status, - "btcrpcexplorer_enabled": is_service_enabled("btcrpcexplorer"), - "btcrpcexplorer_sso_token": get_btcrpcexplorer_sso_token(), - "caravan_status_color": caravan_status_color, - "caravan_status": caravan_status, - "caravan_enabled": is_service_enabled("caravan"), - "specter_status_color": specter_status_color, - "specter_status": specter_status, - "specter_enabled": is_service_enabled("specter"), - "mempool_status_color": mempool_status_color, - "mempool_status": mempool_status, - "mempool_enabled": is_service_enabled("mempool"), - "btcpayserver_enabled": is_service_enabled("btcpayserver"), - "btcpayserver_status_color": btcpayserver_status_color, - "btcpayserver_status": btcpayserver_status, - "vpn_status_color": vpn_status_color, - "vpn_status": vpn_status, - "vpn_enabled": is_service_enabled("vpn"), - "whirlpool_status": whirlpool_status, - "whirlpool_status_color": whirlpool_status_color, - "whirlpool_enabled": is_service_enabled("whirlpool"), - "whirlpool_initialized": whirlpool_initialized, - "is_dojo_installed": is_dojo_installed(), - "dojo_status": dojo_status, - "dojo_status_color": dojo_status_color, - "dojo_enabled": is_service_enabled("dojo"), - "dojo_initialized": dojo_initialized, "product_key_skipped": pk_skipped, "product_key_error": pk_error, "fsck_error": has_fsck_error(), diff --git a/rootfs/standard/var/www/mynode/static/css/mynode.css b/rootfs/standard/var/www/mynode/static/css/mynode.css index 2c774da6..70cc21b9 100644 --- a/rootfs/standard/var/www/mynode/static/css/mynode.css +++ b/rootfs/standard/var/www/mynode/static/css/mynode.css @@ -383,6 +383,7 @@ table.bitcoin_table td { .red { background-color: red; } .gray { background-color: gray; } .blue { background-color: blue; } +.clear { opacity: 100%; } .green_text {color: green;} .yellow_text {color: yellow;} diff --git a/rootfs/standard/var/www/mynode/static/images/electrum_logo.png b/rootfs/standard/var/www/mynode/static/images/electrs.png similarity index 100% rename from rootfs/standard/var/www/mynode/static/images/electrum_logo.png rename to rootfs/standard/var/www/mynode/static/images/electrs.png diff --git a/rootfs/standard/var/www/mynode/static/images/sphinx.png b/rootfs/standard/var/www/mynode/static/images/sphinxrelay.png similarity index 100% rename from rootfs/standard/var/www/mynode/static/images/sphinx.png rename to rootfs/standard/var/www/mynode/static/images/sphinxrelay.png diff --git a/rootfs/standard/var/www/mynode/static/images/whirlpool.png b/rootfs/standard/var/www/mynode/static/images/whirlpool.png new file mode 100644 index 00000000..bed83724 Binary files /dev/null and b/rootfs/standard/var/www/mynode/static/images/whirlpool.png differ diff --git a/rootfs/standard/var/www/mynode/static/images/wp-black.png b/rootfs/standard/var/www/mynode/static/images/wp-black.png deleted file mode 100644 index 4a0079bc..00000000 Binary files a/rootfs/standard/var/www/mynode/static/images/wp-black.png and /dev/null differ diff --git a/rootfs/standard/var/www/mynode/static/images/wp-white.png b/rootfs/standard/var/www/mynode/static/images/wp-white.png deleted file mode 100644 index 8272a154..00000000 Binary files a/rootfs/standard/var/www/mynode/static/images/wp-white.png and /dev/null differ diff --git a/rootfs/standard/var/www/mynode/templates/dojo.html b/rootfs/standard/var/www/mynode/templates/dojo.html index 4fad024d..47ef3a83 100644 --- a/rootfs/standard/var/www/mynode/templates/dojo.html +++ b/rootfs/standard/var/www/mynode/templates/dojo.html @@ -49,7 +49,7 @@ Uninstall - {% if dojo_enabled and dojo_initialized and electrs_status == "Running" %} + {% if dojo_enabled and electrs_status == "Running" %}