diff --git a/app/Commands/Fail2banDisableCommand.php b/app/Commands/Fail2banDisableCommand.php index 38219af..3c9b174 100644 --- a/app/Commands/Fail2banDisableCommand.php +++ b/app/Commands/Fail2banDisableCommand.php @@ -12,7 +12,7 @@ use LaravelZero\Framework\Commands\Command; * @author Björn Hase, Tentakelfabrik * @license http://opensource.org/licenses/MIT The MIT License * @link https://gitea.tentakelfabrik.de/Tentakelfabrik/mcp - * + * */ class Fail2banDisableCommand extends Command { @@ -56,7 +56,7 @@ class Fail2banDisableCommand extends Command unlink(self::DESTINATION_FAIL2BAN_JAIL_DIRECTORY.'/'.$configuration.'.conf'); - exec('service fail2ban restart'); + system('service fail2ban restart'); $this->info('Fail2ban...'.$configuration.' disabled'); } } diff --git a/app/Commands/Fail2banEnableCommand.php b/app/Commands/Fail2banEnableCommand.php index 5f11c80..52319d5 100644 --- a/app/Commands/Fail2banEnableCommand.php +++ b/app/Commands/Fail2banEnableCommand.php @@ -12,7 +12,7 @@ use LaravelZero\Framework\Commands\Command; * @author Björn Hase, Tentakelfabrik * @license http://opensource.org/licenses/MIT The MIT License * @link https://gitea.tentakelfabrik.de/Tentakelfabrik/mcp - * + * */ class Fail2banEnableCommand extends Command { @@ -63,7 +63,7 @@ class Fail2banEnableCommand extends Command } copy($source, $destination); - exec('service fail2ban restart'); + system('service fail2ban restart'); $this->info('Fail2ban...'.$configuration.' enabled'); } diff --git a/app/Commands/LetsEncryptAddCommand.php b/app/Commands/LetsEncryptAddCommand.php index 8d3ba56..4721f7c 100644 --- a/app/Commands/LetsEncryptAddCommand.php +++ b/app/Commands/LetsEncryptAddCommand.php @@ -46,14 +46,13 @@ class LetsEncryptAddCommand extends Command // add file for domain $saved = []; - // create flags + // create flags foreach($domains as $domain) { $domainFlags .= '-d '.$domain.' '; $saved[$domain] = '/etc/letsencrypt/live/'.$domain.'/fullchain.pem'; } - exec('certbot --non-interactive --agree-tos -m '.$this->argument('email').' --nginx '.$domainFlags, $output); - $this->line(implode("\n", $output)); + system('certbot --non-interactive --agree-tos -m '.$this->argument('email').' --nginx '.$domainFlags); foreach($saved as $domain => $file) { if (file_exists($file)) { diff --git a/app/Commands/LetsEncryptInstallCommand.php b/app/Commands/LetsEncryptInstallCommand.php index e4e74e7..7ebe3e5 100644 --- a/app/Commands/LetsEncryptInstallCommand.php +++ b/app/Commands/LetsEncryptInstallCommand.php @@ -65,10 +65,7 @@ class LetsEncryptInstallCommand extends Command $output = []; $this->info('LetsEncrypt generate dhparam.pem...'); - exec('openssl dhparam -out /etc/ssl/certs/dhparam.pem 4096', $ouput); - - // @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))); + system('openssl dhparam -out /etc/ssl/certs/dhparam.pem 4096', $ouput); if (Install::isReady('certbot')) { $this->info('LetsEncrypt installing...Success! \o/'); diff --git a/app/Commands/LetsEncryptRemoveCommand.php b/app/Commands/LetsEncryptRemoveCommand.php index 26bf72c..7e4ee54 100644 --- a/app/Commands/LetsEncryptRemoveCommand.php +++ b/app/Commands/LetsEncryptRemoveCommand.php @@ -63,9 +63,9 @@ class LetsEncryptRemoveCommand extends Command $errors++; } else { if (is_file($directory)) { - exec('rm '.$directory.' 2>&1', $output); + system('rm '.$directory.' 2>&1'); } else { - exec('rm -rf '.$directory.' 2>&1', $output); + system('rm -rf '.$directory.' 2>&1'); } } } diff --git a/app/Commands/MariadbInstallCommand.php b/app/Commands/MariadbInstallCommand.php index d8262a9..703953e 100644 --- a/app/Commands/MariadbInstallCommand.php +++ b/app/Commands/MariadbInstallCommand.php @@ -98,25 +98,25 @@ class MariadbInstallCommand extends Command // 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\');"'); + system('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=\'\';"'); + system('sudo mysql -u root -e "DELETE FROM mysql.user WHERE User=\'\';"'); // 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 "DELETE FROM mysql.db WHERE Db=\'test\' OR Db=\'test_%\';"'); + system('sudo mysql -u root -e "DROP DATABASE IF EXISTS test;"'); + system('sudo mysql -u root -e "DELETE FROM mysql.db WHERE Db=\'test\' OR Db=\'test_%\';"'); // remove plugin for root and set password $this->info('Mariadb add password for root...'); if ($version === '10.4') { - exec('sudo mysql -u root -e "ALTER USER root@localhost IDENTIFIED VIA mysql_native_password USING PASSWORD(\''.$password.'\'); FLUSH PRIVILEGES;"'); + system('sudo mysql -u root -e "ALTER USER root@localhost IDENTIFIED VIA mysql_native_password USING PASSWORD(\''.$password.'\'); FLUSH PRIVILEGES;"'); } else { - exec('sudo mysql -u root -e "UPDATE mysql.user SET Password=PASSWORD(\''.$password.'\') WHERE User=\'root\'; FLUSH PRIVILEGES;"'); - exec('sudo mysql -u root -e "UPDATE mysql.user SET plugin=\'\' where User=\'root\';"'); + system('sudo mysql -u root -e "UPDATE mysql.user SET Password=PASSWORD(\''.$password.'\') WHERE User=\'root\'; FLUSH PRIVILEGES;"'); + 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); diff --git a/app/Commands/NginxInstallCommand.php b/app/Commands/NginxInstallCommand.php index 34234c9..352ab7f 100644 --- a/app/Commands/NginxInstallCommand.php +++ b/app/Commands/NginxInstallCommand.php @@ -77,8 +77,7 @@ class NginxInstallCommand extends Command $output = []; $this->info('Nginx adding ufw rules...'); - exec('ufw allow "Nginx Full" 2>&1', $output); - $this->line(implode("\n", $output)); + system('ufw allow "Nginx Full"'); $this->info('Nginx installing...Success! \o/'); } else {