Allow specification of a version
This commit is contained in:
parent
fb98b1892d
commit
db5c9b3675
1 changed files with 17 additions and 6 deletions
|
@ -10,10 +10,13 @@ use Symfony\Component\Console\Helper\ProgressBar;
|
||||||
|
|
||||||
class UpgradeCommand extends Command
|
class UpgradeCommand extends Command
|
||||||
{
|
{
|
||||||
protected const DEFAULT_URL = 'https://github.com/pterodactyl/panel/releases/latest/download/panel.tar.gz';
|
protected const DEFAULT_URL = 'https://github.com/pterodactyl/panel/releases/%s/panel.tar.gz';
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
protected $signature = 'p:upgrade {--url=} {--skip-download}';
|
protected $signature = 'p:upgrade
|
||||||
|
{--url= : The specific archive to download.}
|
||||||
|
{--release= : A specific Pterodactyl version to download from GitHub. Leave blank to use latest.}
|
||||||
|
{--skip-download : If set no archive will be downloaded.}';
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
protected $description = 'Downloads a new archive for Pterodactyl from GitHub and then executes the normal upgrade commands.';
|
protected $description = 'Downloads a new archive for Pterodactyl from GitHub and then executes the normal upgrade commands.';
|
||||||
|
@ -35,7 +38,7 @@ class UpgradeCommand extends Command
|
||||||
if (!$skipDownload) {
|
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->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->output->comment('Download Source (set with --url=):');
|
||||||
$this->line($this->option('url') ?? self::DEFAULT_URL);
|
$this->line($this->getUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->input->isInteractive()) {
|
if ($this->input->isInteractive()) {
|
||||||
|
@ -54,9 +57,8 @@ class UpgradeCommand extends Command
|
||||||
|
|
||||||
if (!$skipDownload) {
|
if (!$skipDownload) {
|
||||||
$this->withProgress($bar, function () {
|
$this->withProgress($bar, function () {
|
||||||
$url = $this->option('url') ?? self::DEFAULT_URL;
|
$this->line("\$upgrader> curl -L \"{$this->getUrl()}\" | tar -xzv");
|
||||||
$this->line("\$upgrader> curl -L \"$url\" | tar -xzv");
|
$process = Process::fromShellCommandline("curl -L \"{$this->getUrl()}\" | tar -xzvf");
|
||||||
$process = Process::fromShellCommandline("curl -L \"$url\" | tar -xzvf");
|
|
||||||
$process->run(function ($type, $buffer) {
|
$process->run(function ($type, $buffer) {
|
||||||
$this->{$type === Process::ERR ? 'error' : 'line'}($buffer);
|
$this->{$type === Process::ERR ? 'error' : 'line'}($buffer);
|
||||||
});
|
});
|
||||||
|
@ -133,4 +135,13 @@ class UpgradeCommand extends Command
|
||||||
$bar->advance();
|
$bar->advance();
|
||||||
$bar->display();
|
$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');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue