option('skip-download'); if (!$skipDownload) { $this->output->warning('This command does not verify the integrity of downloaded assets. Please ensure that you trust the download source before continuing. If you do not wish to download an archive, please indicate that using the --skip-download flag, or answering "no" to the question below.'); $this->output->comment('Download Source (set with --url=):'); $this->line($this->getUrl()); } if (version_compare(PHP_VERSION, '7.4.0') < 0) { $this->error('Cannot execute self-upgrade process. The minimum required PHP version required is 7.4.0, you have [' . PHP_VERSION . '].'); } $user = 'www-data'; $group = 'www-data'; if ($this->input->isInteractive()) { if (!$skipDownload) { $skipDownload = !$this->confirm('Would you like to download and unpack the archive files for the latest version?', true); } if (is_null($this->option('user'))) { $user_details = posix_getpwuid(fileowner('public')); $user = $user_details['name'] ?? 'www-data'; $group_details = posix_getgrgid(filegroup('public')); $group = $group_details['name'] ?? 'www-data'; if (!$this->confirm("Your webserver user (and group) has been detected as [{$user}:{$group}]: is this correct?", true)) { $user = $this->anticipate( 'Please enter the name of the user running your webserver process. This varies from system to system, but is generally "www-data:www-data", "nginx:nginx", or "apache:apache".', [ 'www-data:www-data', 'nginx:nginx', 'apache:apache', ] ); } } if (!$this->confirm('Are you sure you want to run the upgrade process for your Panel?')) { return; } } ini_set('output_buffering', 0); $bar = $this->output->createProgressBar($skipDownload ? 9 : 10); $bar->start(); if (!$skipDownload) { $this->withProgress($bar, function () { $this->line("\$upgrader> curl -L \"{$this->getUrl()}\" | tar -xzv"); $process = Process::fromShellCommandline("curl -L \"{$this->getUrl()}\" | tar -xzv"); $process->run(function ($type, $buffer) { $this->{$type === Process::ERR ? 'error' : 'line'}($buffer); }); }); } $this->withProgress($bar, function () { $this->line('$upgrader> php artisan down'); $this->call('down'); }); $this->withProgress($bar, function () { $this->line('$upgrader> chmod -R 755 storage bootstrap/cache'); $process = new Process(['chmod', '-R', '755', 'storage', 'bootstrap/cache']); $process->run(function ($type, $buffer) { $this->{$type === Process::ERR ? 'error' : 'line'}($buffer); }); }); $this->withProgress($bar, function () { $command = ['composer', 'install', '--no-ansi']; if (config('app.env') === 'production' && !config('app.debug')) { $command[] = '--optimize-autoloader'; $command[] = '--no-dev'; } $this->line('$upgrader> ' . implode(' ', $command)); $process = new Process($command); $process->setTimeout(10 * 60); $process->run(function ($type, $buffer) { $this->line($buffer); }); }); /** @var \Illuminate\Foundation\Application $app */ $app = require __DIR__ . '/../../../bootstrap/app.php'; /** @var \Pterodactyl\Console\Kernel $kernel */ $kernel = $app->make(Kernel::class); $kernel->bootstrap(); $this->setLaravel($app); $this->withProgress($bar, function () { $this->line('$upgrader> php artisan view:clear'); $this->call('view:clear'); }); $this->withProgress($bar, function () { $this->line('$upgrader> php artisan config:clear'); $this->call('config:clear'); }); $this->withProgress($bar, function () { $this->line('$upgrader> php artisan migrate --seed --force'); $this->call('migrate', ['--seed' => '', '--force' => '']); }); $this->withProgress($bar, function () use ($user, $group) { $this->line("\$upgrader> chown -R {$user}:{$group} *"); $process = Process::fromShellCommandline("chown -R {$user}:{$group} *", $this->getLaravel()->basePath()); $process->setTimeout(10 * 60); $process->run(function ($type, $buffer) { $this->{$type === Process::ERR ? 'error' : 'line'}($buffer); }); }); $this->withProgress($bar, function () { $this->line('$upgrader> php artisan queue:restart'); $this->call('queue:restart'); }); $this->withProgress($bar, function () { $this->line('$upgrader> php artisan up'); $this->call('up'); }); $this->newLine(); $this->info('Finished running upgrade.'); } protected function withProgress(ProgressBar $bar, Closure $callback) { $bar->clear(); $callback(); $bar->advance(); $bar->display(); } protected function getUrl(): string { if ($this->option('url')) { return $this->option('url'); } return sprintf(self::DEFAULT_URL, $this->option('release') ? 'download/v' . $this->option('release') : 'latest/download'); } }