1
1
mirror of https://github.com/pterodactyl/panel.git synced 2024-11-26 11:02:31 +01:00

Make sure we chown the files at the end of the process

This commit is contained in:
Dane Everitt 2021-01-23 16:27:23 -08:00
parent db5c9b3675
commit fd9245b2c5
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53

View File

@ -14,6 +14,7 @@ class UpgradeCommand extends Command
/** @var string */ /** @var string */
protected $signature = 'p:upgrade protected $signature = 'p:upgrade
{--user= : The user that PHP runs under. All files will be owned by this user.}
{--url= : The specific archive to download.} {--url= : The specific archive to download.}
{--release= : A specific Pterodactyl version to download from GitHub. Leave blank to use latest.} {--release= : A specific Pterodactyl version to download from GitHub. Leave blank to use latest.}
{--skip-download : If set no archive will be downloaded.}'; {--skip-download : If set no archive will be downloaded.}';
@ -41,18 +42,35 @@ class UpgradeCommand extends Command
$this->line($this->getUrl()); $this->line($this->getUrl());
} }
$user = 'www-data';
if ($this->input->isInteractive()) { if ($this->input->isInteractive()) {
if (!$skipDownload) { if (!$skipDownload) {
$skipDownload = !$this->confirm('Would you like to download and unpack the archive files for the latest version?', true); $skipDownload = !$this->confirm('Would you like to download and unpack the archive files for the latest version?', true);
} }
if (is_null($this->option('user'))) {
$details = posix_getpwuid(fileowner('public'));
$user = $details['name'] ?? 'www-data';
if (!$this->confirm("Your webserver user has been detected as [{$user}]: 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", "nginx", or "apache".',
[
'www-data',
'apache',
'nginx',
]
);
}
}
if (!$this->confirm('Are you sure you want to run the upgrade process for your Panel?')) { if (!$this->confirm('Are you sure you want to run the upgrade process for your Panel?')) {
return; return;
} }
} }
ini_set('output_buffering', 0); ini_set('output_buffering', 0);
$bar = $this->output->createProgressBar($skipDownload ? 8 : 9); $bar = $this->output->createProgressBar($skipDownload ? 9 : 10);
$bar->start(); $bar->start();
if (!$skipDownload) { if (!$skipDownload) {
@ -114,6 +132,14 @@ class UpgradeCommand extends Command
$this->call('migrate', ['--seed' => '', '--force' => '']); $this->call('migrate', ['--seed' => '', '--force' => '']);
}); });
$this->withProgress($bar, function () use ($user) {
$this->line("\$upgrader> chown -R {$user}:{$user} *");
$process = Process::fromShellCommandline("chown -R {$user}:{$user} *");
$process->run(function ($type, $buffer) {
$this->{$type === Process::ERR ? 'error' : 'line'}($buffer);
});
});
$this->withProgress($bar, function () { $this->withProgress($bar, function () {
$this->line('$upgrader> php artisan queue:restart'); $this->line('$upgrader> php artisan queue:restart');
$this->call('queue:restart'); $this->call('queue:restart');