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.

58 lines
1.2 KiB

  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 LetsEncryptRemoveCommand extends Command
  11. {
  12. const CERT_DIR = '/etc/certbot/';
  13. /**
  14. * The signature of the command.
  15. *
  16. * @var string
  17. */
  18. protected $signature = 'lets-encrypt:remove {domain*}';
  19. /**
  20. * The description of the command.
  21. *
  22. * @var string
  23. */
  24. protected $description = 'Remove Certificates from LetsEncrypt';
  25. /**
  26. * Execute the console command.
  27. *
  28. * @return mixed
  29. *
  30. */
  31. public function handle()
  32. {
  33. $domains = $this->argument('domain');
  34. foreach($domains as $domain) {
  35. $archive = self::CERT_DIR.'archive/'.$domain;
  36. $live = self::CERT_DIR.'live/'.$domain;
  37. $renewal = self::CERT_DIR.'renewal/'.$domain;
  38. rmdir($archiv);
  39. rmdir($live);
  40. rmdir($renewal);
  41. if (file_exists($archiv) && file_exists($live) && file_exists($renewal)) {
  42. $this->info('Certifikate for '.$domain.' ...deleted!');
  43. } else {
  44. $this->error('Certifikate for '.$domain.' ...not deleted!');
  45. }
  46. }
  47. }
  48. }