Remove more unnecessary translations
This commit is contained in:
parent
0e3e14aa93
commit
100d4ee726
3 changed files with 58 additions and 126 deletions
|
@ -1,32 +1,23 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Pterodactyl - Panel
|
|
||||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
|
||||||
*
|
|
||||||
* This software is licensed under the terms of the MIT license.
|
|
||||||
* https://opensource.org/licenses/MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Pterodactyl\Console\Commands\Environment;
|
namespace Pterodactyl\Console\Commands\Environment;
|
||||||
|
|
||||||
use DateTimeZone;
|
use DateTimeZone;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Contracts\Console\Kernel;
|
use Illuminate\Contracts\Console\Kernel;
|
||||||
use Illuminate\Validation\Factory as ValidatorFactory;
|
|
||||||
use Pterodactyl\Traits\Commands\EnvironmentWriterTrait;
|
use Pterodactyl\Traits\Commands\EnvironmentWriterTrait;
|
||||||
use Illuminate\Contracts\Config\Repository as ConfigRepository;
|
|
||||||
|
|
||||||
class AppSettingsCommand extends Command
|
class AppSettingsCommand extends Command
|
||||||
{
|
{
|
||||||
use EnvironmentWriterTrait;
|
use EnvironmentWriterTrait;
|
||||||
|
|
||||||
public const ALLOWED_CACHE_DRIVERS = [
|
public const CACHE_DRIVERS = [
|
||||||
'redis' => 'Redis (recommended)',
|
'redis' => 'Redis (recommended)',
|
||||||
'memcached' => 'Memcached',
|
'memcached' => 'Memcached',
|
||||||
'file' => 'Filesystem',
|
'file' => 'Filesystem',
|
||||||
];
|
];
|
||||||
|
|
||||||
public const ALLOWED_SESSION_DRIVERS = [
|
public const SESSION_DRIVERS = [
|
||||||
'redis' => 'Redis (recommended)',
|
'redis' => 'Redis (recommended)',
|
||||||
'memcached' => 'Memcached',
|
'memcached' => 'Memcached',
|
||||||
'database' => 'MySQL Database',
|
'database' => 'MySQL Database',
|
||||||
|
@ -34,7 +25,7 @@ class AppSettingsCommand extends Command
|
||||||
'cookie' => 'Cookie',
|
'cookie' => 'Cookie',
|
||||||
];
|
];
|
||||||
|
|
||||||
public const ALLOWED_QUEUE_DRIVERS = [
|
public const QUEUE_DRIVERS = [
|
||||||
'redis' => 'Redis (recommended)',
|
'redis' => 'Redis (recommended)',
|
||||||
'database' => 'MySQL Database',
|
'database' => 'MySQL Database',
|
||||||
'sync' => 'Sync',
|
'sync' => 'Sync',
|
||||||
|
@ -45,11 +36,6 @@ class AppSettingsCommand extends Command
|
||||||
*/
|
*/
|
||||||
protected $command;
|
protected $command;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \Illuminate\Contracts\Config\Repository
|
|
||||||
*/
|
|
||||||
protected $config;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
|
@ -79,13 +65,11 @@ class AppSettingsCommand extends Command
|
||||||
/**
|
/**
|
||||||
* AppSettingsCommand constructor.
|
* AppSettingsCommand constructor.
|
||||||
*/
|
*/
|
||||||
public function __construct(ConfigRepository $config, Kernel $command, ValidatorFactory $validator)
|
public function __construct(Kernel $command)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
$this->config = $config;
|
|
||||||
$this->command = $command;
|
$this->command = $command;
|
||||||
$this->validator = $validator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -95,67 +79,60 @@ class AppSettingsCommand extends Command
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
if (empty($this->config->get('hashids.salt')) || $this->option('new-salt')) {
|
if (empty(config('hashids.salt')) || $this->option('new-salt')) {
|
||||||
$this->variables['HASHIDS_SALT'] = str_random(20);
|
$this->variables['HASHIDS_SALT'] = str_random(20);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->output->comment(trans('command/messages.environment.app.author_help'));
|
$this->output->comment('Provide the email address that eggs exported by this Panel should be from. This should be a valid email address.');
|
||||||
$this->variables['APP_SERVICE_AUTHOR'] = $this->option('author') ?? $this->ask(
|
$this->variables['APP_SERVICE_AUTHOR'] = $this->option('author') ?? $this->ask(
|
||||||
trans('command/messages.environment.app.author'),
|
'Egg Author Email',
|
||||||
$this->config->get('pterodactyl.service.author', 'unknown@unknown.com')
|
config('pterodactyl.service.author', 'unknown@unknown.com')
|
||||||
);
|
);
|
||||||
|
|
||||||
$validator = $this->validator->make(
|
if (!filter_var($this->variables['APP_SERVICE_AUTHOR'], FILTER_VALIDATE_EMAIL)) {
|
||||||
['email' => $this->variables['APP_SERVICE_AUTHOR']],
|
$this->output->error('The service author email provided is invalid.');
|
||||||
['email' => 'email']
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($validator->fails()) {
|
|
||||||
foreach ($validator->errors()->all() as $error) {
|
|
||||||
$this->output->error($error);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->output->comment(trans('command/messages.environment.app.app_url_help'));
|
$this->output->comment('The application URL MUST begin with https:// or http:// depending on if you are using SSL or not. If you do not include the scheme your emails and other content will link to the wrong location.');
|
||||||
$this->variables['APP_URL'] = $this->option('url') ?? $this->ask(
|
$this->variables['APP_URL'] = $this->option('url') ?? $this->ask(
|
||||||
trans('command/messages.environment.app.app_url'),
|
'Application URL',
|
||||||
$this->config->get('app.url', 'http://example.org')
|
config('app.url', 'http://example.org')
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->output->comment(trans('command/messages.environment.app.timezone_help'));
|
$this->output->comment('The timezone should match one of PHP\'s supported timezones. If you are unsure, please reference http://php.net/manual/en/timezones.php.');
|
||||||
$this->variables['APP_TIMEZONE'] = $this->option('timezone') ?? $this->anticipate(
|
$this->variables['APP_TIMEZONE'] = $this->option('timezone') ?? $this->anticipate(
|
||||||
trans('command/messages.environment.app.timezone'),
|
'Application Timezone',
|
||||||
DateTimeZone::listIdentifiers(DateTimeZone::ALL),
|
DateTimeZone::listIdentifiers(DateTimeZone::ALL),
|
||||||
$this->config->get('app.timezone')
|
config('app.timezone')
|
||||||
);
|
);
|
||||||
|
|
||||||
$selected = $this->config->get('cache.default', 'redis');
|
$selected = config('cache.default', 'redis');
|
||||||
$this->variables['CACHE_DRIVER'] = $this->option('cache') ?? $this->choice(
|
$this->variables['CACHE_DRIVER'] = $this->option('cache') ?? $this->choice(
|
||||||
trans('command/messages.environment.app.cache_driver'),
|
'Cache Driver',
|
||||||
self::ALLOWED_CACHE_DRIVERS,
|
self::CACHE_DRIVERS,
|
||||||
array_key_exists($selected, self::ALLOWED_CACHE_DRIVERS) ? $selected : null
|
array_key_exists($selected, self::CACHE_DRIVERS) ? $selected : null
|
||||||
);
|
);
|
||||||
|
|
||||||
$selected = $this->config->get('session.driver', 'redis');
|
$selected = config('session.driver', 'redis');
|
||||||
$this->variables['SESSION_DRIVER'] = $this->option('session') ?? $this->choice(
|
$this->variables['SESSION_DRIVER'] = $this->option('session') ?? $this->choice(
|
||||||
trans('command/messages.environment.app.session_driver'),
|
'Session Driver',
|
||||||
self::ALLOWED_SESSION_DRIVERS,
|
self::SESSION_DRIVERS,
|
||||||
array_key_exists($selected, self::ALLOWED_SESSION_DRIVERS) ? $selected : null
|
array_key_exists($selected, self::SESSION_DRIVERS) ? $selected : null
|
||||||
);
|
);
|
||||||
|
|
||||||
$selected = $this->config->get('queue.default', 'redis');
|
$selected = config('queue.default', 'redis');
|
||||||
$this->variables['QUEUE_CONNECTION'] = $this->option('queue') ?? $this->choice(
|
$this->variables['QUEUE_CONNECTION'] = $this->option('queue') ?? $this->choice(
|
||||||
trans('command/messages.environment.app.queue_driver'),
|
'Queue Driver',
|
||||||
self::ALLOWED_QUEUE_DRIVERS,
|
self::QUEUE_DRIVERS,
|
||||||
array_key_exists($selected, self::ALLOWED_QUEUE_DRIVERS) ? $selected : null
|
array_key_exists($selected, self::QUEUE_DRIVERS) ? $selected : null
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!is_null($this->option('settings-ui'))) {
|
if (!is_null($this->option('settings-ui'))) {
|
||||||
$this->variables['APP_ENVIRONMENT_ONLY'] = $this->option('settings-ui') == 'true' ? 'false' : 'true';
|
$this->variables['APP_ENVIRONMENT_ONLY'] = $this->option('settings-ui') == 'true' ? 'false' : 'true';
|
||||||
} else {
|
} else {
|
||||||
$this->variables['APP_ENVIRONMENT_ONLY'] = $this->confirm(trans('command/messages.environment.app.settings'), true) ? 'false' : 'true';
|
$this->variables['APP_ENVIRONMENT_ONLY'] = $this->confirm('Enable UI based settings editor?', true) ? 'false' : 'true';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure session cookies are set as "secure" when using HTTPS
|
// Make sure session cookies are set as "secure" when using HTTPS
|
||||||
|
@ -183,22 +160,22 @@ class AppSettingsCommand extends Command
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->output->note(trans('command/messages.environment.app.using_redis'));
|
$this->output->note('You\'ve selected the Redis driver for one or more options, please provide valid connection information below. In most cases you can use the defaults provided unless you have modified your setup.');
|
||||||
$this->variables['REDIS_HOST'] = $this->option('redis-host') ?? $this->ask(
|
$this->variables['REDIS_HOST'] = $this->option('redis-host') ?? $this->ask(
|
||||||
trans('command/messages.environment.app.redis_host'),
|
'Redis Host',
|
||||||
$this->config->get('database.redis.default.host')
|
config('database.redis.default.host')
|
||||||
);
|
);
|
||||||
|
|
||||||
$askForRedisPassword = true;
|
$askForRedisPassword = true;
|
||||||
if (!empty($this->config->get('database.redis.default.password'))) {
|
if (!empty(config('database.redis.default.password'))) {
|
||||||
$this->variables['REDIS_PASSWORD'] = $this->config->get('database.redis.default.password');
|
$this->variables['REDIS_PASSWORD'] = config('database.redis.default.password');
|
||||||
$askForRedisPassword = $this->confirm(trans('command/messages.environment.app.redis_pass_defined'));
|
$askForRedisPassword = $this->confirm('It seems a password is already defined for Redis, would you like to change it?');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($askForRedisPassword) {
|
if ($askForRedisPassword) {
|
||||||
$this->output->comment(trans('command/messages.environment.app.redis_pass_help'));
|
$this->output->comment('By default a Redis server instance has no password as it is running locally and inaccessible to the outside world. If this is the case, simply hit enter without entering a value.');
|
||||||
$this->variables['REDIS_PASSWORD'] = $this->option('redis-pass') ?? $this->output->askHidden(
|
$this->variables['REDIS_PASSWORD'] = $this->option('redis-pass') ?? $this->output->askHidden(
|
||||||
trans('command/messages.environment.app.redis_password')
|
'Redis Password'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,8 +184,8 @@ class AppSettingsCommand extends Command
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->variables['REDIS_PORT'] = $this->option('redis-port') ?? $this->ask(
|
$this->variables['REDIS_PORT'] = $this->option('redis-port') ?? $this->ask(
|
||||||
trans('command/messages.environment.app.redis_port'),
|
'Redis Port',
|
||||||
$this->config->get('database.redis.default.port')
|
config('database.redis.default.port')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Pterodactyl - Panel
|
|
||||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
|
||||||
*
|
|
||||||
* This software is licensed under the terms of the MIT license.
|
|
||||||
* https://opensource.org/licenses/MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Pterodactyl\Console\Commands\Environment;
|
namespace Pterodactyl\Console\Commands\Environment;
|
||||||
|
|
||||||
|
@ -14,17 +7,11 @@ use Illuminate\Console\Command;
|
||||||
use Illuminate\Contracts\Console\Kernel;
|
use Illuminate\Contracts\Console\Kernel;
|
||||||
use Illuminate\Database\DatabaseManager;
|
use Illuminate\Database\DatabaseManager;
|
||||||
use Pterodactyl\Traits\Commands\EnvironmentWriterTrait;
|
use Pterodactyl\Traits\Commands\EnvironmentWriterTrait;
|
||||||
use Illuminate\Contracts\Config\Repository as ConfigRepository;
|
|
||||||
|
|
||||||
class DatabaseSettingsCommand extends Command
|
class DatabaseSettingsCommand extends Command
|
||||||
{
|
{
|
||||||
use EnvironmentWriterTrait;
|
use EnvironmentWriterTrait;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \Illuminate\Contracts\Config\Repository
|
|
||||||
*/
|
|
||||||
protected $config;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \Illuminate\Contracts\Console\Kernel
|
* @var \Illuminate\Contracts\Console\Kernel
|
||||||
*/
|
*/
|
||||||
|
@ -58,11 +45,10 @@ class DatabaseSettingsCommand extends Command
|
||||||
/**
|
/**
|
||||||
* DatabaseSettingsCommand constructor.
|
* DatabaseSettingsCommand constructor.
|
||||||
*/
|
*/
|
||||||
public function __construct(ConfigRepository $config, DatabaseManager $database, Kernel $console)
|
public function __construct(DatabaseManager $database, Kernel $console)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
$this->config = $config;
|
|
||||||
$this->console = $console;
|
$this->console = $console;
|
||||||
$this->database = $database;
|
$this->database = $database;
|
||||||
}
|
}
|
||||||
|
@ -76,45 +62,45 @@ class DatabaseSettingsCommand extends Command
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$this->output->note(trans('command/messages.environment.database.host_warning'));
|
$this->output->note('It is highly recommended to not use "localhost" as your database host as we have seen frequent socket connection issues. If you want to use a local connection you should be using "127.0.0.1".');
|
||||||
$this->variables['DB_HOST'] = $this->option('host') ?? $this->ask(
|
$this->variables['DB_HOST'] = $this->option('host') ?? $this->ask(
|
||||||
trans('command/messages.environment.database.host'),
|
'Database Host',
|
||||||
$this->config->get('database.connections.mysql.host', '127.0.0.1')
|
config('database.connections.mysql.host', '127.0.0.1')
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->variables['DB_PORT'] = $this->option('port') ?? $this->ask(
|
$this->variables['DB_PORT'] = $this->option('port') ?? $this->ask(
|
||||||
trans('command/messages.environment.database.port'),
|
'Database Port',
|
||||||
$this->config->get('database.connections.mysql.port', 3306)
|
config('database.connections.mysql.port', 3306)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->variables['DB_DATABASE'] = $this->option('database') ?? $this->ask(
|
$this->variables['DB_DATABASE'] = $this->option('database') ?? $this->ask(
|
||||||
trans('command/messages.environment.database.database'),
|
'Database Name',
|
||||||
$this->config->get('database.connections.mysql.database', 'panel')
|
config('database.connections.mysql.database', 'panel')
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->output->note(trans('command/messages.environment.database.username_warning'));
|
$this->output->note('Using the "root" account for MySQL connections is not only highly frowned upon, it is also not allowed by this application. You\'ll need to have created a MySQL user for this software.');
|
||||||
$this->variables['DB_USERNAME'] = $this->option('username') ?? $this->ask(
|
$this->variables['DB_USERNAME'] = $this->option('username') ?? $this->ask(
|
||||||
trans('command/messages.environment.database.username'),
|
'Database Username',
|
||||||
$this->config->get('database.connections.mysql.username', 'pterodactyl')
|
config('database.connections.mysql.username', 'pterodactyl')
|
||||||
);
|
);
|
||||||
|
|
||||||
$askForMySQLPassword = true;
|
$askForMySQLPassword = true;
|
||||||
if (!empty($this->config->get('database.connections.mysql.password')) && $this->input->isInteractive()) {
|
if (!empty(config('database.connections.mysql.password')) && $this->input->isInteractive()) {
|
||||||
$this->variables['DB_PASSWORD'] = $this->config->get('database.connections.mysql.password');
|
$this->variables['DB_PASSWORD'] = config('database.connections.mysql.password');
|
||||||
$askForMySQLPassword = $this->confirm(trans('command/messages.environment.database.password_defined'));
|
$askForMySQLPassword = $this->confirm('It appears you already have a MySQL connection password defined, would you like to change it?');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($askForMySQLPassword) {
|
if ($askForMySQLPassword) {
|
||||||
$this->variables['DB_PASSWORD'] = $this->option('password') ?? $this->secret(trans('command/messages.environment.database.password'));
|
$this->variables['DB_PASSWORD'] = $this->option('password') ?? $this->secret('Database Password');
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->testMySQLConnection();
|
$this->testMySQLConnection();
|
||||||
} catch (PDOException $exception) {
|
} catch (PDOException $exception) {
|
||||||
$this->output->error(trans('command/messages.environment.database.connection_error', ['error' => $exception->getMessage()]));
|
$this->output->error(sprintf('Unable to connect to the MySQL server using the provided credentials. The error returned was "%s".', $exception->getMessage()));
|
||||||
$this->output->error(trans('command/messages.environment.database.creds_not_saved'));
|
$this->output->error('Your connection credentials have NOT been saved. You will need to provide valid connection information before proceeding.');
|
||||||
|
|
||||||
if ($this->confirm(trans('command/messages.environment.database.try_again'))) {
|
if ($this->confirm('Go back and try again?')) {
|
||||||
$this->database->disconnect('_pterodactyl_command_test');
|
$this->database->disconnect('_pterodactyl_command_test');
|
||||||
|
|
||||||
return $this->handle();
|
return $this->handle();
|
||||||
|
@ -135,7 +121,7 @@ class DatabaseSettingsCommand extends Command
|
||||||
*/
|
*/
|
||||||
private function testMySQLConnection()
|
private function testMySQLConnection()
|
||||||
{
|
{
|
||||||
$this->config->set('database.connections._pterodactyl_command_test', [
|
config()->set('database.connections._pterodactyl_command_test', [
|
||||||
'driver' => 'mysql',
|
'driver' => 'mysql',
|
||||||
'host' => $this->variables['DB_HOST'],
|
'host' => $this->variables['DB_HOST'],
|
||||||
'port' => $this->variables['DB_PORT'],
|
'port' => $this->variables['DB_PORT'],
|
||||||
|
|
|
@ -62,36 +62,5 @@ return [
|
||||||
'ask_mail_name' => 'Name that emails should appear from',
|
'ask_mail_name' => 'Name that emails should appear from',
|
||||||
'ask_encryption' => 'Encryption method to use',
|
'ask_encryption' => 'Encryption method to use',
|
||||||
],
|
],
|
||||||
'database' => [
|
|
||||||
'host_warning' => 'It is highly recommended to not use "localhost" as your database host as we have seen frequent socket connection issues. If you want to use a local connection you should be using "127.0.0.1".',
|
|
||||||
'host' => 'Database Host',
|
|
||||||
'port' => 'Database Port',
|
|
||||||
'database' => 'Database Name',
|
|
||||||
'username_warning' => 'Using the "root" account for MySQL connections is not only highly frowned upon, it is also not allowed by this application. You\'ll need to have created a MySQL user for this software.',
|
|
||||||
'username' => 'Database Username',
|
|
||||||
'password_defined' => 'It appears you already have a MySQL connection password defined, would you like to change it?',
|
|
||||||
'password' => 'Database Password',
|
|
||||||
'connection_error' => 'Unable to connect to the MySQL server using the provided credentials. The error returned was ":error".',
|
|
||||||
'creds_not_saved' => 'Your connection credentials have NOT been saved. You will need to provide valid connection information before proceeding.',
|
|
||||||
'try_again' => 'Go back and try again?',
|
|
||||||
],
|
|
||||||
'app' => [
|
|
||||||
'settings' => 'Enable UI based settings editor?',
|
|
||||||
'author' => 'Egg Author Email',
|
|
||||||
'author_help' => 'Provide the email address that eggs exported by this Panel should be from. This should be a valid email address.',
|
|
||||||
'app_url_help' => 'The application URL MUST begin with https:// or http:// depending on if you are using SSL or not. If you do not include the scheme your emails and other content will link to the wrong location.',
|
|
||||||
'app_url' => 'Application URL',
|
|
||||||
'timezone_help' => 'The timezone should match one of PHP\'s supported timezones. If you are unsure, please reference http://php.net/manual/en/timezones.php.',
|
|
||||||
'timezone' => 'Application Timezone',
|
|
||||||
'cache_driver' => 'Cache Driver',
|
|
||||||
'session_driver' => 'Session Driver',
|
|
||||||
'queue_driver' => 'Queue Driver',
|
|
||||||
'using_redis' => 'You\'ve selected the Redis driver for one or more options, please provide valid connection information below. In most cases you can use the defaults provided unless you have modified your setup.',
|
|
||||||
'redis_host' => 'Redis Host',
|
|
||||||
'redis_password' => 'Redis Password',
|
|
||||||
'redis_pass_help' => 'By default a Redis server instance has no password as it is running locally and inaccessible to the outside world. If this is the case, simply hit enter without entering a value.',
|
|
||||||
'redis_port' => 'Redis Port',
|
|
||||||
'redis_pass_defined' => 'It seems a password is already defined for Redis, would you like to change it?',
|
|
||||||
],
|
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in a new issue