From 601dbea4a88eedba88db3098852222a7d47d97eb Mon Sep 17 00:00:00 2001 From: Taylor Helsper Date: Mon, 17 May 2021 19:40:18 -0500 Subject: [PATCH] Remove special install/uninstall for Dojo --- .../standard/usr/bin/mynode_docker_images.sh | 6 +-- .../var/www/mynode/application_info.py | 10 ++++- rootfs/standard/var/www/mynode/dojo.py | 1 - .../www/mynode/enable_disable_functions.py | 20 +-------- rootfs/standard/var/www/mynode/mynode.py | 42 ------------------- .../var/www/mynode/templates/dojo.html | 1 - 6 files changed, 12 insertions(+), 68 deletions(-) diff --git a/rootfs/standard/usr/bin/mynode_docker_images.sh b/rootfs/standard/usr/bin/mynode_docker_images.sh index 8316c7cf..9bc7ae8a 100755 --- a/rootfs/standard/usr/bin/mynode_docker_images.sh +++ b/rootfs/standard/usr/bin/mynode_docker_images.sh @@ -89,13 +89,13 @@ while true; do CURRENT="" INSTALL=true # If Upgrade file existed, mark "install" choice for legacy devices - if [ -f /mnt/hdd/mynode/settings/dojo_url ]; then - touch /mnt/hdd/mynode/settings/mynode_dojo_install + if [ -f /mnt/hdd/mynode/settings/dojo_url ] || [ -f /mnt/hdd/mynode/settings/mynode_dojo_install ]; then + touch /mnt/hdd/mynode/settings/install_dojo sync sleep 3s fi # Only install Dojo if marked for installation and testnet not enabled - if [ -f /mnt/hdd/mynode/settings/mynode_dojo_install ] && [ ! -f $IS_TESTNET_ENABLED_FILE ]; then + if [ -f /mnt/hdd/mynode/settings/install_dojo ] && [ ! -f $IS_TESTNET_ENABLED_FILE ]; then if [ -f $DOJO_UPGRADE_URL_FILE ] && [ ! -f $DOJO_VERSION_FILE ]; then echo $DOJO_VERSION > $DOJO_VERSION_FILE sync diff --git a/rootfs/standard/var/www/mynode/application_info.py b/rootfs/standard/var/www/mynode/application_info.py index a24fd229..59824ea5 100644 --- a/rootfs/standard/var/www/mynode/application_info.py +++ b/rootfs/standard/var/www/mynode/application_info.py @@ -54,8 +54,14 @@ def uninstall_app(app): # Sync os.system("sync") -def is_installed(current_version): - return current_version != "not installed" +def is_installed(short_name): + filename1 = "/home/bitcoin/.mynode/"+short_name+"_install" + filename2 = "/mnt/hdd/mynode/settings/"+short_name+"_install" + if os.path.isfile(filename1): + return True + elif os.path.isfile(filename2): + return True + return False def get_app_current_version(short_name): version = "unknown" diff --git a/rootfs/standard/var/www/mynode/dojo.py b/rootfs/standard/var/www/mynode/dojo.py index 57abeeb9..c1d7eea4 100644 --- a/rootfs/standard/var/www/mynode/dojo.py +++ b/rootfs/standard/var/www/mynode/dojo.py @@ -131,7 +131,6 @@ def dojo_page(): templateData = { "title": "myNode Dojo", "ui_settings": read_ui_settings(), - "is_dojo_installed": is_dojo_installed(), "dojo_status": dojo_status, "dojo_version": get_dojo_version(), "dojo_enabled": is_service_enabled("dojo"), diff --git a/rootfs/standard/var/www/mynode/enable_disable_functions.py b/rootfs/standard/var/www/mynode/enable_disable_functions.py index 4b3f7563..a937206c 100644 --- a/rootfs/standard/var/www/mynode/enable_disable_functions.py +++ b/rootfs/standard/var/www/mynode/enable_disable_functions.py @@ -23,10 +23,7 @@ def disable_service(short_name): # Functions to handle special enable/disable cases def enable_actions(short_name): - if short_name == "dojo": - if not is_dojo_installed(): - install_dojo() - raise RequestRedirect("/settings/reboot-device") + pass def disable_actions(short_name): if short_name == "electrs": @@ -41,18 +38,3 @@ def disable_actions(short_name): def restart_service(short_name): os.system("systemctl restart {} --no-pager".format(short_name)) - -# Dojo install / uninstall functions.... future work to abstract this -def is_dojo_installed(): - return os.path.isfile(DOJO_INSTALL_FILE) - -def install_dojo(): - os.system("touch " + DOJO_INSTALL_FILE) - os.system("sync") - -def uninstall_dojo(): - os.system("rm -f " + DOJO_INSTALL_FILE) - os.system("rf -f /mnt/hdd/mynode/settings/dojo_url") - 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 8868d015..d557a335 100644 --- a/rootfs/standard/var/www/mynode/mynode.py +++ b/rootfs/standard/var/www/mynode/mynode.py @@ -614,48 +614,6 @@ def page_toggle_app(): enable_service(app_short_name) return redirect("/") -@app.route("/toggle-dojo-install") -def page_toggle_dojo_install(): - check_logged_in() - - # In case of refresh, mark toggle was started - check_and_mark_reboot_action("toggle_dojo_install") - - if is_dojo_installed(): - # Mark app as not installed - uninstall_dojo() - - # Re-install app (this will uninstall and not re-install after reboot since install file is missing) - t = Timer(1.0, reinstall_app, ["dojo"]) - t.start() - - # Display wait page - templateData = { - "title": "myNode Uninstall", - "header_text": "Uninstalling", - "subheader_text": "This may take a while...", - "ui_settings": read_ui_settings() - } - return render_template('reboot.html', **templateData) - else: - # Mark Dojo for install - install_dojo() - - # Re-install app - t = Timer(1.0, reboot_device) - t.start() - - # Display wait page - templateData = { - "title": "myNode Install", - "header_text": "Installing", - "subheader_text": "This may take a while...", - "ui_settings": read_ui_settings() - } - return render_template('reboot.html', **templateData) - - return redirect("/") - @app.route("/clear-fsck-error") def page_clear_fsck_error(): check_logged_in() diff --git a/rootfs/standard/var/www/mynode/templates/dojo.html b/rootfs/standard/var/www/mynode/templates/dojo.html index 47ef3a83..19cac874 100644 --- a/rootfs/standard/var/www/mynode/templates/dojo.html +++ b/rootfs/standard/var/www/mynode/templates/dojo.html @@ -46,7 +46,6 @@ {% if dojo_enabled %} Restart {% endif %} - Uninstall {% if dojo_enabled and electrs_status == "Running" %}