Skip to content

Commit 3ca835e

Browse files
authored
Add group input to upgrade command
1 parent b0995f6 commit 3ca835e

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

app/Console/Commands/UpgradeCommand.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +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.}
17+
{--user= : The user (and group) that PHP runs under. All files will be owned by this user (and group).}
1818
{--url= : The specific archive to download.}
1919
{--release= : A specific Pterodactyl version to download from GitHub. Leave blank to use latest.}
2020
{--skip-download : If set no archive will be downloaded.}';
@@ -46,22 +46,26 @@ public function handle()
4646
}
4747

4848
$user = 'www-data';
49+
$group = 'www-data';
4950
if ($this->input->isInteractive()) {
5051
if (!$skipDownload) {
5152
$skipDownload = !$this->confirm('Would you like to download and unpack the archive files for the latest version?', true);
5253
}
5354

5455
if (is_null($this->option('user'))) {
55-
$details = posix_getpwuid(fileowner('public'));
56+
$user_details = posix_getpwuid(fileowner('public'));
5657
$user = $details['name'] ?? 'www-data';
58+
59+
$group_details = posix_getgrgid(filegroup('public'));
60+
$group = $details['name'] ?? 'www-data';
5761

58-
if (!$this->confirm("Your webserver user has been detected as [{$user}]: is this correct?", true)) {
62+
if (!$this->confirm("Your webserver user (and group) has been detected as [{$user}:{$group}]: is this correct?", true)) {
5963
$user = $this->anticipate(
60-
'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".',
64+
'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".',
6165
[
62-
'www-data',
63-
'apache',
64-
'nginx',
66+
'www-data:www-data',
67+
'nginx:nginx',
68+
'apache:apache',
6569
]
6670
);
6771
}
@@ -136,9 +140,9 @@ public function handle()
136140
$this->call('migrate', ['--seed' => '', '--force' => '']);
137141
});
138142

139-
$this->withProgress($bar, function () use ($user) {
140-
$this->line("\$upgrader> chown -R {$user}:{$user} *");
141-
$process = Process::fromShellCommandline("chown -R {$user}:{$user} *", $this->getLaravel()->basePath());
143+
$this->withProgress($bar, function () use ($user, $group) {
144+
$this->line("\$upgrader> chown -R {$user}:{$group} *");
145+
$process = Process::fromShellCommandline("chown -R {$user}:{$group} *", $this->getLaravel()->basePath());
142146
$process->setTimeout(10 * 60);
143147
$process->run(function ($type, $buffer) {
144148
$this->{$type === Process::ERR ? 'error' : 'line'}($buffer);

0 commit comments

Comments
 (0)