| 
																	
																	
																		
																			
																		
																	
																	
																 | 
																@ -36,7 +36,7 @@ class MariadbInstallCommand extends Command | 
															
														
														
													
														
															
																 | 
																 | 
																     * | 
																 | 
																 | 
																     * | 
															
														
														
													
														
															
																 | 
																 | 
																     * @var string | 
																 | 
																 | 
																     * @var string | 
															
														
														
													
														
															
																 | 
																 | 
																     */ | 
																 | 
																 | 
																     */ | 
															
														
														
													
														
															
																 | 
																 | 
																    protected $description = 'Install mariadb and set configuration'; | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																    protected $description = 'Install Mariadb and set configuration'; | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																    /** | 
																 | 
																 | 
																    /** | 
															
														
														
													
														
															
																 | 
																 | 
																     * Execute the console command. | 
																 | 
																 | 
																     * Execute the console command. | 
															
														
														
													
												
													
														
															
																| 
																	
																	
																	
																		
																			
																		
																	
																 | 
																@ -47,8 +47,11 @@ class MariadbInstallCommand extends Command | 
															
														
														
													
														
															
																 | 
																 | 
																    { | 
																 | 
																 | 
																    { | 
															
														
														
													
														
															
																 | 
																 | 
																        $this->info('Mariadb install...'); | 
																 | 
																 | 
																        $this->info('Mariadb install...'); | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																        exec('apt update 2>&1'); | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																        exec('apt install -y mariadb-server mariadb-client 2>&1'); | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																        exec('apt update 2>&1', $output); | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																        exec('apt install -y mariadb-server mariadb-client 2>&1', $output); | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																        // @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 mariadb-client')) { | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
												
													
														
															
																| 
																	
																	
																	
																		
																			
																		
																	
																 | 
																@ -68,27 +71,31 @@ class MariadbInstallCommand extends Command | 
															
														
														
													
														
															
																 | 
																 | 
																            $password = $generator->generatePasswords()[0]; | 
																 | 
																 | 
																            $password = $generator->generatePasswords()[0]; | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																            // remove plugin for root and set password
 | 
																 | 
																 | 
																            // remove plugin for root and set password
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																            $this->info('Mariadb add password for root...'); | 
															
														
														
													
														
															
																 | 
																 | 
																            exec('sudo mysql -u root -e "UPDATE mysql.user SET Password=PASSWORD(\''.$password.'\') WHERE User=\'root\';"'); | 
																 | 
																 | 
																            exec('sudo mysql -u root -e "UPDATE mysql.user SET Password=PASSWORD(\''.$password.'\') WHERE User=\'root\';"'); | 
															
														
														
													
														
															
																 | 
																 | 
																            exec('sudo mysql -u root -e "UPDATE mysql.user SET plugin=\'\' where User=\'root\';"'); | 
																 | 
																 | 
																            exec('sudo mysql -u root -e "UPDATE mysql.user SET plugin=\'\' where User=\'root\';"'); | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																            // delete anonymous user
 | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																            exec('sudo mysql -u root -e "DELETE FROM mysql.user WHERE User=\'\';"'); | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																            // make sure root can only access from local
 | 
																 | 
																 | 
																            // make sure root can only access from local
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																            $this->info('Mariadb make sure root can ony access from local...'); | 
															
														
														
													
														
															
																 | 
																 | 
																            exec('sudo mysql -u root -e "DELETE FROM mysql.user WHERE User=\'root\' AND Host NOT IN (\'localhost\', \'127.0.0.1\', \'::1\');"'); | 
																 | 
																 | 
																            exec('sudo mysql -u root -e "DELETE FROM mysql.user WHERE User=\'root\' AND Host NOT IN (\'localhost\', \'127.0.0.1\', \'::1\');"'); | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																            // delete anonymous user
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																            $this->info('Mariadb delete anonymous user...'); | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																            exec('sudo mysql -u root -e "DELETE FROM mysql.user WHERE User=\'\';"'); | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																            // drop test database and anthing familiar
 | 
																 | 
																 | 
																            // drop test database and anthing familiar
 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																            $this->info('Mariadb drop test and anthing familiar...'); | 
															
														
														
													
														
															
																 | 
																 | 
																            exec('sudo mysql -u root -e "DROP DATABASE IF EXISTS test;"'); | 
																 | 
																 | 
																            exec('sudo mysql -u root -e "DROP DATABASE IF EXISTS test;"'); | 
															
														
														
													
														
															
																 | 
																 | 
																            exec('sudo mysql -u root -e "DELETE FROM mysql.db WHERE Db=\'test\' OR Db=\'test_%\';"'); | 
																 | 
																 | 
																            exec('sudo mysql -u root -e "DELETE FROM mysql.db WHERE Db=\'test\' OR Db=\'test_%\';"'); | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																            // update privileges
 | 
																 | 
																 | 
																            // update privileges
 | 
															
														
														
													
														
															
																 | 
																 | 
																            exec('sudo mysql -u root -e "FLUSH PRIVILEGES;"'); | 
																 | 
																 | 
																            exec('sudo mysql -u root -e "FLUSH PRIVILEGES;"'); | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																            $this->info('Success! \o/ Check /root/mcp.log'); | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																            $this->info('Mariadb installing...Success! \o/ Check '.self::MCP_LOG_FILE); | 
															
														
														
													
														
															
																 | 
																 | 
																            file_put_contents(self::MCP_LOG_FILE, "Mariadb installed\nuser: root\npassword: $password\n--\n", FILE_APPEND); | 
																 | 
																 | 
																            file_put_contents(self::MCP_LOG_FILE, "Mariadb installed\nuser: root\npassword: $password\n--\n", FILE_APPEND); | 
															
														
														
													
														
															
																 | 
																 | 
																
 | 
																 | 
																 | 
																
 | 
															
														
														
													
														
															
																 | 
																 | 
																        } else { | 
																 | 
																 | 
																        } else { | 
															
														
														
													
														
															
																 | 
																 | 
																            $this->error('Failed!'); | 
																 | 
																 | 
																 | 
															
														
														
													
														
															
																 | 
																 | 
																 | 
																 | 
																 | 
																            $this->error('Failed! Please check log-file!'); | 
															
														
														
													
														
															
																 | 
																 | 
																        } | 
																 | 
																 | 
																        } | 
															
														
														
													
														
															
																 | 
																 | 
																    } | 
																 | 
																 | 
																    } | 
															
														
														
													
														
															
																 | 
																 | 
																} | 
																 | 
																 | 
																} |