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.

55 lines
1.2 KiB

4 years ago
  1. <?php
  2. namespace App\Commands;
  3. use Illuminate\Console\Scheduling\Schedule;
  4. use LaravelZero\Framework\Commands\Command;
  5. /**
  6. *
  7. *
  8. *
  9. */
  10. class Fail2banDisableCommand extends Command
  11. {
  12. const FAIL2BAN_JAIL_DIRECTORY = '/etc/fail2ban/jail.d';
  13. const RESOURCES_JAIL_DIRECTORY = '/resources/fail2ban/jail.d';
  14. /**
  15. * The signature of the command.
  16. *
  17. * @var string
  18. */
  19. protected $signature = 'fail2ban:disable {configuration}';
  20. /**
  21. * The description of the command.
  22. *
  23. * @var string
  24. */
  25. protected $description = 'disable fail2ban configuration';
  26. /**
  27. * Execute the console command.
  28. *
  29. * @return mixed
  30. */
  31. public function handle()
  32. {
  33. // getting configuration
  34. $configuration = $this->argument('configuration');
  35. $source = base_path().self::RESOURCES_JAIL_DIRECTORY.'/'.$configuration.'.conf';
  36. // configuration not found
  37. if (!file_exists($source)) {
  38. $this->error('fail2ban...configuration not found');
  39. exit();
  40. }
  41. unlink(self::FAIL2BAN_JAIL_DIRECTORY.'/'.$configuration.'.conf');
  42. exec('service fail2ban restart');
  43. $this->info('fail2ban...'.$configuration.' disabled');
  44. }
  45. }