Skip to content

Commit fd9245b

Browse files
committed
Make sure we chown the files at the end of the process
1 parent db5c9b3 commit fd9245b

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

app/Console/Commands/UpgradeCommand.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class UpgradeCommand extends Command
1414

1515
/** @var string */
1616
protected $signature = 'p:upgrade
17+
{--user= : The user that PHP runs under. All files will be owned by this user.}
1718
{--url= : The specific archive to download.}
1819
{--release= : A specific Pterodactyl version to download from GitHub. Leave blank to use latest.}
1920
{--skip-download : If set no archive will be downloaded.}';
@@ -41,18 +42,35 @@ public function handle()
4142
$this->line($this->getUrl());
4243
}
4344

45+
$user = 'www-data';
4446
if ($this->input->isInteractive()) {
4547
if (!$skipDownload) {
4648
$skipDownload = !$this->confirm('Would you like to download and unpack the archive files for the latest version?', true);
4749
}
4850

51+
if (is_null($this->option('user'))) {
52+
$details = posix_getpwuid(fileowner('public'));
53+
$user = $details['name'] ?? 'www-data';
54+
55+
if (!$this->confirm("Your webserver user has been detected as [{$user}]: is this correct?", true)) {
56+
$user = $this->anticipate(
57+
'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".',
58+
[
59+
'www-data',
60+
'apache',
61+
'nginx',
62+
]
63+
);
64+
}
65+
}
66+
4967
if (!$this->confirm('Are you sure you want to run the upgrade process for your Panel?')) {
5068
return;
5169
}
5270
}
5371

5472
ini_set('output_buffering', 0);
55-
$bar = $this->output->createProgressBar($skipDownload ? 8 : 9);
73+
$bar = $this->output->createProgressBar($skipDownload ? 9 : 10);
5674
$bar->start();
5775

5876
if (!$skipDownload) {
@@ -114,6 +132,14 @@ public function handle()
114132
$this->call('migrate', ['--seed' => '', '--force' => '']);
115133
});
116134

135+
$this->withProgress($bar, function () use ($user) {
136+
$this->line("\$upgrader> chown -R {$user}:{$user} *");
137+
$process = Process::fromShellCommandline("chown -R {$user}:{$user} *");
138+
$process->run(function ($type, $buffer) {
139+
$this->{$type === Process::ERR ? 'error' : 'line'}($buffer);
140+
});
141+
});
142+
117143
$this->withProgress($bar, function () {
118144
$this->line('$upgrader> php artisan queue:restart');
119145
$this->call('queue:restart');

0 commit comments

Comments
 (0)