Skip to content

Commit c0d7e02

Browse files
committed
Add a better panel info output command
1 parent f86c193 commit c0d7e02

File tree

4 files changed

+125
-158
lines changed

4 files changed

+125
-158
lines changed
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
<?php
2+
/*
3+
* Pterodactyl - Panel
4+
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
25+
namespace Pterodactyl\Console\Commands;
26+
27+
use Illuminate\Console\Command;
28+
use Pterodactyl\Services\Helpers\SoftwareVersionService;
29+
use Illuminate\Contracts\Config\Repository as ConfigRepository;
30+
31+
class InfoCommand extends Command
32+
{
33+
/**
34+
* @var \Illuminate\Contracts\Config\Repository
35+
*/
36+
protected $config;
37+
38+
/**
39+
* @var string
40+
*/
41+
protected $signature = 'p:info';
42+
43+
/**
44+
* @var \Pterodactyl\Services\Helpers\SoftwareVersionService
45+
*/
46+
protected $versionService;
47+
48+
/**
49+
* VersionCommand constructor.
50+
*
51+
* @param \Illuminate\Contracts\Config\Repository $config
52+
* @param \Pterodactyl\Services\Helpers\SoftwareVersionService $versionService
53+
*/
54+
public function __construct(ConfigRepository $config, SoftwareVersionService $versionService)
55+
{
56+
parent::__construct();
57+
58+
$this->config = $config;
59+
$this->versionService = $versionService;
60+
}
61+
62+
/**
63+
* Handle execution of command.
64+
*/
65+
public function handle()
66+
{
67+
$this->output->title('Version Information');
68+
$this->table([], [
69+
['Panel Version', $this->config->get('app.version')],
70+
['Latest Version', $this->versionService->getPanel()],
71+
['Up-to-Date', $this->versionService->isLatestPanel() ? 'Yes' : $this->formatText('No', 'bg=red')],
72+
['Unique Identifier', $this->config->get('pterodactyl.service.author')],
73+
], 'compact');
74+
75+
$this->output->title('Application Configuration');
76+
$this->table([], [
77+
['Environment', $this->formatText($this->config->get('app.env'), $this->config->get('app.env') === 'production' ?: 'bg=red')],
78+
['Debug Mode', $this->formatText($this->config->get('app.debug') ? 'Yes' : 'No', ! $this->config->get('app.debug') ?: 'bg=red')],
79+
['Installation URL', $this->config->get('app.url')],
80+
['Installation Directory', base_path()],
81+
['Timezone', $this->config->get('app.timezone')],
82+
['Cache Driver', $this->config->get('cache.default')],
83+
['Queue Driver', $this->config->get('queue.default')],
84+
['Session Driver', $this->config->get('session.driver')],
85+
['Filesystem Driver', $this->config->get('filesystems.default')],
86+
['Default Theme', $this->config->get('themes.active')],
87+
['Proxies', $this->config->get('trustedproxies.proxies')],
88+
], 'compact');
89+
90+
$this->output->title('Database Configuration');
91+
$driver = $this->config->get('database.default');
92+
$this->table([], [
93+
['Driver', $driver],
94+
['Host', $this->config->get("database.connections.{$driver}.host")],
95+
['Port', $this->config->get("database.connections.{$driver}.port")],
96+
['Database', $this->config->get("database.connections.{$driver}.database")],
97+
['Usernamne', $this->config->get("database.connections.{$driver}.username")],
98+
], 'compact');
99+
100+
$this->output->title('Email Configuration');
101+
$this->table([], [
102+
['Driver', $this->config->get('mail.driver')],
103+
['Host', $this->config->get('mail.host')],
104+
['Port', $this->config->get('mail.port')],
105+
['Username', $this->config->get('mail.username')],
106+
['From Address', $this->config->get('mail.from.address')],
107+
['From Name', $this->config->get('mail.from.name')],
108+
['Encryption', $this->config->get('mail.encryption')],
109+
], 'compact');
110+
}
111+
112+
/**
113+
* Format output in a Name: Value manner.
114+
*
115+
* @param string $value
116+
* @param string $opts
117+
* @return string
118+
*/
119+
private function formatText($value, $opts = '')
120+
{
121+
return sprintf('<%s>%s</>', $opts, $value);
122+
}
123+
}

app/Console/Commands/MakeUser.php

Lines changed: 0 additions & 95 deletions
This file was deleted.

app/Console/Commands/ShowVersion.php

Lines changed: 0 additions & 63 deletions
This file was deleted.

app/Console/Kernel.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Pterodactyl\Console;
44

55
use Illuminate\Console\Scheduling\Schedule;
6+
use Pterodactyl\Console\Commands\InfoCommand;
67
use Pterodactyl\Console\Commands\User\MakeUserCommand;
78
use Pterodactyl\Console\Commands\User\DeleteUserCommand;
89
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
@@ -21,6 +22,7 @@ class Kernel extends ConsoleKernel
2122
DeleteLocationCommand::class,
2223
DeleteUserCommand::class,
2324
DisableTwoFactorCommand::class,
25+
InfoCommand::class,
2426
MakeLocationCommand::class,
2527
MakeUserCommand::class,
2628
// \Pterodactyl\Console\Commands\MakeUser::class,

0 commit comments

Comments
 (0)