Add page for customizing app versions
This commit is contained in:
parent
57fc6aff15
commit
ad4c075f2d
|
@ -128,7 +128,6 @@ WEBSSH2_LATEST_VERSION_FILE=/mnt/hdd/mynode/settings/webssh2_version_latest
|
|||
# Check for override files
|
||||
if [ -f /usr/share/mynode/mynode_app_versions_custom.sh ]; then
|
||||
source /usr/share/mynode/mynode_app_versions_custom.sh
|
||||
fi
|
||||
if [ -f /mnt/hdd/mynode/settings/mynode_app_versions_custom.sh ]; then
|
||||
elif [ -f /mnt/hdd/mynode/settings/mynode_app_versions_custom.sh ]; then
|
||||
source /mnt/hdd/mynode/settings/mynode_app_versions_custom.sh
|
||||
fi
|
|
@ -3,6 +3,7 @@ from lightning_info import *
|
|||
from electrum_info import *
|
||||
from device_info import *
|
||||
from systemctl_info import *
|
||||
from utilities import *
|
||||
import copy
|
||||
import json
|
||||
import subprocess
|
||||
|
@ -678,4 +679,30 @@ def has_customized_app_versions():
|
|||
return True
|
||||
if os.path.isfile("/mnt/hdd/mynode/settings/mynode_app_versions_custom.sh"):
|
||||
return True
|
||||
return False
|
||||
return False
|
||||
|
||||
def get_app_version_data():
|
||||
try:
|
||||
contents = subprocess.check_output('cat /usr/share/mynode/mynode_app_versions.sh | grep "_VERSION="', shell=True)
|
||||
return contents
|
||||
except Exception as e:
|
||||
return "ERROR"
|
||||
|
||||
def get_custom_app_version_data():
|
||||
if os.path.isfile("/usr/share/mynode/mynode_app_versions_custom.sh"):
|
||||
return get_file_contents("/usr/share/mynode/mynode_app_versions_custom.sh")
|
||||
if os.path.isfile("/mnt/hdd/mynode/settings/mynode_app_versions_custom.sh"):
|
||||
return get_file_contents("/mnt/hdd/mynode/settings/mynode_app_versions_custom.sh")
|
||||
return ""
|
||||
|
||||
def save_custom_app_version_data(data):
|
||||
set_file_contents("/usr/share/mynode/mynode_app_versions_custom.sh", data)
|
||||
set_file_contents("/mnt/hdd/mynode/settings/mynode_app_versions_custom.sh", data)
|
||||
need_application_refresh()
|
||||
os.system("sync")
|
||||
|
||||
def reset_custom_app_version_data():
|
||||
os.system("rm -f /usr/share/mynode/mynode_app_versions_custom.sh")
|
||||
os.system("rm -f /mnt/hdd/mynode/settings/mynode_app_versions_custom.sh")
|
||||
need_application_refresh()
|
||||
os.system("sync")
|
|
@ -51,6 +51,33 @@ def restart_app_page():
|
|||
flash("Application restarting!", category="message")
|
||||
return redirect("/apps")
|
||||
|
||||
@mynode_manage_apps.route("/apps/customize-app-versions")
|
||||
@mynode_manage_apps.route("/apps/customize-app-versions", methods=['GET','POST'])
|
||||
def customize_app_versions_page():
|
||||
return "TODO"
|
||||
check_logged_in()
|
||||
|
||||
app_version_data=get_app_version_data()
|
||||
custom_app_version_data=get_custom_app_version_data()
|
||||
|
||||
# Reset Config
|
||||
if request.args.get("reset") and request.args.get("reset") == "1":
|
||||
reset_custom_app_version_data()
|
||||
flash("Custom config reset!", category="message")
|
||||
return redirect("/apps/customize-app-versions")
|
||||
|
||||
# Save Config
|
||||
if request.method == 'POST' and request.form.get('app_data'):
|
||||
custom_app_data = request.form.get('app_data')
|
||||
save_custom_app_version_data(custom_app_data)
|
||||
flash("Custom config saved!", category="message")
|
||||
return redirect("/apps/customize-app-versions")
|
||||
|
||||
# Load page
|
||||
templateData = {
|
||||
"title": "myNode Customize App Versions",
|
||||
"ui_settings": read_ui_settings(),
|
||||
"product_key_skipped": skipped_product_key(),
|
||||
"has_customized_app_versions": has_customized_app_versions(),
|
||||
"app_version_data": app_version_data,
|
||||
"custom_app_version_data": custom_app_version_data
|
||||
}
|
||||
return render_template('customize_app_versions.html', **templateData)
|
|
@ -145,6 +145,15 @@ td, th {
|
|||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.text_block {
|
||||
width: 800px;
|
||||
color: #444444;
|
||||
margin: auto;
|
||||
text-align: left;
|
||||
font-size: 14px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.error_message {
|
||||
color: red;
|
||||
font-size: 16px;
|
||||
|
|
|
@ -14,7 +14,8 @@
|
|||
{% include 'includes/message_display.html' %}
|
||||
|
||||
<div class="main_header">Bitcoin Config</div>
|
||||
<div class="main_header_sub_text">
|
||||
|
||||
<div class="text_block">
|
||||
You can edit the Bitcoin config. However, using your own config will prevent any future automatic updates and may have adverse effects.
|
||||
<br/><br/>
|
||||
Saving will reboot your device.
|
||||
|
@ -26,6 +27,7 @@
|
|||
<div class="settings_block_subheader_status_icon yellow"></div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="centered_text_div">
|
||||
<form action="/bitcoin/config" method="POST">
|
||||
<textarea class="config_textarea" name="custom_config" id="custom_config">{{ bitcoin_config }}</textarea>
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
<!DOCTYPE html lang="en">
|
||||
<head>
|
||||
<title>{{ title }}</title>
|
||||
{% include 'includes/head.html' %}
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$("#show_config_button").on("click", function() {
|
||||
visible = $("#default_version_config").is(':visible');
|
||||
if (visible) {
|
||||
$("#show_config_button").html("Show Default Version Config");
|
||||
$("#default_version_config").hide();
|
||||
} else {
|
||||
$("#show_config_button").html("Hide Default Version Config");
|
||||
$("#default_version_config").show();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
{% include 'includes/logo_header.html' %}
|
||||
<div class="mynode_back_div">
|
||||
<a class="ui-button ui-widget ui-corner-all mynode_back" href="/"><span class="ui-icon ui-icon-home"></span>home </a>
|
||||
<a class="ui-button ui-widget ui-corner-all mynode_back" href="/settings"><span class="ui-icon ui-icon-gear"></span>settings </a>
|
||||
</div>
|
||||
|
||||
{% include 'includes/message_display.html' %}
|
||||
|
||||
<div class="main_header">Custom Application Versions</div>
|
||||
<br/>
|
||||
|
||||
{% if product_key_skipped %}
|
||||
<div class="text_block">Customizing app versions via the GUI is a Premium Feature</div>
|
||||
{% else %}
|
||||
|
||||
<div class="text_block">
|
||||
You can override the version each application myNode installs. If you override it, future myNode updates will
|
||||
not affect the version you have specified.
|
||||
<br/><br/>
|
||||
|
||||
Saving will update the "Latest Version" of an app shown on the application page. To perform the upgrade,
|
||||
you will need to update it there.
|
||||
<br/><br/>
|
||||
|
||||
<b>Caution:</b> Errors in this file may prevent myNode from booting properly.
|
||||
|
||||
To see the available variables, use the format from the included default myNode version configuration.
|
||||
<br/><br/>
|
||||
|
||||
<button id="show_config_button" class="ui-button ui-widget ui-corner-all mynode_button_small">Show Default Version Config</button>
|
||||
<div id="default_version_config" style="display: none;"><pre>{{app_version_data}}</pre></div>
|
||||
<br/>
|
||||
{% if has_customized_app_versions %}
|
||||
<br/>
|
||||
<div class="settings_block_subheader_status_icon yellow"></div>
|
||||
<i>You currently have saved data in a custom versions file.</i>
|
||||
<div class="settings_block_subheader_status_icon yellow"></div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="centered_text_div">
|
||||
<form action="/apps/customize-app-versions" method="POST">
|
||||
<textarea class="config_textarea" name="app_data" id="app_data">{{ custom_app_version_data }}</textarea>
|
||||
<br/><br/>
|
||||
<input class="ui-button ui-widget ui-corner-all" type="submit" value="Save"/>
|
||||
<a href="/apps/customize-app-versions?reset=1" class="ui-button ui-widget ui-corner-all">Reset Customization</a>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% include 'includes/footer.html' %}
|
||||
</body>
|
||||
</html>
|
|
@ -14,7 +14,8 @@
|
|||
{% include 'includes/message_display.html' %}
|
||||
|
||||
<div class="main_header">LND Custom Config</div>
|
||||
<div class="main_header_sub_text">
|
||||
|
||||
<div class="text_block">
|
||||
You can edit the LND config. However, using your own config will prevent any future automatic updates and may have adverse effects.
|
||||
<br/><br/>
|
||||
Saving will reboot your device.
|
||||
|
@ -26,6 +27,7 @@
|
|||
<div class="settings_block_subheader_status_icon yellow"></div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="centered_text_div">
|
||||
<form action="/lnd/config" method="POST">
|
||||
<textarea class="config_textarea" name="custom_config" id="custom_config">{{ lnd_config }}</textarea>
|
||||
|
|
Loading…
Reference in New Issue
Block a user