Files
webgui/plugins/dynamix.plugin.manager/Update.page

115 lines
3.8 KiB
Plaintext

Menu="About"
Title="Update OS"
Tag="thumbs-up"
---
<?PHP
/* Copyright 2005-2018, Lime Technology
* Copyright 2012-2018, Bergware International.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*/
?>
<?
$version = $date = 'unknown';
$bzroot = file_exists('/boot/previous/bzroot');
$check = $notify['unraidos'] ? 0 : 1;
if (file_exists('/boot/previous/changes.txt')) {
exec("head -n4 /boot/previous/changes.txt",$rows);
foreach ($rows as $row) {
$i = stripos($row,'version');
if ($i !== false) {
list($version,$date) = explode(' ',trim(substr($row,$i+7)));
break;
}
}
}
?>
<style>input[type=button]{margin:0}</style>
<script>
function change_branch(source,branch) {
$('#os_list').html('<tr><td colspan="6"><div class="spinner"></div></td><tr>');
$.get('/plugins/dynamix.plugin.manager/include/ShowPlugins.php',{system:true,source:source,branch:branch},function(data) {
$('#os_list').html(data);
});
}
function change_version(current,release,branch) {
if ($('#os-install').length) {
var status = '#os-install';
} else if (release == current) {
var status = null;
$('#os-status').show();
$('#os-upgrade').hide();
$('#os-downgrade').hide();
} else if (release > current) {
var status = '#os-upgrade';
$('#os-status').hide();
$('#os-upgrade').show();
$('#os-downgrade').hide();
} else {
var status = '#os-downgrade';
$('#os-status').hide();
$('#os-upgrade').hide();
$('#os-downgrade').show();
}
if (status !== null) {
$.get('/plugins/dynamix.plugin.manager/include/ShowPlugins.php',{system:true,release:release,branch:branch},function(data) {
var link = data.split('\0');
$(status).html($(status).html().replace(link[0],link[1]));
});
}
}
function downgrade() {
$.get('/plugins/dynamix.plugin.manager/include/Downgrade.php',{version:'<?=$version?>'},function(){refresh();});
}
function loadlist(id) {
$.get('/plugins/dynamix.plugin.manager/include/ShowPlugins.php',{system:true,audit:id,check:<?=$check?>},function(data) {
var list = $('#os_list');
if (id) {
var cmd = id.split(':');
var tr = 'tr#'+cmd[0].replace(/[\. _]/g,'');
switch (cmd[1]) {
case 'return' : list.html(data); break;
case 'update':
case 'install': list.find(tr).remove(); list.append(data); break;
}
} else {
list.html(data);
}
var reboot = data.search(/REBOOT REQUIRED|DOWNGRADE/)>=0;
if (reboot) {
$('#os-status').html('Changed').show();
$('#change-branch').prop('disabled',true).append($('<option>',{text:'---',selected:true}));
$('#change-version').prop('disabled',true).append($('<option>',{text:'---',selected:true}));
$('#os-install').hide();
$('#os-upgrade').hide();
$('#os-downgrade').hide();
$('#os-release').hide();
$('i.fa-info-circle').hide();
}
<?if ($bzroot):?>
$('#previous').show();
<?endif;?>
<?if ($check):?>
$('#checkos').prop('disabled',reboot);
<?endif;?>
});
}
$(function() {
loadlist();
<?if ($check):?>
$('.tabs').append("<span class='status hshift'><input type='button' id='checkos' value='Check for Updates' onclick='openBox(\"/plugins/dynamix.plugin.manager/scripts/plugin&arg1=checkos\",\"System Update Check\",490,430,true,\"loadlist\",\":return\")' disabled></span>");
<?endif;?>
});
</script>
<table class='tablesorter plugins shift' id='os_table'>
<thead><tr><th></th><th>Component</th><th>Author</th><th>Installed</th><th>Available</th><th>Status</th><th>Branch</th></tr></thead>
<tbody id="os_list"><tr><td colspan="7"><div class="spinner"></div></td><tr></tbody>
</table>