public function autoUpdate()
{
$debugArgs = ['supplier' => $this->supplier->getName(), 'name' => $this->name];
$this->log('Begin Cabin auto-update routine', LogLevel::DEBUG, $debugArgs);
if ($this->isAirshipSpecialCabin()) {
// This only gets touched by core updates.
return;
}
try {
/**
* @var UpdateInfo[]
*/
$updates = $this->updateCheck($this->supplier->getName(), $this->name, $this->manifest['version']);
foreach ($updates as $updateInfo) {
if (!$this->checkVersionSettings($updateInfo, $this->manifest['version'])) {
$this->log('Skipping Cabin update', LogLevel::INFO, ['info' => $updateInfo->getResponse(), 'new_version' => $updateInfo->getVersion(), 'current_version' => $this->manifest['version']]);
continue;
}
/**
* @var UpdateFile
*/
$updateFile = $this->downloadUpdateFile($updateInfo);
$this->log('Downloaded Cabin update file', LogLevel::DEBUG, $debugArgs);
if ($this->bypassSecurityAndJustInstall) {
$this->log('Cabin update verification bypassed', LogLevel::ALERT, $debugArgs);
$this->install($updateInfo, $updateFile);
return;
}
/**
* Don't proceed unless we've verified the signatures
*/
if ($this->verifyUpdateSignature($updateInfo, $updateFile)) {
if ($this->checkKeyggdrasil($updateInfo, $updateFile)) {
$this->install($updateInfo, $updateFile);
} else {
$this->log('Keyggdrasil check failed for this Cabin', LogLevel::ALERT, $debugArgs);
self::$continuumLogger->store(LogLevel::ALERT, 'Cabin update failed -- checksum not registered in Keyggdrasil', $this->getLogContext($updateInfo, $updateFile));
}
} else {
$this->log('Signature check failed for this Cabin', LogLevel::ALERT, $debugArgs);
self::$continuumLogger->store(LogLevel::ALERT, 'Cabin update failed -- invalid signature', $this->getLogContext($updateInfo, $updateFile));
}
}
} catch (NoAPIResponse $ex) {
// We should log this.
$this->log('Automatic update failure: NO API Response.', LogLevel::ERROR, \Airship\throwableToArray($ex));
self::$continuumLogger->store(LogLevel::ALERT, 'Cabin update failed -- no API Response', ['action' => 'UPDATE', 'name' => $this->name, 'supplier' => $this->supplier->getName(), 'type' => $this->type]);
}
}