Skip to content

Commit

Permalink
Mantis 0001684: Fix bug when running backup jobs via WebUI. Jobs to b…
Browse files Browse the repository at this point in the history
…e executed via WebUI must be enabled, otherwise the required scripts do not exist.
  • Loading branch information
votdev committed Mar 2, 2017
1 parent 1e1c9ab commit 17088e5
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
4 changes: 1 addition & 3 deletions deb/openmediavault-usbbackup/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
openmediavault-usbbackup (3.2.15) stable; urgency=low

* Various improvements.
* Mantis 0001684: Fix bug when running backup jobs via WebUI. Jobs to be
executed via WebUI must be enabled, otherwise the required scripts do
not exist.
* Mantis 0001684: Fix bug when running backup jobs via WebUI.

-- Volker Theile <volker.theile@openmediavault.org> Tue, 28 Feb 2017 19:45:39 +0100

Expand Down
2 changes: 1 addition & 1 deletion deb/openmediavault-usbbackup/debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Homepage: http://www.openmediavault.org

Package: openmediavault-usbbackup
Architecture: all
Depends: rsync, openmediavault (>= 3.0.60)
Depends: rsync, openmediavault (>= 3.0.65)
Priority: optional
Description: OpenMediaVault USB/eSATA backup plugin
Automatically synchronise a shared folder to an USB/eSATA device and vice
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,24 @@ class OMVRpcServiceUsbBackup extends \OMV\Rpc\ServiceAbstract {
// Get the configuration object.
$db = \OMV\Config\Database::getInstance();
$object = $db->get("conf.service.usbbackup.job", $params['uuid']);
// Get the file system and mount it if necessary.
$deviceFile = $object->get("devicefile");
\OMV\System\Filesystem\Filesystem::assertGetImpl($deviceFile);
$fs = \OMV\System\Filesystem\Filesystem::getImpl($deviceFile);
if (FALSE === $fs->isMounted()) {
// Make sure the mount point exists.
// Note, the name of the mount point is generated from the MD5
// sum of the device file.
$dir = \OMV\System\MountPoint::buildPath(md5($deviceFile));
$mp = new \OMV\System\MountPoint($dir);
$mp->create();
// Mount the file system at the specified directory.
$fs->mount([], $dir);
}
// Create a background process.
return $this->execBgProc(function($bgStatusFilename, $bgOutputFilename)
use ($object) {
// Execute the backup script.
use ($object, $fs, $mp) {
// Execute the rsync script.
$cmdArgs = [];
$cmdArgs[] = "--shell";
$cmdArgs[] = "--non-interactive";
Expand All @@ -240,15 +254,17 @@ class OMVRpcServiceUsbBackup extends \OMV\Rpc\ServiceAbstract {
\OMV\Environment::get("OMV_USBBACKUP_SCRIPTS_DIR",
"/var/lib/openmediavault/usbbackup.d"),
sprintf("%s%s", \OMV\Environment::get(
"OMV_USBBACKUP_JOBS_SCRIPT_PREFIX",
"openmediavault-usbbackup-"),
md5($object->get("devicefile"))));
"OMV_USBBACKUP_RSYNC_SCRIPT_PREFIX", "rsync-"),
$object->getIdentifier()));
$cmd = new \OMV\System\Process("sudo", $cmdArgs);
$cmd->setEnv("SHELL", "/bin/sh");
$cmd->setRedirect2to1();
$cmdLine = $cmd->getCommandLine();
// Execute the command.
$exitStatus = $this->exec($cmdLine, $output, $bgOutputFilename);
// Cleanup.
$fs->umount();
$mp->unlink();
// Check the exit status.
if (0 !== $exitStatus)
throw new \OMV\ExecException($cmdLine, $output, $exitStatus);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,14 +350,7 @@ Ext.define("OMV.module.admin.service.usbbackup.Jobs", {
disabled: true,
selectionConfig: {
minSelections: 1,
maxSelections: 1,
enabledFn: function(c, records) {
// Disable the 'Run' button if the selected job
// is not enabled. The job must be enabled to ensure
// that the required scripts exist.
var record = records[0];
return (record.get("enable") === true);
}
maxSelections: 1
}
}]);
return items;
Expand Down

0 comments on commit 17088e5

Please sign in to comment.