Add upgrade and reinstall buttons to app page

This commit is contained in:
Taylor Helsper 2020-09-08 21:20:29 -05:00
parent 9786df8c55
commit eabd2df2df
5 changed files with 59 additions and 15 deletions

View File

@ -456,7 +456,7 @@ CURRENT=""
if [ -f $BTCRPCEXPLORER_VERSION_FILE ]; then
CURRENT=$(cat $BTCRPCEXPLORER_VERSION_FILE)
fi
if [ "$CURRENT" != "$BTCRPCEXPLORER_UPGRADE_URL" ]; then
if [ "$CURRENT" != "$BTCRPCEXPLORER_VERSION" ]; then
cd /opt/mynode
rm -rf btc-rpc-explorer
sudo -u bitcoin wget $BTCRPCEXPLORER_UPGRADE_URL -O btc-rpc-explorer.tar.gz
@ -468,7 +468,7 @@ if [ "$CURRENT" != "$BTCRPCEXPLORER_UPGRADE_URL" ]; then
mkdir -p /home/bitcoin/.mynode/
chown -R bitcoin:bitcoin /home/bitcoin/.mynode/
echo $BTCRPCEXPLORER_UPGRADE_URL > $BTCRPCEXPLORER_VERSION_FILE
echo $BTCRPCEXPLORER_VERSION > $BTCRPCEXPLORER_VERSION_FILE
fi

View File

@ -24,7 +24,7 @@ elif [ "$APP" = "lnd" ]; then
elif [ "$APP" = "loopd" ]; then
rm -f $LOOP_VERSION_FILE
elif [ "$APP" = "btcrpcexplorer" ]; then
rm -f /home/bitcoin/.mynode/.btcrpcexplorer_url # NEEDS UPDATE TO VERSION FILE
rm -f $BTCRPCEXPLORER_VERSION_FILE
elif [ "$APP" = "caravan" ]; then
rm -f $CARAVAN_VERSION_FILE
elif [ "$APP" = "corsproxy" ]; then
@ -32,7 +32,7 @@ elif [ "$APP" = "corsproxy" ]; then
elif [ "$APP" = "joinmarket" ]; then
rm -f $JOINMARKET_VERSION_FILE
elif [ "$APP" = "lnbits" ]; then
rm -f /home/bitcoin/.mynode/.lnbits_url # NEEDS UPDATE TO VERSION FILE
rm -f $LNBITS_VERSION_FILE
elif [ "$APP" = "lndconnect" ]; then
rm -f $LNDCONNECT_VERSION_FILE
elif [ "$APP" = "lndhub" ]; then

View File

@ -190,16 +190,34 @@ def has_checkin_error():
#==================================
def get_app_current_version(app):
version = "unknown"
filename = "/home/bitcoin/.mynode/"+app+"_version"
if os.path.isfile(filename):
version = get_file_contents(filename)
filename1 = "/home/bitcoin/.mynode/"+app+"_version"
filename2 = "/mnt/hdd/mynode/settings/"+app+"_version"
if os.path.isfile(filename1):
version = get_file_contents(filename1)
elif os.path.isfile(filename2):
version = get_file_contents(filename2)
else:
version = "not installed"
# For versions that are hashes, shorten them
version = version[0:16]
return version
def get_app_latest_version(app):
version = "unknown"
filename = "/home/bitcoin/.mynode/"+app+"_version_latest"
if os.path.isfile(filename):
version = get_file_contents(filename)
filename1 = "/home/bitcoin/.mynode/"+app+"_version_latest"
filename2 = "/mnt/hdd/mynode/settings/"+app+"_version_latest"
if os.path.isfile(filename1):
version = get_file_contents(filename1)
elif os.path.isfile(filename2):
version = get_file_contents(filename2)
else:
version = "error"
# For versions that are hashes, shorten them
version = version[0:16]
return version

View File

@ -2,6 +2,25 @@
<head>
<title>{{ title }}</title>
{% include 'includes/head.html' %}
<script>
function upgrade(name, short_name) {
if ( confirm("Are you sure you want to upgrade "+name+"? This will reboot your device.") ) {
window.location.href='/settings/reinstall-app?app='+short_name;
}
}
function reinstall(name, short_name) {
if ( confirm("Are you sure you want to re-install "+name+"? This will reboot your device.") ) {
window.location.href='/settings/reinstall-app?app='+short_name;
}
}
$(document).ready(function() {
});
</script>
</head>
<body>
{% include 'includes/logo_header.html' %}
@ -18,7 +37,7 @@
<td>Application</td>
<td>Current Version</td>
<td>Latest Version</td>
<td>Actions</td>
<td colspan="2">Actions</td>
</thead>
<tbody>
{% for app in apps %}
@ -26,7 +45,14 @@
<td>{{ app.name }}</td>
<td>{{ app.current_version }}</td>
<td>{{ app.latest_version }}</td>
<td></td>
<td>
{% if app.current_version != app.latest_version %}
<button class="ui-button ui-widget ui-corner-all mynode_button_small" onclick="upgrade('{{ app.name }}', '{{ app.short_name }}');">Upgrade</button>
{% endif %}
</td>
<td>
<button class="ui-button ui-widget ui-corner-all mynode_button_small" onclick="reinstall('{{ app.name }}', '{{ app.short_name }}');">Reinstall</button>
</td>
</tr>
{% endfor %}
</tbody>

View File

@ -576,16 +576,16 @@
<a href="/status" class="ui-button ui-widget ui-corner-all settings_button">Status</a>
</div>
<!--
<div class="settings_block">
<div class="settings_block_header">Applications</div>
<div class="settings_block_subheader">Manage Applications</div>
You can view application information and manage applications.
You can view application information and manage app upgrades.
<br/>
<a href="/apps" class="ui-button ui-widget ui-corner-all settings_button">Manage Apps</a>
</div>
-->
<div class="settings_block">
<div class="settings_block_header">User Interface</div>