Airship\Engine\Continuum\Updaters\Airship::autoUpdate PHP Method

autoUpdate() public method

1. Check if a new update is available. 2. Download the upload file, store in a temporary file. 3. Verify the signature (via Halite). 4. Verify the update is recorded in Keyggdrasil. 5. If all is well, run the update script.
public autoUpdate ( )
    public function autoUpdate()
    {
        $state = State::instance();
        try {
            /**
             * @var UpdateInfo[]
             */
            $updateInfoArray = $this->updateCheck($state->universal['airship']['trusted-supplier'], $this->name, \AIRSHIP_VERSION, 'airship_version');
            /**
             * Let's iterate through every possible available update,
             * until we find the desired version.
             */
            foreach ($updateInfoArray as $updateInfo) {
                if (!$this->checkVersionSettings($updateInfo, \AIRSHIP_VERSION)) {
                    // This is not the update we are looking for.
                    $this->log('Skipping update', LogLevel::DEBUG, ['info' => $updateInfo->getResponse(), 'new_version' => $updateInfo->getVersion(), 'current_version' => \AIRSHIP_VERSION]);
                    continue;
                }
                /**
                 * @var UpdateFile
                 */
                $updateFile = $this->downloadUpdateFile($updateInfo, 'airship_download');
                if ($this->bypassSecurityAndJustInstall) {
                    // I'm sorry, Dave. I'm afraid I can't do that.
                    $this->log('Core update verification cannot be bypassed', LogLevel::ERROR);
                    self::$continuumLogger->store(LogLevel::ALERT, 'CMS Airship core update - security bypass ignored.', $this->getLogContext($updateInfo, $updateFile));
                }
                /**
                 * 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 Airship core update', LogLevel::ALERT);
                        self::$continuumLogger->store(LogLevel::ALERT, 'CMS Airship core update failed -- checksum not registered in Keyggdrasil', $this->getLogContext($updateInfo, $updateFile));
                    }
                } else {
                    $this->log('Invalid signature for this Airship core update', LogLevel::ALERT);
                    self::$continuumLogger->store(LogLevel::ALERT, 'CMS Airship core 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, 'CMS Airship core update failed -- no API Response', ['action' => 'UPDATE', 'name' => $this->name, 'supplier' => $this->supplier->getName(), 'type' => $this->type]);
        }
    }