OpenSource CLI-App to install and handle stuff related to Web-Server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

62 lines
1.5 KiB

<?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');
system('service fail2ban restart');
$this->info('Fail2ban...'.$configuration.' disabled');
}
}