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 done
pull/7091/head
iglocska 2021-02-25 11:37:37 +01:00
parent add5882d8b
commit 64879b836e
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
3 changed files with 26 additions and 2 deletions

View File

@ -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');
}
}

View File

@ -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']));
}
}
}

View File

@ -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, '.')) {