Skip to content

Commit cf1ac04

Browse files
authored
Merge pull request pterodactyl#3279 from Boy132/patch-1
Add group input to upgrade command
2 parents 4bd1fea + fd8259f commit cf1ac04

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

app/Console/Commands/UpgradeCommand.php

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class UpgradeCommand extends Command
1515
/** @var string */
1616
protected $signature = 'p:upgrade
1717
{--user= : The user that PHP runs under. All files will be owned by this user.}
18+
{--group= : The group that PHP runs under. All files will be owned by this group.}
1819
{--url= : The specific archive to download.}
1920
{--release= : A specific Pterodactyl version to download from GitHub. Leave blank to use latest.}
2021
{--skip-download : If set no archive will be downloaded.}';
@@ -46,22 +47,39 @@ public function handle()
4647
}
4748

4849
$user = 'www-data';
50+
$group = 'www-data';
4951
if ($this->input->isInteractive()) {
5052
if (!$skipDownload) {
5153
$skipDownload = !$this->confirm('Would you like to download and unpack the archive files for the latest version?', true);
5254
}
5355

5456
if (is_null($this->option('user'))) {
55-
$details = posix_getpwuid(fileowner('public'));
56-
$user = $details['name'] ?? 'www-data';
57+
$userDetails = posix_getpwuid(fileowner('public'));
58+
$user = $userDetails['name'] ?? 'www-data';
5759

5860
if (!$this->confirm("Your webserver user has been detected as [{$user}]: is this correct?", true)) {
5961
$user = $this->anticipate(
6062
'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".',
6163
[
6264
'www-data',
65+
'nginx',
6366
'apache',
67+
]
68+
);
69+
}
70+
}
71+
72+
if (is_null($this->option('group'))) {
73+
$groupDetails = posix_getgrgid(filegroup('public'));
74+
$group = $groupDetails['name'] ?? 'www-data';
75+
76+
if (!$this->confirm("Your webserver group has been detected as [{$group}]: is this correct?", true)) {
77+
$group = $this->anticipate(
78+
'Please enter the name of the group running your webserver process. Normally this is the same as your user.',
79+
[
80+
'www-data',
6481
'nginx',
82+
'apache',
6583
]
6684
);
6785
}
@@ -136,9 +154,9 @@ public function handle()
136154
$this->call('migrate', ['--seed' => '', '--force' => '']);
137155
});
138156

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());
157+
$this->withProgress($bar, function () use ($user, $group) {
158+
$this->line("\$upgrader> chown -R {$user}:{$group} *");
159+
$process = Process::fromShellCommandline("chown -R {$user}:{$group} *", $this->getLaravel()->basePath());
142160
$process->setTimeout(10 * 60);
143161
$process->run(function ($type, $buffer) {
144162
$this->{$type === Process::ERR ? 'error' : 'line'}($buffer);

0 commit comments

Comments
 (0)