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

99 lines
3.4 KiB
Plaintext

Menu="About"
Title="Update OS"
Icon="icon-update"
Tag="upload"
---
<?PHP
/* Copyright 2005-2020, Lime Technology
* Copyright 2012-2020, 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.
*/
?>
<?
$empty = "<tr><td colspan='6'><div class='spinner'></div></td></tr>";
$version = $branch = $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;
}
}
$branch = strpos($version,'rc')===false ? 'Stable' : 'Next';
}
?>
<style>
input[value='Install'],input[value='Update'],input[value='Restore']{margin:0}
<?if (strstr('white,black',$display['theme'])):?>
span.vhshift{margin-top:11px!important}
<?endif;?>
</style>
<script>
var original = null;
function update_table(branch) {
$('#os_list').html("<?=$empty?>");
if (original) {
if (branch != original) branch = '';
} else {
if (branch) original = branch;
}
$.get('/plugins/dynamix.plugin.manager/include/ShowPlugins.php',{system:'true',branch:branch},function(data) {
if (data) $('#os_list').html(data);
$('#os_table').trigger('update',true);
});
}
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);
}
<?if (preg_match("/^\*\*(REBOOT REQUIRED|DOWNGRADE)/",@file_get_contents("$docroot/plugins/unRAIDServer/README.md",false,null,0,20))):?>
$('#change_branch').prop('disabled',true);
<?endif;?>
<?if ($bzroot):?>
$('#previous').show();
<?endif;?>
<?if ($check):?>
$('#checkos').prop('disabled',false);
<?endif;?>
});
}
$(function() {
loadlist();
<?if ($check):?>
$('.tabs').append("<span class='status vhshift'><input type='button' id='checkos' value='Check for Updates' onclick='openBox(\"/plugins/dynamix.plugin.manager/scripts/plugin&arg1=checkos\",\"System Update Check\",600,600,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>Version</th><th>Status</th><th>Branch</th></tr></thead>
<tbody id="os_list"><?=$empty?></tbody>
<?if ($bzroot):?>
<tbody id="previous" style="display:none"><tr><td><img src="/plugins/unRAIDServer/images/unRAIDServer.png" class="list"></td><td><b>Unraid OS (previous)</b></td><td>LimeTech</td><td><?=$version?></td><td><input type="button" value="Restore" onclick="downgrade()"></td><td><?=$branch?></td></tbody>
<?endif;?>
</table>