1
1
mirror of https://github.com/pterodactyl/panel.git synced 2024-11-22 09:02:28 +01:00

flags for setup scripts, closes #134

This commit is contained in:
Dane Everitt 2016-10-12 19:02:15 -04:00
parent 90240bfd69
commit f65e41a1af
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
4 changed files with 66 additions and 34 deletions

View File

@ -8,9 +8,11 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
### Added
* Return node configuration from remote API by using `/api/nodes/{id}/config` endpoint. Only accepts SSL connections.
* Support for filtering servers within Admin CP to narrow down results by name, email, allocation, or defined fields.
* Setup scripts (user, mail, env) now support argument flags for use in containers and other non-terminal environments.
### Changed
* Creating a user, server, or node now returns `HTTP/1.1 200` and a JSON element with the user/server/node's ID.
* Environment setting script is much more user friendly and does not require an excessive amount of clicking and typing.
## v0.5.0-pre.2 (Bodacious Boreopterus)

View File

@ -35,7 +35,10 @@ class MakeUser extends Command
*
* @var string
*/
protected $signature = 'pterodactyl:user';
protected $signature = 'pterodactyl:user
{--email= : Email address to use for this account.}
{--password= : Password to assign to the user.}
{--admin= : Boolean flag for if user should be an admin.}';
/**
* The console command description.
@ -61,15 +64,15 @@ class MakeUser extends Command
*/
public function handle()
{
$email = $this->ask('Email');
$password = $this->secret('Password');
$password_confirmation = $this->secret('Confirm Password');
$email = is_null($this->option('email')) ? $this->ask('Email') : $this->option('email');
$password = is_null($this->option('password')) ? $this->secret('Password') : $this->option('password');
$password_confirmation = is_null($this->option('password')) ? $this->secret('Confirm Password') : $this->option('password');
if ($password !== $password_confirmation) {
return $this->error('The passwords provided did not match!');
}
$admin = $this->confirm('Is this user a root administrator?');
$admin = is_null($this->option('admin')) ? $this->confirm('Is this user a root administrator?') : $this->option('admin');
try {
$user = new UserRepository;

View File

@ -32,7 +32,13 @@ class UpdateEmailSettings extends Command
*
* @var string
*/
protected $signature = 'pterodactyl:mail';
protected $signature = 'pterodactyl:mail
{--driver=}
{--email=}
{--host=}
{--port=}
{--username=}
{--password=}';
/**
* The console command description.
@ -92,35 +98,35 @@ class UpdateEmailSettings extends Command
'Postmark Transactional Email Service'
]
]);
$variables['MAIL_DRIVER'] = $this->choice('Which email driver would you like to use?', [
$variables['MAIL_DRIVER'] = is_null($this->option('driver')) ? $this->choice('Which email driver would you like to use?', [
'smtp',
'mail',
'mailgun',
'mandrill',
'postmark'
]);
]) : $this->option('driver');
switch ($variables['MAIL_DRIVER']) {
case 'smtp':
$variables['MAIL_HOST'] = $this->ask('SMTP Host (e.g smtp.google.com)');
$variables['MAIL_PORT'] = $this->anticipate('SMTP Host Port (e.g 587)', ['587']);
$variables['MAIL_USERNAME'] = $this->ask('SMTP Username');
$variables['MAIL_PASSWORD'] = $this->secret('SMTP Password');
$variables['MAIL_HOST'] = is_null($this->option('host')) ? $this->ask('SMTP Host (e.g smtp.google.com)') : $this->option('host');
$variables['MAIL_PORT'] = is_null($this->option('port')) ? $this->anticipate('SMTP Host Port (e.g 587)', ['587']) : $this->option('port');
$variables['MAIL_USERNAME'] = is_null($this->option('username')) ? $this->ask('SMTP Username') : $this->option('password');
$variables['MAIL_PASSWORD'] = is_null($this->option('password')) ? $this->secret('SMTP Password') : $this->option('password');
break;
case 'mail':
break;
case 'mailgun':
$variables['MAILGUN_DOMAIN'] = $this->ask('Mailgun Domain');
$variables['MAILGUN_KEY'] = $this->ask('Mailgun Key');
$variables['MAILGUN_DOMAIN'] = is_null($this->option('host')) ? $this->ask('Mailgun Domain') : $this->option('host');
$variables['MAILGUN_KEY'] = is_null($this->option('username')) ? $this->ask('Mailgun Key') : $this->option('username');
break;
case 'mandrill':
$variables['MANDRILL_SECRET'] = $this->ask('Mandrill Secret');
$variables['MANDRILL_SECRET'] = is_null($this->option('username')) ? $this->ask('Mandrill Secret') : $this->option('username');
break;
case 'postmark':
$variables['MAIL_DRIVER'] = 'smtp';
$variables['MAIL_HOST'] = 'smtp.postmarkapp.com';
$variables['MAIL_PORT'] = 587;
$variables['MAIL_USERNAME'] = $this->ask('Postmark API Token');
$variables['MAIL_USERNAME'] = is_null($this->option('username')) ? $this->ask('Postmark API Token') : $this->option('username');
$variables['MAIL_PASSWORD'] = $variables['MAIL_USERNAME'];
break;
default:
@ -129,7 +135,7 @@ class UpdateEmailSettings extends Command
break;
}
$variables['MAIL_FROM'] = $this->ask('Email address emails should originate from');
$variables['MAIL_FROM'] = is_null($this->option('email')) ? $this->ask('Email address emails should originate from') : $this->option('email');
$variables['MAIL_ENCRYPTION'] = 'tls';
$bar = $this->output->createProgressBar(count($variables));

View File

@ -33,7 +33,14 @@ class UpdateEnvironment extends Command
*
* @var string
*/
protected $signature = 'pterodactyl:env';
protected $signature = 'pterodactyl:env
{--dbhost=}
{--dbport=}
{--dbname=}
{--dbuser=}
{--dbpass=}
{--url=}
{--timezone=}';
/**
* The console command description.
@ -69,40 +76,54 @@ class UpdateEnvironment extends Command
$envContents = file_get_contents($file);
$this->info('Simply leave blank and press enter to fields that you do not wish to update.');
if (!env('SERVICE_AUTHOR', false)) {
$this->info('No service author set, setting one now.');
$variables['SERVICE_AUTHOR'] = env('SERVICE_AUTHOR', (string) Uuid::generate(4));
}
// DB info
if($this->confirm('Update database host? [' . env('DB_HOST') . ']')) {
$variables['DB_HOST'] = $this->anticipate('Database Host (usually \'localhost\' or \'127.0.0.1\')', [ 'localhost', '127.0.0.1', env('DB_HOST') ]);
if (is_null($this->option('dbhost'))) {
$variables['DB_HOST'] = $this->anticipate('Database Host', [ 'localhost', '127.0.0.1', env('DB_HOST') ], env('DB_HOST'));
} else {
$variables['DB_HOST'] = $this->option('dbhost');
}
if($this->confirm('Update database port? [' . env('DB_PORT') . ']')) {
$variables['DB_PORT'] = $this->anticipate('Database Port', [ 3306, env('DB_PORT') ]);
if (is_null($this->option('dbport'))) {
$variables['DB_PORT'] = $this->anticipate('Database Port', [ 3306, env('DB_PORT') ], env('DB_PORT'));
} else {
$variables['DB_PORT'] = $this->option('dbport');
}
if($this->confirm('Update database name? [' . env('DB_DATABASE') . ']')) {
$variables['DB_DATABASE'] = $this->anticipate('Database Name', [ 'pterodactyl', 'homestead', ENV('DB_DATABASE') ]);
if (is_null($this->option('dbname'))) {
$variables['DB_DATABASE'] = $this->anticipate('Database Name', [ 'pterodactyl', 'homestead', ENV('DB_DATABASE') ], env('DB_DATABASE'));
} else {
$variables['DB_DATABASE'] = $this->option('dbname');
}
if($this->confirm('Update database username? [' . env('DB_USERNAME') . ']')) {
$variables['DB_USERNAME'] = $this->anticipate('Database Username', [ env('DB_USERNAME') ]);
if (is_null($this->option('dbuser'))) {
$variables['DB_USERNAME'] = $this->anticipate('Database Username', [ ENV('DB_DATABASE') ], env('DB_USERNAME'));
} else {
$variables['DB_USERNAME'] = $this->option('dbuser');
}
if($this->confirm('Update database password?')) {
$variables['DB_PASSWORD'] = $this->secret('Database User\'s Password');
if (is_null($this->option('dbpass'))) {
$this->line('The Database Password field is required; you cannot hit enter and use a default value.');
$variables['DB_PASSWORD'] = $this->secret('Database User Password');
} else {
$variables['DB_PASSWORD'] = $this->option('dbpass');
}
// Other Basic Information
if($this->confirm('Update panel URL? [' . env('APP_URL') . ']')) {
$variables['APP_URL'] = $this->anticipate('Enter your current panel URL (include http or https).', [ env('APP_URL', 'http://localhost') ]);
if (is_null($this->option('url'))) {
$variables['APP_URL'] = $this->ask('Panel URL', env('APP_URL'));
} else {
$variables['APP_URL'] = $this->option('url');
}
if($this->confirm('Update panel timezone? [' . env('APP_TIMEZONE') . ']')) {
if (is_null($this->option('timezone'))) {
$this->line('The timezone should match one of the supported timezones according to http://php.net/manual/en/timezones.php');
$variables['APP_TIMEZONE'] = $this->anticipate('Enter the timezone for this panel to run with', \DateTimeZone::listIdentifiers(\DateTimeZone::ALL));
$variables['APP_TIMEZONE'] = $this->anticipate('Panel Timezone', \DateTimeZone::listIdentifiers(\DateTimeZone::ALL), env('APP_TIMEZONE'));
} else {
$variables['APP_TIMEZONE'] = $this->option('timezone');
}
$bar = $this->output->createProgressBar(count($variables));