diff --git a/plugins/dynamix/FlashInfo.page b/plugins/dynamix/FlashInfo.page
index 49fa0dea7..38fee215f 100644
--- a/plugins/dynamix/FlashInfo.page
+++ b/plugins/dynamix/FlashInfo.page
@@ -13,6 +13,34 @@ Title="Flash Device Settings"
* all copies or substantial portions of the Software.
*/
?>
+
+
+
+
Flash Vendor:
: =$var['flashVendor'];?>
@@ -35,4 +63,6 @@ Flash GUID:
-:
+:
+
+
Please wait... creating USB backup zip file (this may take several minutes)
diff --git a/plugins/dynamix/include/Download.php b/plugins/dynamix/include/Download.php
index 77a3dfe18..b110cce7f 100644
--- a/plugins/dynamix/include/Download.php
+++ b/plugins/dynamix/include/Download.php
@@ -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,13 @@ case 'diag':
exec("$docroot/webGui/scripts/diagnostics $anon ".escapeshellarg("$docroot/$file"));
echo "/$file";
break;
-}
+case 'unlink':
+ $disk = exec("ls -l '$docroot/$file'");
+ $disk = substr($disk,strpos($disk,'>')+2);
+ exec("rm -f '$docroot/$file' '$disk'");
+ break;
+case 'backup':
+ echo exec("$docroot/webGui/scripts/usb_backup");
+ break;
+}
?>
diff --git a/plugins/dynamix/scripts/usb_backup b/plugins/dynamix/scripts/usb_backup
new file mode 100644
index 000000000..f31c98913
--- /dev/null
+++ b/plugins/dynamix/scripts/usb_backup
@@ -0,0 +1,43 @@
+#!/usr/bin/php -q
+
+
+$docroot = $docroot ?: $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
+$var = file_exists('/var/local/emhttp/var.ini') ? parse_ini_file('/var/local/emhttp/var.ini') : [];
+$out = ['previous','syslinux'];
+
+$server = isset($var['NAME']) ? str_replace(' ','_',strtolower($var['NAME'])) : 'tower';
+$mydate = date('Ymd-Hi');
+$backup = "$server-usb-backup-$mydate.zip";
+
+list($used,$free) = explode(',',exec("df /boot|awk 'END{print $3,$4}'"));
+$usb = $free > $used;
+foreach (glob('/mnt/user/*',GLOB_ONLYDIR) as $share) {
+ $free = exec("df $share|awk 'END{print $4}'");
+ if ($free > $used) {$zip = $share; break;}
+}
+$zip = $zip ? "$zip/$backup" : ($usb ? "/boot/$backup" : "");
+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;
+}
+?>
\ No newline at end of file