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

View File

@ -24,7 +24,7 @@ elif [ "$APP" = "lnd" ]; then
elif [ "$APP" = "loopd" ]; then elif [ "$APP" = "loopd" ]; then
rm -f $LOOP_VERSION_FILE rm -f $LOOP_VERSION_FILE
elif [ "$APP" = "btcrpcexplorer" ]; then 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 elif [ "$APP" = "caravan" ]; then
rm -f $CARAVAN_VERSION_FILE rm -f $CARAVAN_VERSION_FILE
elif [ "$APP" = "corsproxy" ]; then elif [ "$APP" = "corsproxy" ]; then
@ -32,7 +32,7 @@ elif [ "$APP" = "corsproxy" ]; then
elif [ "$APP" = "joinmarket" ]; then elif [ "$APP" = "joinmarket" ]; then
rm -f $JOINMARKET_VERSION_FILE rm -f $JOINMARKET_VERSION_FILE
elif [ "$APP" = "lnbits" ]; then 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 elif [ "$APP" = "lndconnect" ]; then
rm -f $LNDCONNECT_VERSION_FILE rm -f $LNDCONNECT_VERSION_FILE
elif [ "$APP" = "lndhub" ]; then elif [ "$APP" = "lndhub" ]; then

View File

@ -190,16 +190,34 @@ def has_checkin_error():
#================================== #==================================
def get_app_current_version(app): def get_app_current_version(app):
version = "unknown" version = "unknown"
filename = "/home/bitcoin/.mynode/"+app+"_version" filename1 = "/home/bitcoin/.mynode/"+app+"_version"
if os.path.isfile(filename): filename2 = "/mnt/hdd/mynode/settings/"+app+"_version"
version = get_file_contents(filename) 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 return version
def get_app_latest_version(app): def get_app_latest_version(app):
version = "unknown" version = "unknown"
filename = "/home/bitcoin/.mynode/"+app+"_version_latest" filename1 = "/home/bitcoin/.mynode/"+app+"_version_latest"
if os.path.isfile(filename): filename2 = "/mnt/hdd/mynode/settings/"+app+"_version_latest"
version = get_file_contents(filename) 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 return version

View File

@ -2,6 +2,25 @@
<head> <head>
<title>{{ title }}</title> <title>{{ title }}</title>
{% include 'includes/head.html' %} {% 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> </head>
<body> <body>
{% include 'includes/logo_header.html' %} {% include 'includes/logo_header.html' %}
@ -18,7 +37,7 @@
<td>Application</td> <td>Application</td>
<td>Current Version</td> <td>Current Version</td>
<td>Latest Version</td> <td>Latest Version</td>
<td>Actions</td> <td colspan="2">Actions</td>
</thead> </thead>
<tbody> <tbody>
{% for app in apps %} {% for app in apps %}
@ -26,7 +45,14 @@
<td>{{ app.name }}</td> <td>{{ app.name }}</td>
<td>{{ app.current_version }}</td> <td>{{ app.current_version }}</td>
<td>{{ app.latest_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> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>

View File

@ -576,16 +576,16 @@
<a href="/status" class="ui-button ui-widget ui-corner-all settings_button">Status</a> <a href="/status" class="ui-button ui-widget ui-corner-all settings_button">Status</a>
</div> </div>
<!--
<div class="settings_block"> <div class="settings_block">
<div class="settings_block_header">Applications</div> <div class="settings_block_header">Applications</div>
<div class="settings_block_subheader">Manage 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/> <br/>
<a href="/apps" class="ui-button ui-widget ui-corner-all settings_button">Manage Apps</a> <a href="/apps" class="ui-button ui-widget ui-corner-all settings_button">Manage Apps</a>
</div> </div>
-->
<div class="settings_block"> <div class="settings_block">
<div class="settings_block_header">User Interface</div> <div class="settings_block_header">User Interface</div>