Support installing BS via CLI
This commit is contained in:
parent
e71e74cd5b
commit
623ebfc3e2
47
app/Console/Commands/ExecuteInstallation.php
Normal file
47
app/Console/Commands/ExecuteInstallation.php
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class ExecuteInstallation extends Command
|
||||
{
|
||||
protected $signature = 'bs:install {email} {password} {nickname}';
|
||||
|
||||
protected $description = 'Execute installation and create a super administrator.';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$this->call('key:random');
|
||||
$this->call('salt:random');
|
||||
$this->call('migrate', ['--force' => true]);
|
||||
|
||||
$siteUrl = url('/');
|
||||
if (ends_with($siteUrl, '/index.php')) {
|
||||
$siteUrl = substr($siteUrl, 0, -10);
|
||||
}
|
||||
option(['site_url' => $siteUrl]);
|
||||
|
||||
$admin = new User;
|
||||
$admin->email = $this->argument('email');
|
||||
$admin->nickname = $this->argument('nickname');
|
||||
$admin->score = option('user_initial_score');
|
||||
$admin->avatar = 0;
|
||||
$admin->password = app('cipher')->hash($this->argument('password'), config('secure.salt'));
|
||||
$admin->ip = '127.0.0.1';
|
||||
$admin->permission = User::SUPER_ADMIN;
|
||||
$admin->register_at = get_datetime_string();
|
||||
$admin->last_sign_at = get_datetime_string(time() - 86400);
|
||||
$admin->verified = true;
|
||||
$admin->save();
|
||||
|
||||
$this->info('Installation completed!');
|
||||
$this->info('We recommend to modify your "Site URL" option if incorrect.');
|
||||
}
|
||||
}
|
||||
|
|
@ -18,6 +18,7 @@ class Kernel extends ConsoleKernel
|
|||
Commands\SaltRandomCommand::class,
|
||||
Commands\MigratePlayersTable::class,
|
||||
Commands\MigrateCloset::class,
|
||||
Commands\ExecuteInstallation::class,
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user