function listjobtotalsAction() { $this->view->title = $this->view->translate->_("List of Job Totals"); // do Bacula ACLs $command = 'list'; if (!$this->bacula_acl->doOneBaculaAcl($command, 'command')) { $msg = sprintf($this->view->translate->_('You try to run Bacula Console with command "%s".'), $command); $this->_forward('bacula-access-denied', 'error', null, array('msg' => $msg)); // action, controller return; } $director = new Director(); if (!$director->isFoundBconsole()) { $this->view->result_error = 'NOFOUND_BCONSOLE'; $this->render(); return; } $astatusdir = $director->execDirector(" <<EOF\nlist jobtotals\n@quit\nEOF"); $this->view->command_output = $astatusdir['command_output']; // check return status of the executed command if ($astatusdir['return_var'] != 0) { $this->view->result_error = $astatusdir['result_error']; } $this->view->meta_refresh = 300; // meta http-equiv="refresh" }
function statusClientIdAction() { // http://localhost/webacula/client/status-client-id/id/1/name/local.fd $client_name = $this->_getParam('name'); $this->view->title = $this->view->translate->_("Client") . " " . $client_name; // do Bacula ACLs $command = 'status'; if (!$this->bacula_acl->doOneBaculaAcl($command, 'command')) { $msg = sprintf($this->view->translate->_('You try to run Bacula Console with command "%s".'), $command); $this->_forward('bacula-access-denied', 'error', null, array('msg' => $msg)); // action, controller return; } $director = new Director(); if (!$director->isFoundBconsole()) { $this->view->result_error = 'NOFOUND_BCONSOLE'; $this->render(); return; } $astatusdir = $director->execDirector(" <<EOF\nstatus client=\"{$client_name}\"\n.\n@quit\nEOF"); $this->view->command_output = $astatusdir['command_output']; // check return status of the executed command if ($astatusdir['return_var'] != 0) { $this->view->result_error = $astatusdir['result_error']; } $this->view->meta_refresh = 300; // meta http-equiv="refresh" }
function cmdAction() { $bcommand = addslashes(trim($this->_request->getPost('bcommand'))); $this->view->bcommand = $bcommand; if ($this->_helper->hasHelper('layout')) { $this->_helper->layout->disableLayout(); // disable layouts } list($cmd) = explode(' ', $bcommand); // do Bacula ACLs if (!$this->bacula_acl->doOneBaculaAcl($cmd, 'command')) { $this->view->msg = sprintf($this->view->translate->_('You try to run Bacula Console with command "%s".'), $cmd) . '<br><b>Bacula ACLs : ' . $this->view->translate->_('Access denied.') . '</b><br>'; $this->render(); return; } $director = new Director(); if (!$director->isFoundBconsole()) { $this->view->msg = '<b>' . $this->view->translate->_('ERROR: bconsole not found.') . '</b><br>'; $this->render(); return; } $astatusdir = $director->execDirector("<<EOF\n{$bcommand}\n@quit\nEOF"); $this->view->command_output = $astatusdir['command_output']; // check return status of the executed command $this->view->return_var = $astatusdir['return_var']; }
function autochangerContentAction() { /* Display Autochanger Content http://www.bacula.org/3.0.x-manuals/en/concepts/concepts/New_Features_in_3_0_0.html * * update slots storage="LTO1" drive=0 * status slots storage="LTO1" drive=0 */ $changer = ''; $storage_name = addslashes($this->_request->getParam('name')); // do Bacula ACLs $command = 'status'; if (!$this->bacula_acl->doOneBaculaAcl($command, 'command')) { $msg = sprintf($this->view->translate->_('You try to run Bacula Console with command "%s".'), $command); $this->_forward('bacula-access-denied', 'error', null, array('msg' => $msg)); // action, controller return; } // do bacula acl if (!$this->bacula_acl->doOneBaculaAcl($storage_name, 'storage')) { $this->view->result_error = 'BACULA_ACCESS_DENIED'; $this->view->command_output = null; echo $this->renderScript('storage/status-id.phtml'); return; } if (!empty($storage_name)) { $this->view->title = $this->view->translate->_("Storage") . " " . $storage_name . ' ' . $this->view->translate->_("autochanger content"); $director = new Director(); if (!$director->isFoundBconsole()) { $this->view->result_error = 'NOFOUND_BCONSOLE'; $this->render(); return; } /* deleted by fixed ID: 3325149 "Display Autochanger Contents" update slots storage=\"$storage_name\" drive=0 wait */ $astatusdir = $director->execDirector(" <<EOF\nstatus slots storage=\"{$storage_name}\" drive=0\nwait\n@quit\nEOF"); $this->view->command_output = $astatusdir['command_output']; // check return status of the executed command if ($astatusdir['return_var'] != 0) { $this->view->result_error = $astatusdir['result_error']; echo $this->renderScript('storage/status-id.phtml'); return; } } else { $this->view->command_output = null; } echo $this->renderScript('storage/status-id.phtml'); }
/** * Get Listing All Jobs * */ function getListJobs() { $director = new Director(); // check access to bconsole if (!$director->isFoundBconsole()) { $aresult[] = 'ERROR: bconsole not found.'; return $aresult; } $astatusdir = $director->execDirector("<<EOF\nrun\n.\n@quit\nEOF"); // check return status of the executed command if ($astatusdir['return_var'] != 0) { $aresult[] = 'ERROR'; $aresult[] = 'bconsole output:<b>'; foreach ($astatusdir['command_output'] as $line) { $aresult[] = $line; } $aresult[] = '</b>'; return $aresult; } /* Parsing Director's output. * Example : The defined Job resources are: 1: restore.files 2: job.name.test.1 3: job name test 2 Select Job resource (1-3): */ $strs = 'The defined Job resources are:'; $str_end = 'Select Job resource'; // признак конца списка $start = 0; $aresult = array(); foreach ($astatusdir['command_output'] as $line) { if (strlen($line) == 0) { continue; } if ($start == 0 && !(strpos($line, $strs) === FALSE)) { $start = 1; // parsing list($number, $name_job) = preg_split("/:+/", $line, 2); if (!empty($name_job)) { $aresult[]['jobname'] = trim($name_job); } continue; } // задания закончились if ($start == 1 && !(strpos($line, $str_end) === FALSE)) { break; } if ($start == 1) { // parsing list($number, $name_job) = preg_split("/:+/", $line, 2); if (!empty($name_job)) { $aresult[]['jobname'] = trim($name_job); } } else { continue; } } // do Bacula ACLs $res2dim = $this->bacula_acl->doBaculaAcl($aresult, 'jobname', 'job'); /* * convert two dimensional $res2dim to one dimension array $res1dim * для корректного отображения в форме нужен ординарный массив */ $res1dim = array(); foreach ($res2dim as $res2) { $res1dim[] = $res2['jobname']; } return $res1dim; }
/** * show job * http://www.bacula.org/3.0.x-manuals/en/console/console/Bacula_Console.html * show job=<xxx> */ function showJobAction() { // do Bacula ACLs $command = 'show'; if (!$this->bacula_acl->doOneBaculaAcl($command, 'command')) { $msg = sprintf($this->view->translate->_('You try to run Bacula Console with command "%s".'), $command); $this->_forward('bacula-access-denied', 'error', null, array('msg' => $msg)); // action, controller return; } $this->view->title = $this->view->translate->_("Show Job resource"); $jobname = trim($this->_request->getParam('jobname')); $this->view->jobname = $jobname; $director = new Director(); if (!$director->isFoundBconsole()) { $this->view->result_error = 'NOFOUND_BCONSOLE'; $this->render(); return; } $astatusdir = $director->execDirector(" <<EOF\nshow job=\"{$jobname}\"\nEOF"); $this->view->command_output = $astatusdir['command_output']; // check return status of the executed command if ($astatusdir['return_var'] != 0) { $this->view->result_error = $astatusdir['result_error']; } }
/** * Run Restore single File + Bacula ACLs * http://www.bacula.org/rel-manual/Restore_Command.html */ function runRestoreSingleFileAction() { // do Bacula ACLs $command = 'restore'; if (!$this->bacula_acl->doOneBaculaAcl($command, 'command')) { $msg = sprintf($this->view->translate->_('You try to run Bacula Console with command "%s".'), $command); $this->_forward('bacula-access-denied', 'error', null, array('msg' => $msg)); // action, controller return; } $this->view->title = $this->view->translate->_('Restore Single File'); // получаем значения из формы FormRestoreOptions $this->getParamFromForm(); // get File data Zend_Loader::loadClass('Job'); $job = new Job(); $file = $job->getByFileId($this->fileid); // do Bacula ACL if (!$file) { return; } // check access to bconsole Zend_Loader::loadClass('Director'); $director = new Director(); if (!$director->isFoundBconsole()) { $this->view->result_error = 'NOFOUND_BCONSOLE'; $this->renderScript('restorejob/run-restore.phtml'); return; } //******************************* запуск задания *************************************** // perform the command line (формируем командную строку) // restore jobid=9713 file=<"/tmp/webacula_restore_9713.tmp" client="local.fd" yes // restore storage=<storage-name> client=<backup-client-name> where=<path> pool=<pool-name> // fileset=<fileset-name> restoreclient=<restore-client-name> select current all done $cmd = 'restore jobid=' . $file[0]['jobid'] . ' file="' . $file[0]['path'] . $file[0]['filename'] . '"' . $this->getCmdRestore() . ' yes'; $comment = __METHOD__; $astatusdir = $director->execDirector(" <<EOF\n@#\n@# {$comment}\n@#\n{$cmd}\nquit\nEOF"); $this->view->command_output = $astatusdir['command_output']; // check return status of the executed command if ($astatusdir['return_var'] == 0) { $this->deleteTmpTables(); $this->mySessionStop(); } else { $this->view->result_error = $astatusdir['result_error']; } //echo "<pre>3 command_output:<br>" . print_r($command_output) . "<br><br>return_var = " . $return_var . "</pre>"; exit; $this->renderScript('restorejob/run-restore.phtml'); }