use blade as conmmands template (#444)

* use blade as conmmands template

* fix lint

* fix ssl
This commit is contained in:
Saeed Vaziry
2025-01-27 21:27:58 +01:00
committed by GitHub
parent a73476c1dd
commit cdbde063f0
208 changed files with 1080 additions and 1012 deletions

View File

@ -3,7 +3,10 @@
namespace App\SiteTypes;
use App\Exceptions\FailedToDeployGitKey;
use App\Exceptions\SSHError;
use App\Models\Site;
use App\SSH\Services\PHP\PHP;
use Illuminate\Support\Str;
abstract class AbstractSiteType implements SiteType
{
@ -14,6 +17,26 @@ public function __construct(Site $site)
$this->site = $site;
}
public function createRules(array $input): array
{
return [];
}
public function createFields(array $input): array
{
return [];
}
public function data(array $input): array
{
return [];
}
public function editRules(array $input): array
{
return [];
}
protected function progress(int $percentage): void
{
$this->site->progress = $percentage;
@ -22,6 +45,7 @@ protected function progress(int $percentage): void
/**
* @throws FailedToDeployGitKey
* @throws SSHError
*/
protected function deployKey(): void
{
@ -35,4 +59,31 @@ protected function deployKey(): void
$this->site->ssh_key
);
}
/**
* @throws SSHError
*/
protected function isolate(): void
{
if (! $this->site->isIsolated()) {
return;
}
$this->site->server->os()->createIsolatedUser(
$this->site->user,
Str::random(15),
$this->site->id
);
// Generate the FPM pool
if ($this->site->php_version) {
/** @var PHP $php */
$php = $this->site->php()->handler();
$php->createFpmPool(
$this->site->user,
$this->site->php_version,
$this->site->id
);
}
}
}

View File

@ -3,6 +3,7 @@
namespace App\SiteTypes;
use App\Enums\SiteFeature;
use App\Exceptions\SSHError;
use App\SSH\Services\Webserver\Webserver;
use Illuminate\Validation\Rule;
@ -41,9 +42,12 @@ public function data(array $input): array
return [];
}
/**
* @throws SSHError
*/
public function install(): void
{
$this->site->isolate();
$this->isolate();
/** @var Webserver $webserver */
$webserver = $this->site->server->webserver()->handler();

View File

@ -3,6 +3,7 @@
namespace App\SiteTypes;
use App\Enums\SiteFeature;
use App\Exceptions\SSHError;
use App\SSH\Services\Webserver\Webserver;
use Illuminate\Validation\Rule;
@ -41,9 +42,12 @@ public function data(array $input): array
];
}
/**
* @throws SSHError
*/
public function install(): void
{
$this->site->isolate();
$this->isolate();
/** @var Webserver $webserver */
$webserver = $this->site->server->webserver()->handler();

View File

@ -4,6 +4,7 @@
use App\Enums\SiteFeature;
use App\Exceptions\FailedToDeployGitKey;
use App\Exceptions\SSHError;
use App\SSH\Composer\Composer;
use App\SSH\Git\Git;
use App\SSH\Services\Webserver\Webserver;
@ -73,10 +74,11 @@ public function data(array $input): array
/**
* @throws FailedToDeployGitKey
* @throws SSHError
*/
public function install(): void
{
$this->site->isolate();
$this->isolate();
/** @var Webserver $webserver */
$webserver = $this->site->server->webserver()->handler();

View File

@ -6,8 +6,10 @@
use App\Actions\Database\CreateDatabaseUser;
use App\Actions\Database\LinkUser;
use App\Enums\SiteFeature;
use App\Exceptions\SSHError;
use App\Models\Database;
use App\Models\DatabaseUser;
use App\SSH\Services\Webserver\Webserver;
use Closure;
use Illuminate\Validation\Rule;
@ -82,9 +84,12 @@ public function data(array $input): array
];
}
/**
* @throws SSHError
*/
public function install(): void
{
$this->site->isolate();
$this->isolate();
/** @var Webserver $webserver */
$webserver = $this->site->server->webserver()->handler();