Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non interactive koel:init #886

Merged
merged 6 commits into from Jan 1, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
71 changes: 50 additions & 21 deletions app/Console/Commands/InitCommand.php
Expand Up @@ -124,20 +124,38 @@ private function setUpDatabase(): void
private function setUpAdminAccount(): void
{
$this->info("Let's create the admin account.");
$name = $this->ask('Your name');
$email = $this->ask('Your email address');
$passwordConfirmed = false;
$password = null;

while (!$passwordConfirmed) {
$password = $this->secret('Your desired password');
$confirmation = $this->secret('Again, just to make sure');

if ($confirmation !== $password) {
$this->error('That doesn\'t match. Let\'s try again.');
} else {
$passwordConfirmed = true;

$name = config('koel.admin.name');
if (!$name) {
$name = $this->ask('Your name');
} else {
$this->comment('Admin name exists => '.$name);
}

$email = config('koel.admin.email');
if (!$email) {
$email = $this->ask('Your email address');
} else {
$this->comment('Admin email exists => '.$email);
}

$password = config('koel.admin.password');
if (!$password) {
$passwordConfirmed = false;
$password = null;

while (!$passwordConfirmed) {
$password = $this->secret('Your desired password');
$confirmation = $this->secret('Again, just to make sure');

if ($confirmation !== $password) {
$this->error('That doesn\'t match. Let\'s try again.');
} else {
$passwordConfirmed = true;
}
}
} else {
$this->comment('Admin password exists => '.str_repeat("*", strlen($password)));
}

User::create([
Expand All @@ -156,20 +174,31 @@ private function maybeSetMediaPath(): void

$this->info('The absolute path to your media directory. If this is skipped (left blank) now, you can set it later via the web interface.');

while (true) {
$path = $this->ask('Media path', false);
$path = config('koel.media_path');
if (!$path) {
while (true) {
$path = $this->ask('Media Path', false);

if ($path === false) {
return;
}

if ($path === false) {
return;
if (is_dir($path) && is_readable($path)) {
Setting::set('media_path', $path);
return;
}

$this->error('The path does not exist or not readable. Try again.');
}
} else {
$this->comment('Media Path exists => '.$path);

if (is_dir($path) && is_readable($path)) {
Setting::set('media_path', $path);

return;
Setting::set('media_path', $path);
return;
}

$this->error('The path does not exist or not readable. Try again.');
$this->error('The path '.$path.' does not exist or not readable. Skipping.');
}
}

Expand Down
2 changes: 2 additions & 0 deletions config/koel.php
Expand Up @@ -26,6 +26,8 @@
|
*/

'media_path' => env('APP_MEDIA_PATH', '/media'),

'sync' => [
'timeout' => env('APP_MAX_SCAN_TIME', 600),
],
Expand Down