Remove special install/uninstall for Dojo

This commit is contained in:
Taylor Helsper 2021-05-17 19:40:18 -05:00
parent fd95edcef8
commit 601dbea4a8
6 changed files with 12 additions and 68 deletions

View File

@ -89,13 +89,13 @@ while true; do
CURRENT="" CURRENT=""
INSTALL=true INSTALL=true
# If Upgrade file existed, mark "install" choice for legacy devices # If Upgrade file existed, mark "install" choice for legacy devices
if [ -f /mnt/hdd/mynode/settings/dojo_url ]; then if [ -f /mnt/hdd/mynode/settings/dojo_url ] || [ -f /mnt/hdd/mynode/settings/mynode_dojo_install ]; then
touch /mnt/hdd/mynode/settings/mynode_dojo_install touch /mnt/hdd/mynode/settings/install_dojo
sync sync
sleep 3s sleep 3s
fi fi
# Only install Dojo if marked for installation and testnet not enabled # 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 if [ -f $DOJO_UPGRADE_URL_FILE ] && [ ! -f $DOJO_VERSION_FILE ]; then
echo $DOJO_VERSION > $DOJO_VERSION_FILE echo $DOJO_VERSION > $DOJO_VERSION_FILE
sync sync

View File

@ -54,8 +54,14 @@ def uninstall_app(app):
# Sync # Sync
os.system("sync") os.system("sync")
def is_installed(current_version): def is_installed(short_name):
return current_version != "not installed" 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): def get_app_current_version(short_name):
version = "unknown" version = "unknown"

View File

@ -131,7 +131,6 @@ def dojo_page():
templateData = { templateData = {
"title": "myNode Dojo", "title": "myNode Dojo",
"ui_settings": read_ui_settings(), "ui_settings": read_ui_settings(),
"is_dojo_installed": is_dojo_installed(),
"dojo_status": dojo_status, "dojo_status": dojo_status,
"dojo_version": get_dojo_version(), "dojo_version": get_dojo_version(),
"dojo_enabled": is_service_enabled("dojo"), "dojo_enabled": is_service_enabled("dojo"),

View File

@ -23,10 +23,7 @@ def disable_service(short_name):
# Functions to handle special enable/disable cases # Functions to handle special enable/disable cases
def enable_actions(short_name): def enable_actions(short_name):
if short_name == "dojo": pass
if not is_dojo_installed():
install_dojo()
raise RequestRedirect("/settings/reboot-device")
def disable_actions(short_name): def disable_actions(short_name):
if short_name == "electrs": if short_name == "electrs":
@ -41,18 +38,3 @@ def disable_actions(short_name):
def restart_service(short_name): def restart_service(short_name):
os.system("systemctl restart {} --no-pager".format(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")

View File

@ -614,48 +614,6 @@ def page_toggle_app():
enable_service(app_short_name) enable_service(app_short_name)
return redirect("/") 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") @app.route("/clear-fsck-error")
def page_clear_fsck_error(): def page_clear_fsck_error():
check_logged_in() check_logged_in()

View File

@ -46,7 +46,6 @@
{% if dojo_enabled %} {% if dojo_enabled %}
<a class="ui-button ui-widget ui-corner-all mynode_button_small" style="width: 100px;" href="/restart-dojo">Restart</a> <a class="ui-button ui-widget ui-corner-all mynode_button_small" style="width: 100px;" href="/restart-dojo">Restart</a>
{% endif %} {% endif %}
<a class="ui-button ui-widget ui-corner-all mynode_button_small" style="width: 100px;" href="/toggle-dojo-install">Uninstall</a>
</td> </td>
</tr> </tr>
{% if dojo_enabled and electrs_status == "Running" %} {% if dojo_enabled and electrs_status == "Running" %}