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

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