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.
 
 
 

59 lines
1.3 KiB

<?php
namespace App\Commands;
use Illuminate\Console\Scheduling\Schedule;
use LaravelZero\Framework\Commands\Command;
use Log;
/**
*
*
*
*/
class Fail2banEnableCommand extends Command
{
const FAIL2BAN_JAIL_DIRECTORY = '/etc/fail2ban/jail.d';
const RESOURCES_JAIL_DIRECTORY = '/resources/fail2ban/jail.d';
/**
* The signature of the command.
*
* @var string
*/
protected $signature = 'fail2ban:enable {configuration}';
/**
* The description of the command.
*
* @var string
*/
protected $description = 'enable fail2ban configuration';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
// getting configuration
$configuration = $this->argument('configuration');
$source = base_path().self::RESOURCES_JAIL_DIRECTORY.'/'.$configuration.'.conf';
// configuration not found
if (!file_exists($source)) {
$this->error('fail2ban...configuration not found');
exit();
}
$destination = self::FAIL2BAN_JAIL_DIRECTORY.'/'.$configuration.'.conf';
copy($source, $destination);
$this->info('fail2ban...'.$configuration.' enabled');
exec('service fail2ban restart');
}
}