<?php
							 | 
						|
								
							 | 
						|
								namespace App\Commands;
							 | 
						|
								
							 | 
						|
								use Illuminate\Console\Scheduling\Schedule;
							 | 
						|
								use LaravelZero\Framework\Commands\Command;
							 | 
						|
								
							 | 
						|
								use App\Facades\Install;
							 | 
						|
								
							 | 
						|
								/**
							 | 
						|
								 *  Install LetsEncrypt
							 | 
						|
								 *
							 | 
						|
								 *  @author Björn Hase, Tentakelfabrik
							 | 
						|
								 *  @license http://opensource.org/licenses/MIT The MIT License
							 | 
						|
								 *  @link https://gitea.tentakelfabrik.de/Tentakelfabrik/mcp
							 | 
						|
								 *
							 | 
						|
								 */
							 | 
						|
								class LetsEncryptInstallCommand extends Command
							 | 
						|
								{
							 | 
						|
								    /**
							 | 
						|
								     * The signature of the command.
							 | 
						|
								     *
							 | 
						|
								     * @var string
							 | 
						|
								     */
							 | 
						|
								    protected $signature = 'lets-encrypt:install';
							 | 
						|
								
							 | 
						|
								    /**
							 | 
						|
								     * The description of the command.
							 | 
						|
								     *
							 | 
						|
								     * @var string
							 | 
						|
								     */
							 | 
						|
								    protected $description = 'Install LetsEncrypt for nginx';
							 | 
						|
								
							 | 
						|
								    /**
							 | 
						|
								     * Execute the console command.
							 | 
						|
								     *
							 | 
						|
								     * @return mixed
							 | 
						|
								     */
							 | 
						|
								    public function handle()
							 | 
						|
								    {
							 | 
						|
								        $this->info('LetsEncrypt installing...');
							 | 
						|
								
							 | 
						|
								        $output = [];
							 | 
						|
								        exec('apt update 2>&1', $output);
							 | 
						|
								        exec('apt install -y software-properties-common 2>&1', $output);
							 | 
						|
								
							 | 
						|
								        // @TODO apt add a Warning for no good, in a later version output will be scanned for helpfull infos
							 | 
						|
								        $this->line(implode("\n", Install::filterAptMessages($output)));
							 | 
						|
								
							 | 
						|
								        $output = [];
							 | 
						|
								        exec('add-apt-repository -y universe 2>&1', $output);
							 | 
						|
								        exec('add-apt-repository -y ppa:certbot/certbot 2>&1', $output);
							 | 
						|
								
							 | 
						|
								        // @TODO apt add a Warning for no good, in a later version output will be scanned for helpfull infos
							 | 
						|
								        $this->line(implode("\n", Install::filterAptMessages($output)));
							 | 
						|
								
							 | 
						|
								        $output = [];
							 | 
						|
								        exec('apt update 2>&1', $output);
							 | 
						|
								        exec('apt install -y certbot python3-certbot-nginx 2>&1', $output);
							 | 
						|
								
							 | 
						|
								        // @TODO apt add a Warning for no good, in a later version output will be scanned for helpfull infos
							 | 
						|
								        $this->line(implode("\n", Install::filterAptMessages($output)));
							 | 
						|
								
							 | 
						|
								        if (Install::isReady('certbot')) {
							 | 
						|
								            $this->info('LetsEncrypt installing...Success! \o/');
							 | 
						|
								        } else {
							 | 
						|
								            $this->error("Failed! Please check log-file!");
							 | 
						|
								        }
							 | 
						|
								    }
							 | 
						|
								}
							 |