mirror of https://github.com/MISP/MISP
new: [CLI] check if updates are done yet or not
usage: - /var/www/MISP/app/Console/cake Admin updatesDone [blocking] - returns True or False based on whether it is done - When the blocking parameter is set, it will not return until all updates are donepull/7091/head
parent
add5882d8b
commit
64879b836e
|
@ -671,4 +671,11 @@ class AdminShell extends AppShell
|
|||
$this->Job->saveField('message', 'Job done.');
|
||||
$this->Job->saveField('status', 4);
|
||||
}
|
||||
|
||||
public function updatesDone()
|
||||
{
|
||||
$blocking = !empty($this->args[0]);
|
||||
$done = $this->AdminSetting->updatesDone($blocking);
|
||||
$this->out($done ? 'True' : 'False');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,4 +43,21 @@ class AdminSetting extends AppModel
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function updatesDone($blocking = false)
|
||||
{
|
||||
if ($blocking) {
|
||||
$continue = false;
|
||||
while ($continue == false) {
|
||||
$db_version = $this->find('first', array('conditions' => array('setting' => 'db_version')));
|
||||
$continue = empty($this->findUpgrades($db_version['AdminSetting']['value']));
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
$db_version = $this->find('first', array('conditions' => array('setting' => 'db_version')));
|
||||
return empty($this->findUpgrades($db_version['AdminSetting']['value']));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2003,7 +2003,7 @@ class AppModel extends Model
|
|||
}
|
||||
}
|
||||
$db_version = $db_version[0];
|
||||
$updates = $this->__findUpgrades($db_version['AdminSetting']['value']);
|
||||
$updates = $this->findUpgrades($db_version['AdminSetting']['value']);
|
||||
if ($processId) {
|
||||
$job = $this->Job->find('first', array(
|
||||
'conditions' => array('Job.id' => $processId)
|
||||
|
@ -2348,7 +2348,7 @@ class AppModel extends Model
|
|||
}
|
||||
}
|
||||
|
||||
private function __findUpgrades($db_version)
|
||||
public function findUpgrades($db_version)
|
||||
{
|
||||
$updates = array();
|
||||
if (strpos($db_version, '.')) {
|
||||
|
|
Loading…
Reference in New Issue