|
@ -52,7 +52,7 @@ class MariadbAddCommand extends Command |
|
|
public function handle() |
|
|
public function handle() |
|
|
{ |
|
|
{ |
|
|
// enter root password
|
|
|
// enter root password
|
|
|
$password = $this->secret('Enter root password'); |
|
|
|
|
|
|
|
|
$password = $this->secret('Root Password'); |
|
|
|
|
|
|
|
|
// connect database
|
|
|
// connect database
|
|
|
try { |
|
|
try { |
|
@ -64,18 +64,20 @@ class MariadbAddCommand extends Command |
|
|
|
|
|
|
|
|
$this->info('Mariadb Create Database...'); |
|
|
$this->info('Mariadb Create Database...'); |
|
|
|
|
|
|
|
|
// generate password
|
|
|
|
|
|
$generator = new ComputerPasswordGenerator(); |
|
|
|
|
|
$generator->setRandomGenerator(new Php7RandomGenerator()) |
|
|
|
|
|
->setUppercase() |
|
|
|
|
|
->setLowercase() |
|
|
|
|
|
->setUppercase() |
|
|
|
|
|
->setNumbers() |
|
|
|
|
|
->setSymbols(false) |
|
|
|
|
|
->setLength(self::PASSWORD_LENGTH); |
|
|
|
|
|
|
|
|
// setting password for root, repeat until
|
|
|
|
|
|
do { |
|
|
|
|
|
$password = $this->secret('New Password'); |
|
|
|
|
|
$passwordRepeat = $this->secret('Repeat Password'); |
|
|
|
|
|
|
|
|
// getting password
|
|
|
|
|
|
$password = $generator->generatePasswords(1)[0]; |
|
|
|
|
|
|
|
|
if ($password !== $passwordRepeat) { |
|
|
|
|
|
$this->error('Password not equal! Try again!'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (empty($password)) { |
|
|
|
|
|
$this->error('Password is empty! Try again!'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} while ($password !== $passwordRepeat || empty($password)); |
|
|
|
|
|
|
|
|
$generator = new ComputerPasswordGenerator(); |
|
|
$generator = new ComputerPasswordGenerator(); |
|
|
$generator->setRandomGenerator(new Php7RandomGenerator()) |
|
|
$generator->setRandomGenerator(new Php7RandomGenerator()) |
|
@ -92,6 +94,9 @@ class MariadbAddCommand extends Command |
|
|
$database = 'db'.$names[0]; |
|
|
$database = 'db'.$names[0]; |
|
|
$username = 'u'.$names[1]; |
|
|
$username = 'u'.$names[1]; |
|
|
|
|
|
|
|
|
|
|
|
$this->info('Database: '.$database); |
|
|
|
|
|
$this->info('Username: '.$username); |
|
|
|
|
|
|
|
|
// getting option for ssl
|
|
|
// getting option for ssl
|
|
|
$ssl = $this->option('ssl'); |
|
|
$ssl = $this->option('ssl'); |
|
|
|
|
|
|
|
@ -131,7 +136,6 @@ class MariadbAddCommand extends Command |
|
|
$mysqli->query("FLUSH PRIVILEGES"); |
|
|
$mysqli->query("FLUSH PRIVILEGES"); |
|
|
$mysqli->close(); |
|
|
$mysqli->close(); |
|
|
|
|
|
|
|
|
$this->info('Success! \o/ Check /root/mcp.log'); |
|
|
|
|
|
file_put_contents(self::MCP_LOG_FILE, "Mariadb $database created\nuser: $username\npassword: $password\n--\n", FILE_APPEND); |
|
|
|
|
|
|
|
|
$this->info('Success! \o/'); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |