From a2d7fba47fd0b898eb74bf3130c767e1ef6f6159 Mon Sep 17 00:00:00 2001 From: Taylor Helsper Date: Thu, 3 Sep 2020 20:37:51 -0500 Subject: [PATCH] Add basic outline for page to manage apps --- rootfs/standard/var/www/mynode/device_info.py | 45 ++++++++++++------- rootfs/standard/var/www/mynode/manage_apps.py | 38 ++++++++++++++++ rootfs/standard/var/www/mynode/mynode.py | 2 + .../var/www/mynode/templates/manage_apps.html | 37 +++++++++++++++ .../var/www/mynode/templates/settings.html | 11 +++++ 5 files changed, 117 insertions(+), 16 deletions(-) create mode 100644 rootfs/standard/var/www/mynode/manage_apps.py create mode 100644 rootfs/standard/var/www/mynode/templates/manage_apps.html diff --git a/rootfs/standard/var/www/mynode/device_info.py b/rootfs/standard/var/www/mynode/device_info.py index 65eb1b46..9d1fbc7f 100644 --- a/rootfs/standard/var/www/mynode/device_info.py +++ b/rootfs/standard/var/www/mynode/device_info.py @@ -131,22 +131,6 @@ def mark_upgrade_started(): def is_upgrade_running(): return os.path.isfile("/tmp/upgrade_started") -def reinstall_app(app): - if not is_upgrade_running(): - mark_upgrade_started() - - # Upgrade - os.system("mkdir -p /home/admin/upgrade_logs") - cmd = "/usr/bin/mynode_reinstall_app.sh {} > /home/admin/upgrade_logs/reinstall_{}.txt 2>&1".format(app,app) - subprocess.call(cmd, shell=True) - - # Sync - os.system("sync") - time.sleep(1) - - # Reboot - reboot_device() - def upgrade_device(): if not is_upgrade_running(): mark_upgrade_started() @@ -200,6 +184,35 @@ def get_recent_upgrade_logs(): def has_checkin_error(): return os.path.isfile("/tmp/check_in_error") + +#================================== +# Manage Apps +#================================== +def get_app_current_version(app): + version = "unknown" + filename = "/home/bitcoin/.mynode/"+app+"_version" + if os.path.isfile(filename): + version = get_file_contents(filename) + return version + + +# This is going to be the "old" way to install apps +def reinstall_app(app): + if not is_upgrade_running(): + mark_upgrade_started() + + # Upgrade + os.system("mkdir -p /home/admin/upgrade_logs") + cmd = "/usr/bin/mynode_reinstall_app.sh {} > /home/admin/upgrade_logs/reinstall_{}.txt 2>&1".format(app,app) + subprocess.call(cmd, shell=True) + + # Sync + os.system("sync") + time.sleep(1) + + # Reboot + reboot_device() + #================================== # Reseller Info #================================== diff --git a/rootfs/standard/var/www/mynode/manage_apps.py b/rootfs/standard/var/www/mynode/manage_apps.py new file mode 100644 index 00000000..92d66554 --- /dev/null +++ b/rootfs/standard/var/www/mynode/manage_apps.py @@ -0,0 +1,38 @@ + +from flask import Blueprint, render_template, redirect +from user_management import check_logged_in +from device_info import * +import subprocess +import re +import os + +mynode_manage_apps = Blueprint('mynode_manage_apps',__name__) + + +### Page functions +@mynode_manage_apps.route("/apps") +def caravan_page(): + check_logged_in() + + apps = [] + apps.append({"name":"Bitcoin", "short_name": "bitcoin"}) + apps.append({"name":"LND", "short_name": "lnd"}) + apps.append({"name":"Loop", "short_name": "loop"}) + #apps.append({"name":"Electrum Server", "short_name": "electrs"}) + #apps.append({"name":"LND Hub", "short_name": "lndhub"}) + #apps.append({"name":"BTC RPC Explorer", "short_name": "btc_rpc_explorer"}) + apps.append({"name":"Ride the Lightning", "short_name": "rtl"}) + apps.append({"name":"Thunderhub", "short_name": "thunderhub"}) + #apps.append({"name":"LNbits", "short_name": "lnbits"}) + apps.append({"name":"Specter", "short_name": "specter"}) + + for app in apps: + app["current_version"] = get_app_current_version(app["short_name"]) + + # Load page + templateData = { + "title": "myNode Manage Apps", + "ui_settings": read_ui_settings(), + "apps": apps + } + return render_template('manage_apps.html', **templateData) diff --git a/rootfs/standard/var/www/mynode/mynode.py b/rootfs/standard/var/www/mynode/mynode.py index 0139e4f1..839e857e 100644 --- a/rootfs/standard/var/www/mynode/mynode.py +++ b/rootfs/standard/var/www/mynode/mynode.py @@ -6,6 +6,7 @@ from bitcoind import mynode_bitcoind from whirlpool import mynode_whirlpool, get_whirlpool_status from dojo import mynode_dojo, get_dojo_status from caravan import mynode_caravan +from manage_apps import mynode_manage_apps from tor import mynode_tor from vpn import mynode_vpn from electrum_server import * @@ -71,6 +72,7 @@ app.register_blueprint(mynode_lnd) app.register_blueprint(mynode_whirlpool) app.register_blueprint(mynode_dojo) app.register_blueprint(mynode_caravan) +app.register_blueprint(mynode_manage_apps) app.register_blueprint(mynode_tor) app.register_blueprint(mynode_electrum_server) app.register_blueprint(mynode_vpn) diff --git a/rootfs/standard/var/www/mynode/templates/manage_apps.html b/rootfs/standard/var/www/mynode/templates/manage_apps.html new file mode 100644 index 00000000..ccd5018e --- /dev/null +++ b/rootfs/standard/var/www/mynode/templates/manage_apps.html @@ -0,0 +1,37 @@ + + + {{ title }} + {% include 'includes/head.html' %} + + + {% include 'includes/logo_header.html' %} +
+ home  +
+ +
Manage Applications
+
+ +

+ + + + + + + + {% for app in apps %} + + + + + + {% endfor %} + +
ApplicationCurrent VersionActions
{{ app.name }}{{ app.current_version }}
+ +

+ + {% include 'includes/footer.html' %} + + diff --git a/rootfs/standard/var/www/mynode/templates/settings.html b/rootfs/standard/var/www/mynode/templates/settings.html index 7039a0c6..eea4b63d 100644 --- a/rootfs/standard/var/www/mynode/templates/settings.html +++ b/rootfs/standard/var/www/mynode/templates/settings.html @@ -576,6 +576,17 @@ Status + +
User Interface