Browse Source

adding #38

release/0.2
Björn 4 years ago
parent
commit
e19a5d617e
7 changed files with 17 additions and 22 deletions
  1. +2
    -2
      app/Commands/Fail2banDisableCommand.php
  2. +2
    -2
      app/Commands/Fail2banEnableCommand.php
  3. +2
    -3
      app/Commands/LetsEncryptAddCommand.php
  4. +1
    -4
      app/Commands/LetsEncryptInstallCommand.php
  5. +2
    -2
      app/Commands/LetsEncryptRemoveCommand.php
  6. +7
    -7
      app/Commands/MariadbInstallCommand.php
  7. +1
    -2
      app/Commands/NginxInstallCommand.php

+ 2
- 2
app/Commands/Fail2banDisableCommand.php View File

@ -12,7 +12,7 @@ use LaravelZero\Framework\Commands\Command;
* @author Björn Hase, Tentakelfabrik * @author Björn Hase, Tentakelfabrik
* @license http://opensource.org/licenses/MIT The MIT License * @license http://opensource.org/licenses/MIT The MIT License
* @link https://gitea.tentakelfabrik.de/Tentakelfabrik/mcp * @link https://gitea.tentakelfabrik.de/Tentakelfabrik/mcp
*
*
*/ */
class Fail2banDisableCommand extends Command class Fail2banDisableCommand extends Command
{ {
@ -56,7 +56,7 @@ class Fail2banDisableCommand extends Command
unlink(self::DESTINATION_FAIL2BAN_JAIL_DIRECTORY.'/'.$configuration.'.conf'); unlink(self::DESTINATION_FAIL2BAN_JAIL_DIRECTORY.'/'.$configuration.'.conf');
exec('service fail2ban restart');
system('service fail2ban restart');
$this->info('Fail2ban...'.$configuration.' disabled'); $this->info('Fail2ban...'.$configuration.' disabled');
} }
} }

+ 2
- 2
app/Commands/Fail2banEnableCommand.php View File

@ -12,7 +12,7 @@ use LaravelZero\Framework\Commands\Command;
* @author Björn Hase, Tentakelfabrik * @author Björn Hase, Tentakelfabrik
* @license http://opensource.org/licenses/MIT The MIT License * @license http://opensource.org/licenses/MIT The MIT License
* @link https://gitea.tentakelfabrik.de/Tentakelfabrik/mcp * @link https://gitea.tentakelfabrik.de/Tentakelfabrik/mcp
*
*
*/ */
class Fail2banEnableCommand extends Command class Fail2banEnableCommand extends Command
{ {
@ -63,7 +63,7 @@ class Fail2banEnableCommand extends Command
} }
copy($source, $destination); copy($source, $destination);
exec('service fail2ban restart');
system('service fail2ban restart');
$this->info('Fail2ban...'.$configuration.' enabled'); $this->info('Fail2ban...'.$configuration.' enabled');
} }


+ 2
- 3
app/Commands/LetsEncryptAddCommand.php View File

@ -46,14 +46,13 @@ class LetsEncryptAddCommand extends Command
// add file for domain // add file for domain
$saved = []; $saved = [];
// create flags
// create flags
foreach($domains as $domain) { foreach($domains as $domain) {
$domainFlags .= '-d '.$domain.' '; $domainFlags .= '-d '.$domain.' ';
$saved[$domain] = '/etc/letsencrypt/live/'.$domain.'/fullchain.pem'; $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) { foreach($saved as $domain => $file) {
if (file_exists($file)) { if (file_exists($file)) {


+ 1
- 4
app/Commands/LetsEncryptInstallCommand.php View File

@ -65,10 +65,7 @@ class LetsEncryptInstallCommand extends Command
$output = []; $output = [];
$this->info('LetsEncrypt generate dhparam.pem...'); $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')) { if (Install::isReady('certbot')) {
$this->info('LetsEncrypt installing...Success! \o/'); $this->info('LetsEncrypt installing...Success! \o/');


+ 2
- 2
app/Commands/LetsEncryptRemoveCommand.php View File

@ -63,9 +63,9 @@ class LetsEncryptRemoveCommand extends Command
$errors++; $errors++;
} else { } else {
if (is_file($directory)) { if (is_file($directory)) {
exec('rm '.$directory.' 2>&1', $output);
system('rm '.$directory.' 2>&1');
} else { } else {
exec('rm -rf '.$directory.' 2>&1', $output);
system('rm -rf '.$directory.' 2>&1');
} }
} }
} }


+ 7
- 7
app/Commands/MariadbInstallCommand.php View File

@ -98,25 +98,25 @@ class MariadbInstallCommand extends Command
// 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...'); $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 // delete anonymous user
$this->info('Mariadb 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 // drop test database and anthing familiar
$this->info('Mariadb drop test 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 // remove plugin for root and set password
$this->info('Mariadb add password for root...'); $this->info('Mariadb add password for root...');
if ($version === '10.4') { 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 { } 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); file_put_contents(self::MCP_LOG_FILE, "Mariadb installed\nuser: root\npassword: $password\n--\n", FILE_APPEND);


+ 1
- 2
app/Commands/NginxInstallCommand.php View File

@ -77,8 +77,7 @@ class NginxInstallCommand extends Command
$output = []; $output = [];
$this->info('Nginx adding ufw rules...'); $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/'); $this->info('Nginx installing...Success! \o/');
} else { } else {


Loading…
Cancel
Save