Browse Source

adding #35

release/0.2
Björn 4 years ago
parent
commit
829f4bd231
2 changed files with 33 additions and 28 deletions
  1. +18
    -14
      app/Commands/MariadbAddCommand.php
  2. +15
    -14
      app/Commands/MariadbInstallCommand.php

+ 18
- 14
app/Commands/MariadbAddCommand.php View File

@ -52,7 +52,7 @@ class MariadbAddCommand extends Command
public function handle()
{
// enter root password
$password = $this->secret('Enter root password');
$password = $this->secret('Root Password');
// connect database
try {
@ -64,18 +64,20 @@ class MariadbAddCommand extends Command
$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->setRandomGenerator(new Php7RandomGenerator())
@ -92,6 +94,9 @@ class MariadbAddCommand extends Command
$database = 'db'.$names[0];
$username = 'u'.$names[1];
$this->info('Database: '.$database);
$this->info('Username: '.$username);
// getting option for ssl
$ssl = $this->option('ssl');
@ -131,7 +136,6 @@ class MariadbAddCommand extends Command
$mysqli->query("FLUSH PRIVILEGES");
$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/');
}
}

+ 15
- 14
app/Commands/MariadbInstallCommand.php View File

@ -79,22 +79,24 @@ class MariadbInstallCommand extends Command
// @TODO apt add a Warning for no good, in a later version output will be scanned for helpfull infos
$this->line(implode("\n", Install::filterAptMessages($output)));
if (Install::isReady('mariadb-server mariadb-client')) {
if (Install::isReady('mariadb-server') && Install::isReady('mariadb-client')) {
$this->info('Mariadb setup...');
// 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('Root Password');
$passwordRepeat = $this->secret('Repeat Root Password');
// getting password for root
$password = $generator->generatePasswords()[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));
// make sure root can only access from local
$this->info('Mariadb make sure root can ony access from local...');
@ -119,8 +121,7 @@ class MariadbInstallCommand extends Command
system('sudo mysql -u root -e "UPDATE mysql.user SET plugin=\'\' where User=\'root\';"');
}
file_put_contents(self::MCP_LOG_FILE, "Mariadb installed\nuser: root\npassword: $password\n--\n", FILE_APPEND);
$this->info('Mariadb installing...Success! \o/ Check '.self::MCP_LOG_FILE);
$this->info('Mariadb installing...Success! \o/');
} else {
$this->error('Failed! Please check log-file!');


Loading…
Cancel
Save