mirror of
https://github.com/PhyreApps/PhyrePanel.git
synced 2024-11-22 07:30:25 +00:00
update
This commit is contained in:
parent
02da12b234
commit
0c699059f5
5 changed files with 76 additions and 3 deletions
|
@ -13,7 +13,16 @@ return new class extends Migration
|
|||
{
|
||||
Schema::create('lets_encrypt_certificates', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->bigInteger('domain_ssl_certificate_id');
|
||||
$table->string('domain')->nullable();
|
||||
$table->string('email')->nullable();
|
||||
$table->longText('certificate')->nullable();
|
||||
$table->longText('private_key')->nullable();
|
||||
$table->longText('chain')->nullable();
|
||||
$table->longText('fullchain')->nullable();
|
||||
$table->string('expires_at')->nullable();
|
||||
$table->string('status')->nullable();
|
||||
$table->bigInteger('domain_id')->nullable();
|
||||
$table->bigInteger('domain_ssl_certificate_id')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -33,7 +33,13 @@ class LetsEncryptCertificateResource extends Resource
|
|||
->searchable()
|
||||
->options(
|
||||
Domain::get()->pluck('domain', 'id')->toArray()
|
||||
),
|
||||
)->columnSpanFull(),
|
||||
|
||||
Forms\Components\TextInput::make('email')
|
||||
->label('Email')
|
||||
->required()
|
||||
->email()
|
||||
->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,19 +2,57 @@
|
|||
|
||||
namespace Modules\LetsEncrypt\Models;
|
||||
|
||||
use App\Jobs\ApacheBuild;
|
||||
use App\Models\Domain;
|
||||
use App\Models\DomainSslCertificate;
|
||||
use App\Models\HostingSubscription;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Modules\LetsEncrypt\Jobs\LetsEncryptSecureDomain;
|
||||
|
||||
class LetsEncryptCertificate extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'domain_id',
|
||||
'email',
|
||||
];
|
||||
|
||||
public static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::creating(function ($model) {
|
||||
dd($model);
|
||||
|
||||
$findDomain = Domain::where('id', $model->domain_id)->first();
|
||||
if (!$findDomain) {
|
||||
throw new \Exception('Domain not found');
|
||||
}
|
||||
|
||||
$findSSL = DomainSslCertificate::where('domain', $findDomain->domain)->first();
|
||||
if ($findSSL) {
|
||||
throw new \Exception('SSL already exists');
|
||||
}
|
||||
|
||||
$findHostingSubscription = HostingSubscription::where('id', $findDomain->hosting_subscription_id)->first();
|
||||
if (!$findHostingSubscription) {
|
||||
throw new \Exception('Hosting subscription not found');
|
||||
}
|
||||
|
||||
$secureDomain = new LetsEncryptSecureDomain($findDomain->id);
|
||||
$secureDomain->handle();
|
||||
|
||||
ApacheBuild::dispatchSync();
|
||||
|
||||
$findSSL = DomainSslCertificate::where('domain', $findDomain->domain)->first();
|
||||
if ($findSSL) {
|
||||
$model->domain_ssl_certificate_id = $findSSL->id;
|
||||
$model->certificate = $findSSL->certificate;
|
||||
$model->private_key = $findSSL->private_key;
|
||||
$model->certificate_chain = $findSSL->certificate_chain;
|
||||
$model->expires_at = $findSSL->expiration_date;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
18
web/Modules/LetsEncrypt/PostInstall.php
Normal file
18
web/Modules/LetsEncrypt/PostInstall.php
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace Modules\LetsEncrypt;
|
||||
|
||||
use App\ModulePostInstall;
|
||||
|
||||
class PostInstall extends ModulePostInstall
|
||||
{
|
||||
public $supportLog = true;
|
||||
public function run()
|
||||
{
|
||||
$installDockerShellFile = base_path('Modules/LetsEncrypt/shell/install-letsencrypt.sh');
|
||||
|
||||
shell_exec("chmod +x $installDockerShellFile");
|
||||
shell_exec("bash $installDockerShellFile >> $this->logFile &");
|
||||
|
||||
}
|
||||
}
|
2
web/Modules/LetsEncrypt/shell/install-letsencrypt.sh
Normal file
2
web/Modules/LetsEncrypt/shell/install-letsencrypt.sh
Normal file
|
@ -0,0 +1,2 @@
|
|||
# install certbot
|
||||
sudo apt-get install certbot -y
|
Loading…
Reference in a new issue