Improve upgrade logs

This commit is contained in:
Taylor Helsper 2021-01-07 14:52:41 -06:00
parent 07769e2857
commit fc3ee4f62d
4 changed files with 26 additions and 6 deletions

View File

@ -64,7 +64,11 @@ VERSION=$(cat /usr/share/mynode/version)
touch $UPGRADE_ERROR_FILE
for i in {1..5}
do
/bin/bash /usr/bin/mynode_post_upgrade.sh > /home/admin/upgrade_logs/upgrade_log_${VERSION}_post_${i}.txt 2>&1
# Clear old upgrade logs
rm -f /home/admin/upgrade_logs/upgrade_log_${VERSION}_post_*
rm -f /home/admin/upgrade_logs/upgrade_log_latest_post_*
/bin/bash /usr/bin/mynode_post_upgrade.sh 2>&1 | tee /home/admin/upgrade_logs/upgrade_log_${VERSION}_post_${i}.txt /home/admin/upgrade_logs/upgrade_log_latest_post_${i}.txt
RC=$?
if [ "${RC}" -eq "0" ]; then
rm -f $UPGRADE_ERROR_FILE

View File

@ -173,7 +173,9 @@ def upgrade_device():
# Upgrade
os.system("mkdir -p /home/admin/upgrade_logs")
cmd = "/usr/bin/mynode_upgrade.sh > /home/admin/upgrade_logs/upgrade_log_from_{}_upgrade.txt 2>&1".format(get_current_version())
file1 = "/home/admin/upgrade_logs/upgrade_log_from_{}_upgrade.txt".format(get_current_version())
file2 = "/home/admin/upgrade_logs/upgrade_log_latest.txt"
cmd = "/usr/bin/mynode_upgrade.sh 2>&1 | tee {} {}".format(file1, file2)
subprocess.call(cmd, shell=True)
# Sync
@ -189,7 +191,9 @@ def upgrade_device_beta():
# Upgrade
os.system("mkdir -p /home/admin/upgrade_logs")
cmd = "/usr/bin/mynode_upgrade.sh beta > /home/admin/upgrade_logs/upgrade_log_from_{}_upgrade.txt 2>&1".format(get_current_version())
file1 = "/home/admin/upgrade_logs/upgrade_log_from_{}_upgrade.txt".format(get_current_version())
file2 = "/home/admin/upgrade_logs/upgrade_log_latest.txt"
cmd = "/usr/bin/mynode_upgrade.sh beta 2>&1 | tee {} {}".format(file1, file2)
subprocess.call(cmd, shell=True)
# Sync

View File

@ -321,6 +321,16 @@ def upgrade_beta_page():
}
return render_template('reboot.html', **templateData)
@mynode_settings.route("/settings/get-upgrade-log")
def get_upgrade_log_page():
check_logged_in()
log = get_file_contents("/home/admin/upgrade_logs/upgrade_log_latest.txt")
if (log == "ERROR"):
log = "No log file found"
return log
@mynode_settings.route("/settings/get-latest-version")
def get_latest_version_page():
check_logged_in()

View File

@ -427,7 +427,10 @@
<tr>
<td>Latest Version</td>
<td>{{latest_version}}</td>
<td>&nbsp;<a href="/settings/get-latest-version" class="ui-button ui-widget ui-corner-all settings_button_small">Check for Updates</a></td>
<td>
&nbsp;<a href="/settings/get-latest-version" class="ui-button ui-widget ui-corner-all settings_button_small">Check for Updates</a>
&nbsp;<button id="show_upgrade_status" class="ui-button ui-widget ui-corner-all settings_button_small">Show Upgrade Log</button>
</td>
</tr>
</table>
{% if current_version != latest_version and latest_version != "" %}
@ -440,9 +443,8 @@
{% elif not product_key_skipped and upgrade_error %}
<p style="color: red;">It appears a recent upgrade may not have fully completed.</p>
<button id="upgrade" class="ui-button ui-widget ui-corner-all settings_button">Retry Upgrade</button>
<button id="show_upgrade_status" class="ui-button ui-widget ui-corner-all settings_button">Show Upgrade Logs</button>
<div id="upgrade_status" style='text-align: left; font-size: 12px; width: 800px; display: none;'><pre>{{upgrade_logs}}</pre></div>
{% endif %}
<div id="upgrade_status" style='text-align: left; font-size: 12px; width: 800px; display: none;'><pre>{{upgrade_logs}}</pre></div>
<div class="divider"></div>