Browse Source

adding

release/0.1
Björn 4 years ago
parent
commit
134bb9846a
9 changed files with 73 additions and 26 deletions
  1. +4
    -1
      app/Commands/Fail2banDisableCommand.php
  2. +5
    -2
      app/Commands/Fail2banEnableCommand.php
  3. +4
    -1
      app/Commands/LetsEncryptAddCommand.php
  4. +15
    -7
      app/Commands/LetsEncryptInstallCommand.php
  5. +4
    -1
      app/Commands/NodejsInstallCommand.php
  6. +4
    -1
      app/Helpers/InstallHelper.php
  7. +3
    -2
      app/Helpers/NginxTemplateHelper.php
  8. +25
    -6
      app/Helpers/NginxVhostHelper.php
  9. +9
    -5
      app/Helpers/TerminalHelper.php

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

@ -9,7 +9,10 @@ use LaravelZero\Framework\Commands\Command;
* Disable Fail2ban Configuration
*
*
*
* @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
{


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

@ -9,7 +9,10 @@ use LaravelZero\Framework\Commands\Command;
* Enable Fail2ban Configuration
*
*
*
* @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
{
@ -61,7 +64,7 @@ class Fail2banEnableCommand extends Command
copy($source, $destination);
exec('service fail2ban restart');
$this->info('Fail2ban...'.$configuration.' enabled');
}
}

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

@ -9,7 +9,10 @@ use LaravelZero\Framework\Commands\Command;
* Add LetsEncrypt Certificate
*
*
*
* @author Björn Hase, Tentakelfabrik
* @license http://opensource.org/licenses/MIT The MIT License
* @link https://gitea.tentakelfabrik.de/Tentakelfabrik/mcp
*
*/
class LetsEncryptAddCommand extends Command
{


+ 15
- 7
app/Commands/LetsEncryptInstallCommand.php View File

@ -5,9 +5,14 @@ namespace App\Commands;
use Illuminate\Console\Scheduling\Schedule;
use LaravelZero\Framework\Commands\Command;
use App\Facades\Install;
/**
* Install LetsEncrypt
*
*
* @author Björn Hase, Tentakelfabrik
* @license http://opensource.org/licenses/MIT The MIT License
* @link https://gitea.tentakelfabrik.de/Tentakelfabrik/mcp
*
*/
class LetsEncryptInstallCommand extends Command
@ -35,12 +40,15 @@ class LetsEncryptInstallCommand extends Command
{
$this->info('LetsEncrypt installing...');
exec('apt update 2>&1');
exec('apt-get install software-properties-common 2>&1');
exec('add-apt-repository universe 2>&1');
exec('add-apt-repository ppa:certbot/certbot 2>&1');
exec('apt-get update 2>&1');
exec('apt-get install certbot python3-certbot-nginx 2>&1');
exec('apt update 2>&1', $output);
exec('apt-get install software-properties-common 2>&1', $output);
exec('add-apt-repository universe 2>&1', $output);
exec('add-apt-repository ppa:certbot/certbot 2>&1', $output);
exec('apt-get update 2>&1', $output);
exec('apt-get install certbot python3-certbot-nginx 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('certbot')) {
$this->info('LetsEncrypt installing...Success! \o/');


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

@ -8,8 +8,11 @@ use LaravelZero\Framework\Commands\Command;
use App\Facades\Install;
/**
* Install Nodejs
*
*
* @author Björn Hase, Tentakelfabrik
* @license http://opensource.org/licenses/MIT The MIT License
* @link https://gitea.tentakelfabrik.de/Tentakelfabrik/mcp
*
*/
class NodejsInstallCommand extends Command


+ 4
- 1
app/Helpers/InstallHelper.php View File

@ -3,9 +3,12 @@
namespace App\Helpers;
/**
* Helper for install
*
* @author Björn Hase, Tentakelfabrik
* @license http://opensource.org/licenses/MIT The MIT License
* @link https://gitea.tentakelfabrik.de/Tentakelfabrik/mcp
*
*
*/
class InstallHelper
{


+ 3
- 2
app/Helpers/NginxTemplateHelper.php View File

@ -3,7 +3,8 @@
namespace App\Helpers;
/**
*
* handle Templates for nginx
*
*
* @author Björn Hase, Tentakelfabrik
* @license http://opensource.org/licenses/MIT The MIT License
@ -62,7 +63,7 @@ class NginxTemplateHelper
}
/**
* find templates
* find templates
*
* @return array
*


+ 25
- 6
app/Helpers/NginxVhostHelper.php View File

@ -3,9 +3,11 @@
namespace App\Helpers;
/**
* hande nginx vhosts
*
*
*
* @author Björn Hase, Tentakelfabrik
* @license http://opensource.org/licenses/MIT The MIT License
* @link https://gitea.tentakelfabrik.de/Tentakelfabrik/mcp
*
*/
class NginxVhostHelper
@ -26,7 +28,7 @@ class NginxVhostHelper
];
/**
*
* get sites that are in sites-available
*
*
* @return array
@ -38,7 +40,7 @@ class NginxVhostHelper
}
/**
*
* get sites that are in sites-enabled
*
*
* @return array
@ -56,6 +58,8 @@ class NginxVhostHelper
* ssl_certificate /etc/letsencrypt/live/<domain>/fullchain.pem;
* ssl_certificate_key /etc/letsencrypt/live/<domain>/privkey.pem;
*
* @param string $filename
*
*/
private function getCertificate($path)
{
@ -72,7 +76,7 @@ class NginxVhostHelper
preg_match(self::REGEX_SSL_CERTIFICATE, $content, $matches);
preg_match(self::REGEX_SSL_CERTIFICATE_KEY, $content, $matches);
// check for ssl certificates
// check ssl certificates
if (count($matches) >= 2) {
$result['ssl'] = true;
@ -80,6 +84,7 @@ class NginxVhostHelper
$result['ssl_certificate_exists'] = true;
}
// getting expired
exec('openssl x509 -noout -dates -in '.$path, $openssl);
if (isset($openssl[1])) {
@ -91,6 +96,13 @@ class NginxVhostHelper
return $result;
}
/**
* get vhost
*
* @param string $filename
* @param array $enabled
* @return array
*/
private function getVhost($filename, $enabled)
{
// getting full path
@ -109,6 +121,12 @@ class NginxVhostHelper
return $result;
}
/**
* find single vhost by filename
*
* @param string $filename
* @return array
*/
public function findOneByFilename($filename)
{
// getting enabled
@ -117,8 +135,9 @@ class NginxVhostHelper
}
/**
* getting vhosts
* find all vhost
*
* @return array
*/
public function find()
{


+ 9
- 5
app/Helpers/TerminalHelper.php View File

@ -3,18 +3,22 @@
namespace App\Helpers;
/**
* Helper for Terminal
*
*
* @author Björn Hase, Tentakelfabrik
* @license http://opensource.org/licenses/MIT The MIT License
* @link https://gitea.tentakelfabrik.de/Tentakelfabrik/mcp
*
*/
class TerminalHelper
{
/**
* show array and create for each confirm
*
* @param object $menu
* @param array $messages
* @param string $text
*
* @param [type] $menu [description]
* @param [type] $messages [description]
* @param string $text [description]
* @return [type] [description]
*/
public function confirmArray($menu, $messages, $text = 'Ok', $field = NULL)
{


Loading…
Cancel
Save