mirror of
https://github.com/unraid/webgui.git
synced 2026-01-20 16:40:17 -06:00
Merge pull request #143 from bergware/6.4-wip
Added "USB backup" function
This commit is contained in:
@@ -3,8 +3,8 @@ Title="Disk Shares"
|
||||
Cond="$var['fsState']=='Started' && $var['shareDisk']!='no'"
|
||||
---
|
||||
<?PHP
|
||||
/* Copyright 2005-2016, Lime Technology
|
||||
* Copyright 2012-2016, Bergware International.
|
||||
/* Copyright 2005-2017, Lime Technology
|
||||
* Copyright 2012-2017, 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,
|
||||
@@ -16,8 +16,12 @@ Cond="$var['fsState']=='Started' && $var['shareDisk']!='no'"
|
||||
?>
|
||||
<script>
|
||||
function displayDisks(all) {
|
||||
if (all == 'yes') $('#disk_list').html("<tr><td colspan='8' style='text-align:center'><i class='fa fa-spinner fa-spin icon'></i>Please wait... computing disk shares!</td></tr>");
|
||||
$.get('/webGui/include/DiskList.php',{compute:all,path:'<?=$path?>',prev:'<?=$prev?>',scale:'<?=$display['scale']?>',number:'<?=$display['number']?>'},function(data){
|
||||
if (all == 'yes') {
|
||||
$.cookie('ssz','ssz',{path:'/'});
|
||||
$('#disk_list').html("<tr><td colspan='8' style='text-align:center'><i class='fa fa-spinner fa-spin icon'></i>Please wait... computing disk shares!</td></tr>");
|
||||
}
|
||||
$.get('/webGui/include/DiskList.php',{compute:all,path:'<?=$path?>',scale:'<?=$display['scale']?>',number:'<?=$display['number']?>',fill:$.cookie('ssz')},function(data){
|
||||
$.removeCookie('ssz',{path:'/'})
|
||||
$('#disk_list').html(data);
|
||||
$('#compute-disks').prop('disabled',!data || data.indexOf('colspan=')!=-1);
|
||||
});
|
||||
|
||||
@@ -2,8 +2,8 @@ Menu="Flash"
|
||||
Title="Flash Device Settings"
|
||||
---
|
||||
<?PHP
|
||||
/* Copyright 2005-2016, Lime Technology
|
||||
* Copyright 2012-2016, Bergware International.
|
||||
/* Copyright 2005-2017, Lime Technology
|
||||
* Copyright 2012-2017, 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,
|
||||
@@ -13,6 +13,32 @@ Title="Flash Device Settings"
|
||||
* all copies or substantial portions of the Software.
|
||||
*/
|
||||
?>
|
||||
<script>
|
||||
function cleanUp(zip) {
|
||||
if (document.hasFocus()) {
|
||||
$('input[value="Creating Flash backup..."]').val('Flash backup').prop('disabled',false);
|
||||
$('#pleaseWait').hide('slow');
|
||||
$.post('/webGui/include/Download.php',{cmd:'unlink',file:zip});
|
||||
} else {
|
||||
setTimeout(function(){cleanUp(zip);},2000);
|
||||
}
|
||||
}
|
||||
function backup() {
|
||||
$('input[value="Flash backup"]').val('Creating Flash backup...').prop('disabled',true);
|
||||
$('#pleaseWait').show('slow');
|
||||
$.post('/webGui/include/Download.php',{cmd:'backup'},function(zip) {
|
||||
if (zip) {
|
||||
location = '/'+zip;
|
||||
setTimeout(function(){cleanUp(zip);},6000);
|
||||
} else {
|
||||
$('input[value="Creating Flash backup..."]').val('Flash backup');
|
||||
$('#pleaseWait').hide('slow');
|
||||
swal('Creation error','Insufficient free disk space available','error');
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
Flash Vendor:
|
||||
: <?=$var['flashVendor'];?>
|
||||
|
||||
@@ -34,5 +60,10 @@ Flash GUID:
|
||||
|
||||
<?endif;?>
|
||||
|
||||
> Use *Flash backup* to create a single zip file of the current contents of the flash device and store it locally on your computer.
|
||||
|
||||
|
||||
: <input type="button" value="Done" onclick="done()">
|
||||
: <input type="button" value="Flash backup" onclick="backup()"><input type="button" value="Done" onclick="done()">
|
||||
|
||||
<br><div id="pleaseWait" style="display:none;text-align:center"><span class="red-text strong">Please wait... creating Flash backup zip file (this may take several minutes)</span>
|
||||
<br><br><span class="small">Do not leave this page until backup operation is finished</span></div>
|
||||
|
||||
@@ -3,8 +3,8 @@ Title="User Shares"
|
||||
Cond="$var['fsState']=="Started" && $var['shareUser']=='e'"
|
||||
---
|
||||
<?PHP
|
||||
/* Copyright 2005-2016, Lime Technology
|
||||
* Copyright 2012-2016, Bergware International.
|
||||
/* Copyright 2005-2017, Lime Technology
|
||||
* Copyright 2012-2017, 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,
|
||||
@@ -16,8 +16,12 @@ Cond="$var['fsState']=="Started" && $var['shareUser']=='e'"
|
||||
?>
|
||||
<script>
|
||||
function displayShares(all) {
|
||||
if (all == 'yes') $('#share_list').html("<tr><td colspan='8' style='text-align:center'><i class='fa fa-spinner fa-spin icon'></i>Please wait... computing user shares!</td></tr>");
|
||||
$.get('/webGui/include/ShareList.php',{compute:all,path:'<?=addslashes(htmlspecialchars($path))?>',prev:'<?=addslashes(htmlspecialchars($prev))?>',scale:'<?=$display['scale']?>',number:'<?=$display['number']?>'},function(data){
|
||||
if (all == 'yes') {
|
||||
$.cookie('ssz','ssz',{path:'/'});
|
||||
$('#share_list').html("<tr><td colspan='8' style='text-align:center'><i class='fa fa-spinner fa-spin icon'></i>Please wait... computing user shares!</td></tr>");
|
||||
}
|
||||
$.get('/webGui/include/ShareList.php',{compute:all,path:'<?=addslashes(htmlspecialchars($path))?>',scale:'<?=$display['scale']?>',number:'<?=$display['number']?>',fill:$.cookie('ssz')},function(data){
|
||||
$.removeCookie('ssz',{path:'/'})
|
||||
$('#share_list').html(data);
|
||||
$('#compute-shares').prop('disabled',!data || data.indexOf('colspan=')!=-1);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?PHP
|
||||
/* Copyright 2005-2016, Lime Technology
|
||||
* Copyright 2012-2016, Bergware International.
|
||||
/* Copyright 2005-2017, Lime Technology
|
||||
* Copyright 2012-2017, 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,
|
||||
@@ -11,7 +11,7 @@
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
$docroot = $docroot ?: @$_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
$docroot = $docroot ?: $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
require_once "$docroot/webGui/include/Helpers.php";
|
||||
|
||||
$shares = parse_ini_file('state/shares.ini',true);
|
||||
@@ -22,6 +22,7 @@ $sec_nfs = parse_ini_file('state/sec_nfs.ini',true);
|
||||
$sec_afp = parse_ini_file('state/sec_afp.ini',true);
|
||||
$compute = $_GET['compute'];
|
||||
$path = $_GET['path'];
|
||||
$fill = $_GET['fill'];
|
||||
|
||||
$display = [];
|
||||
$display['scale'] = $_GET['scale'];
|
||||
@@ -53,9 +54,10 @@ $myDisks = array_filter(array_diff(array_keys($disks), explode(',',$var['shareUs
|
||||
|
||||
// Share size per disk
|
||||
$ssz2 = [];
|
||||
foreach (glob("state/*.ssz2", GLOB_NOSORT) as $entry) {
|
||||
$ssz2[basename($entry, ".ssz2")] = parse_ini_file($entry);
|
||||
}
|
||||
if ($fill)
|
||||
foreach (glob("state/*.ssz2", GLOB_NOSORT) as $entry) $ssz2[basename($entry, ".ssz2")] = parse_ini_file($entry);
|
||||
else
|
||||
exec("rm -f /var/local/emhttp/*.ssz2");
|
||||
|
||||
// Build table
|
||||
$row = 0;
|
||||
@@ -93,11 +95,11 @@ foreach ($disks as $name => $disk) {
|
||||
echo "<td></td>";
|
||||
echo "<td class='disk-$row-1'>".my_scale($sharesize*1024, $unit)." $unit</td>";
|
||||
echo "<td class='disk-$row-2'>".my_scale($disk['fsFree']*1024, $unit)." $unit</td>";
|
||||
echo "<td><a href='/update.htm?cmd=$cmd&csrf_token={$var['csrf_token']}' target='progressFrame' title='Recompute...' onclick='$(\".disk-$row-1\").html(\"Please wait...\");$(\".disk-$row-2\").html(\"\");'><i class='fa fa-refresh icon'></i></a></td>";
|
||||
echo "<td><a href='/update.htm?cmd=$cmd&csrf_token={$var['csrf_token']}' target='progressFrame' title='Recompute...' onclick='$.cookie(\"ssz\",\"ssz\",{path:\"/\"});$(\".disk-$row-1\").html(\"Please wait...\");$(\".disk-$row-2\").html(\"\");'><i class='fa fa-refresh icon'></i></a></td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
} else {
|
||||
echo "<td><a href='/update.htm?cmd=$cmd&csrf_token={$var['csrf_token']}' target='progressFrame' onclick=\"$(this).text('Please wait...')\">Compute...</a></td>";
|
||||
echo "<td><a href='/update.htm?cmd=$cmd&csrf_token={$var['csrf_token']}' target='progressFrame' onclick=\"$.cookie('ssz','ssz',{path:'/'});$(this).text('Please wait...')\">Compute...</a></td>";
|
||||
echo "<td>".my_scale($disk['fsFree']*1024, $unit)." $unit</td>";
|
||||
echo "<td><a href='$path/Browse?dir=/mnt/$name'><img src='/webGui/images/explore.png' title='Browse /mnt/$name'></a></td>";
|
||||
echo "</tr>";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?PHP
|
||||
/* Copyright 2005-2016, Lime Technology
|
||||
* Copyright 2012-2016, Bergware International.
|
||||
/* Copyright 2005-2017, Lime Technology
|
||||
* Copyright 2012-2017, 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,
|
||||
@@ -11,7 +11,7 @@
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
$docroot = $docroot ?: @$_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
$docroot = $docroot ?: $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
$file = $_POST['file'];
|
||||
switch ($_POST['cmd']) {
|
||||
case 'save':
|
||||
@@ -36,5 +36,12 @@ case 'diag':
|
||||
exec("$docroot/webGui/scripts/diagnostics $anon ".escapeshellarg("$docroot/$file"));
|
||||
echo "/$file";
|
||||
break;
|
||||
}
|
||||
case 'unlink':
|
||||
$backup = readlink("$docroot/$file");
|
||||
exec("rm -f '$docroot/$file' '$backup'");
|
||||
break;
|
||||
case 'backup':
|
||||
echo exec("$docroot/webGui/scripts/flash_backup");
|
||||
break;
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?PHP
|
||||
/* Copyright 2005-2016, Lime Technology
|
||||
* Copyright 2012-2016, Bergware International.
|
||||
/* Copyright 2005-2017, Lime Technology
|
||||
* Copyright 2012-2017, 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,
|
||||
@@ -11,7 +11,7 @@
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
$docroot = $docroot ?: @$_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
$docroot = $docroot ?: $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
require_once "$docroot/webGui/include/Helpers.php";
|
||||
|
||||
$shares = parse_ini_file('state/shares.ini',true);
|
||||
@@ -22,6 +22,7 @@ $sec_nfs = parse_ini_file('state/sec_nfs.ini',true);
|
||||
$sec_afp = parse_ini_file('state/sec_afp.ini',true);
|
||||
$compute = $_GET['compute'];
|
||||
$path = $_GET['path'];
|
||||
$fill = $_GET['fill'];
|
||||
|
||||
$display = [];
|
||||
$display['scale'] = $_GET['scale'];
|
||||
@@ -60,9 +61,10 @@ $myDisks = array_filter(array_diff(array_keys($disks), explode(',',$var['shareUs
|
||||
|
||||
// Share size per disk
|
||||
$ssz1 = [];
|
||||
foreach (glob("state/*.ssz1", GLOB_NOSORT) as $entry) {
|
||||
$ssz1[basename($entry, ".ssz1")] = parse_ini_file($entry);
|
||||
}
|
||||
if ($fill)
|
||||
foreach (glob("state/*.ssz1", GLOB_NOSORT) as $entry) $ssz1[basename($entry, ".ssz1")] = parse_ini_file($entry);
|
||||
else
|
||||
exec("rm -f /var/local/emhttp/*.ssz1");
|
||||
|
||||
// Build table
|
||||
$row = 0;
|
||||
@@ -97,11 +99,11 @@ foreach ($shares as $name => $share) {
|
||||
echo "<td></td>";
|
||||
echo "<td class='share-$row-1'>".my_scale($disksize*1024, $unit)." $unit</td>";
|
||||
echo "<td class='share-$row-2'>".my_scale($disks[$diskname]['fsFree']*1024, $unit)." $unit</td>";
|
||||
echo "<td><a href='/update.htm?cmd=$cmd&csrf_token={$var['csrf_token']}' target='progressFrame' title='Recompute...' onclick='$(\".share-$row-1\").html(\"Please wait...\");$(\".share-$row-2\").html(\"\");'><i class='fa fa-refresh icon'></i></a></td>";
|
||||
echo "<td><a href='/update.htm?cmd=$cmd&csrf_token={$var['csrf_token']}' target='progressFrame' title='Recompute...' onclick='$.cookie(\"ssz\",\"ssz\",{path:\"/\"});$(\".share-$row-1\").html(\"Please wait...\");$(\".share-$row-2\").html(\"\");'><i class='fa fa-refresh icon'></i></a></td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
} else {
|
||||
echo "<td><a href='/update.htm?cmd=$cmd&csrf_token={$var['csrf_token']}' target='progressFrame' onclick=\"$(this).text('Please wait...')\">Compute...</a></td>";
|
||||
echo "<td><a href='/update.htm?cmd=$cmd&csrf_token={$var['csrf_token']}' target='progressFrame' onclick=\"$.cookie('ssz','ssz',{path:'/'});$(this).text('Please wait...')\">Compute...</a></td>";
|
||||
echo "<td>".my_scale($share['free']*1024, $unit)." $unit</td>";
|
||||
echo "<td><a href='$path/Browse?dir=/mnt/user/".urlencode($name)."'><img src='/webGui/images/explore.png' title='Browse /mnt/user/".urlencode($name)."'></a></td>";
|
||||
echo "</tr>";
|
||||
|
||||
46
plugins/dynamix/scripts/flash_backup
Executable file
46
plugins/dynamix/scripts/flash_backup
Executable file
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/php -q
|
||||
<?PHP
|
||||
/* Copyright 2005-2017, Lime Technology
|
||||
* Copyright 2012-2017, 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.
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
$docroot = $docroot ?: $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
$var = file_exists('/var/local/emhttp/var.ini') ? parse_ini_file('/var/local/emhttp/var.ini') : [];
|
||||
$dir = ['system','appdata','isos'];
|
||||
$out = ['prev','previous','syslinux'];
|
||||
|
||||
$server = isset($var['NAME']) ? str_replace(' ','_',strtolower($var['NAME'])) : 'tower';
|
||||
$mydate = date('Ymd-Hi');
|
||||
$backup = "$server-flash-backup-$mydate.zip";
|
||||
|
||||
$used = exec("df /boot|awk 'END{print $3}'") * 1.5;
|
||||
$free = exec("df /|awk 'END{print $4}'");
|
||||
if ($free > $used) $zip = "/$backup"; else {
|
||||
foreach ($dir as $share) {
|
||||
if (!is_dir("/mnt/user/$share")) continue;
|
||||
$free = exec("df /mnt/user/$share|awk 'END{print $4}'");
|
||||
if ($free > $used) {$zip = "/mnt/user/$share/$backup"; break;}
|
||||
}
|
||||
}
|
||||
if ($zip) {
|
||||
chdir("/boot");
|
||||
foreach (glob("*",GLOB_NOSORT+GLOB_ONLYDIR) as $folder) {
|
||||
if (in_array($folder,$out)) continue;
|
||||
exec("zip -qr ".escapeshellarg($zip)." ".escapeshellarg($folder));
|
||||
}
|
||||
foreach (glob("*",GLOB_NOSORT) as $file) {
|
||||
if (is_dir($file)) continue;
|
||||
exec("zip -q ".escapeshellarg($zip)." ".escapeshellarg($file));
|
||||
}
|
||||
symlink($zip,"$docroot/$backup");
|
||||
echo $backup;
|
||||
}
|
||||
?>
|
||||
@@ -52,8 +52,8 @@ form+p{display:none}
|
||||
#nav-block{position:absolute;top:0;bottom:12px;color:#5D6833;white-space:nowrap;float:left;overflow-y:scroll;direction:rtl}
|
||||
#nav-block>div{direction:ltr}
|
||||
#nav-item{width:24px;text-align:left;padding:14px 24px 14px 16px;border-bottom:#42453E 1px solid;font-size:18px;overflow:hidden}
|
||||
#nav-item:hover{width:150px;color:#5D6833;background:#ABC056;border-bottom:none;-webkit-transition:all 0.25s ease-in-out;transition:all 0.25s ease-in-out}
|
||||
#nav-item:hover a{color:#5D6833;background:#ABC056;-webkit-transition:all 0.3s ease-in-out;transition:all 0.3s ease-in-out}
|
||||
#nav-item:hover{width:150px;color:#5D6833;background:#ABC056;border-bottom:none;-webkit-transition:all 0.2s ease-in-out;transition:all 0.2s ease-in-out}
|
||||
#nav-item:hover a{color:#5D6833;background:#ABC056}
|
||||
#nav-item img{display:none}
|
||||
#nav-item a{color:#A6A7A7;text-decoration:none}
|
||||
#nav-item a:before{font-family:docker-icon,fontawesome;font-size:26px;margin-right:25px}
|
||||
@@ -68,8 +68,8 @@ form+p{display:none}
|
||||
#nav-item a[href='/Apps']:before{content:'\f0db'}
|
||||
#nav-item a[href='/Stats']:before{content:'\f1fe'}
|
||||
#nav-item a[href='/Tools']:before{content:'\f0ad'}
|
||||
#nav-item.active,#nav-item.active a{color:#5D6833;background:#ABC056}
|
||||
#nav-item.HelpButton.active:hover{background:#ABC056}
|
||||
#nav-item.active,#nav-item.active a{color:#5D6833;background:#ABC056;font-size:18px}
|
||||
#nav-item.HelpButton.active:hover{background:#ABC056;font-size:0}
|
||||
#nav-item.HelpButton.active{background:#121510}
|
||||
#nav-item.HelpButton a:before{content:'\f059'}
|
||||
#nav-item.FeedbackButton a:before{content:'\f075'}
|
||||
|
||||
@@ -52,8 +52,8 @@ form+p{display:none}
|
||||
#nav-block{position:absolute;top:0;bottom:12px;color:#5D6833;white-space:nowrap;float:left;overflow-y:scroll;direction:rtl}
|
||||
#nav-block>div{direction:ltr}
|
||||
#nav-item{width:24px;text-align:left;padding:14px 24px 14px 16px;border-bottom:#42453E 1px solid;font-size:18px;overflow:hidden}
|
||||
#nav-item:hover{width:150px;color:#5D6833;background:#ABC056;border-bottom:none;-webkit-transition:all 0.25s ease-in-out;transition:all 0.25s ease-in-out}
|
||||
#nav-item:hover a{color:#5D6833;background:#ABC056;-webkit-transition:all 0.3s ease-in-out;transition:all 0.3s ease-in-out}
|
||||
#nav-item:hover{width:150px;color:#5D6833;background:#ABC056;border-bottom:none;-webkit-transition:all 0.2s ease-in-out;transition:all 0.2s ease-in-out}
|
||||
#nav-item:hover a{color:#5D6833;background:#ABC056}
|
||||
#nav-item img{display:none}
|
||||
#nav-item a{color:#A6A7A7;text-decoration:none}
|
||||
#nav-item a:before{font-family:docker-icon,fontawesome;font-size:26px;margin-right:25px}
|
||||
@@ -69,8 +69,8 @@ form+p{display:none}
|
||||
#nav-item a[href='/Stats']:before{content:'\f1fe'}
|
||||
#nav-item a[href='/Tools']:before{content:'\f0ad'}
|
||||
#nav-item.active,#nav-item.active a{color:#5D6833;background:#ABC056}
|
||||
#nav-item.HelpButton.active:hover{background:#ABC056}
|
||||
#nav-item.HelpButton.active{background:#121510}
|
||||
#nav-item.HelpButton.active:hover{background:#ABC056;font-size:18px}
|
||||
#nav-item.HelpButton.active{background:#121510;font-size:0}
|
||||
#nav-item.HelpButton a:before{content:'\f059'}
|
||||
#nav-item.FeedbackButton a:before{content:'\f075'}
|
||||
#nav-item.InfoButton a:before{content:'\f05a'}
|
||||
|
||||
@@ -58,10 +58,6 @@ $myPage = $site[basename($path)];
|
||||
$pageroot = $docroot.'/'.dirname($myPage['file']);
|
||||
$update = true; // set for legacy
|
||||
|
||||
// hack: maybe delete stale share size files
|
||||
if ($myPage['name'] != 'Shares')
|
||||
foreach(glob('/var/local/emhttp/*.ssz*', GLOB_NOSORT) as $sszfile) @unlink($sszfile);
|
||||
|
||||
// Giddyup
|
||||
require_once "$docroot/webGui/include/DefaultPageLayout.php";
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user