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.
 
 
 

68 lines
1.6 KiB

<?php
namespace App\Commands;
use Illuminate\Console\Scheduling\Schedule;
use LaravelZero\Framework\Commands\Command;
use Respect\Validation\Validator as v;
use Respect\Validation\Exceptions\NestedValidationException;
/**
* Add LetsEncrypt Certificate
*
*
* @author Björn Hase, Tentakelfabrik
* @license http://opensource.org/licenses/MIT The MIT License
* @link https://gitea.tentakelfabrik.de/Tentakelfabrik/mcp
*
*/
class LetsEncryptAddCommand extends Command
{
/**
* The signature of the command.
*
* @var string
*/
protected $signature = 'lets-encrypt:add {email} {domain}';
/**
* The description of the command.
*
* @var string
*/
protected $description = 'Add Certificates from LetsEncrypt';
/**
* Execute the console command.
*
* @return mixed
*
*/
public function handle()
{
$email = $this->argument('email');
if (!v::email()->validate($email)) {
$this->error('First argument has to be a valid E-Mail! Failed!');
exit();
}
$domain = $this->argument('domain');
// adding flags
$domainFlags = '';
// add file for domain
$saved = [];
system('certbot --non-interactive --agree-tos -m '.$this->argument('email').' --nginx -d '.$domain);
// check for certificate
if (file_exists( '/etc/letsencrypt/live/'.$domain.'/fullchain.pem')) {
$this->info($domain.'...Success!');
} else {
$this->error($domain.'...Failed!');
}
}
}