<?php
|
|
|
|
namespace App\Commands;
|
|
|
|
use Illuminate\Console\Scheduling\Schedule;
|
|
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
|
|
{
|
|
// destination to jail
|
|
const DESTINATION_FAIL2BAN_JAIL_DIRECTORY = '/etc/fail2ban/jail.d';
|
|
|
|
// source to jail
|
|
const SOURCE_FAIL2BAN_JAIL_DIRECTORY = '/resources/fail2ban/jail.d';
|
|
|
|
/**
|
|
* The signature of the command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'fail2ban:disable {configuration}';
|
|
|
|
/**
|
|
* The description of the command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'disable fail2ban configuration';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function handle()
|
|
{
|
|
// getting configuration
|
|
$configuration = $this->argument('configuration');
|
|
|
|
$source = base_path().self::SOURCE_FAIL2BAN_JAIL_DIRECTORY.'/'.$configuration.'.conf';
|
|
|
|
// configuration not found
|
|
if (!file_exists($source)) {
|
|
$this->error('fail2ban...configuration not found');
|
|
exit();
|
|
}
|
|
|
|
unlink(self::DESTINATION_FAIL2BAN_JAIL_DIRECTORY.'/'.$configuration.'.conf');
|
|
|
|
exec('service fail2ban restart');
|
|
$this->info('Fail2ban...'.$configuration.' disabled');
|
|
}
|
|
}
|