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.

65 lines
1.5 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
4 years ago
  1. <?php
  2. namespace App\Commands;
  3. use Illuminate\Console\Scheduling\Schedule;
  4. use LaravelZero\Framework\Commands\Command;
  5. /**
  6. * Add LetsEncrypt Certificate
  7. *
  8. *
  9. * @author Björn Hase, Tentakelfabrik
  10. * @license http://opensource.org/licenses/MIT The MIT License
  11. * @link https://gitea.tentakelfabrik.de/Tentakelfabrik/mcp
  12. *
  13. */
  14. class LetsEncryptAddCommand extends Command
  15. {
  16. /**
  17. * The signature of the command.
  18. *
  19. * @var string
  20. */
  21. protected $signature = 'lets-encrypt:add {email} {domain*} ';
  22. /**
  23. * The description of the command.
  24. *
  25. * @var string
  26. */
  27. protected $description = 'Add Certificates from LetsEncrypt';
  28. /**
  29. * Execute the console command.
  30. *
  31. * @return mixed
  32. *
  33. */
  34. public function handle()
  35. {
  36. $domains = $this->argument('domain');
  37. // adding flags
  38. $domainFlags = '';
  39. // add file for domain
  40. $saved = [];
  41. // create flags
  42. foreach($domains as $domain) {
  43. $domainFlags .= '-d '.$domain.' ';
  44. $saved[$domain] = '/etc/letsencrypt/live/'.$domain.'/fullchain.pem';
  45. }
  46. system('certbot --non-interactive --agree-tos -m '.$this->argument('email').' --nginx '.$domainFlags);
  47. foreach($saved as $domain => $file) {
  48. if (file_exists($file)) {
  49. $this->info($domain.'...Success!');
  50. } else {
  51. $this->error($domain.'...Failed!');
  52. }
  53. }
  54. }
  55. }