mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-07 17:02:34 +00:00
@ -3,6 +3,7 @@
|
||||
namespace App\Jobs\Installation;
|
||||
|
||||
use App\Actions\FirewallRule\CreateRule;
|
||||
use App\Enums\ServiceStatus;
|
||||
use App\Jobs\Job;
|
||||
use App\Models\FirewallRule;
|
||||
use App\Models\Service;
|
||||
@ -32,6 +33,9 @@ public function handle(): void
|
||||
$this->downloadSource();
|
||||
$this->setUpVHost();
|
||||
$this->restartPHP();
|
||||
$this->service->update([
|
||||
'status' => ServiceStatus::READY,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -41,7 +45,7 @@ private function setUpFirewall(): void
|
||||
{
|
||||
$this->firewallRule = FirewallRule::query()
|
||||
->where('server_id', $this->service->server_id)
|
||||
->where('port', '54331')
|
||||
->where('port', $this->service->type_data['port'])
|
||||
->first();
|
||||
if ($this->firewallRule) {
|
||||
$this->firewallRule->source = $this->service->type_data['allowed_ip'];
|
||||
@ -52,7 +56,7 @@ private function setUpFirewall(): void
|
||||
[
|
||||
'type' => 'allow',
|
||||
'protocol' => 'tcp',
|
||||
'port' => '54331',
|
||||
'port' => $this->service->type_data['port'],
|
||||
'source' => $this->service->type_data['allowed_ip'],
|
||||
'mask' => '0',
|
||||
]
|
||||
@ -78,6 +82,7 @@ private function setUpVHost(): void
|
||||
{
|
||||
$vhost = File::get(resource_path('commands/webserver/nginx/phpmyadmin-vhost.conf'));
|
||||
$vhost = Str::replace('__php_version__', $this->service->server->defaultService('php')->version, $vhost);
|
||||
$vhost = Str::replace('__port__', $this->service->type_data['port'], $vhost);
|
||||
$this->service->server->ssh()->exec(
|
||||
new CreateNginxPHPMyAdminVHostCommand($vhost),
|
||||
'create-phpmyadmin-vhost'
|
||||
@ -98,6 +103,9 @@ private function restartPHP(): void
|
||||
public function failed(Throwable $throwable): Throwable
|
||||
{
|
||||
$this->firewallRule?->removeFromServer();
|
||||
$this->service->update([
|
||||
'status' => ServiceStatus::INSTALLATION_FAILED,
|
||||
]);
|
||||
throw $throwable;
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ private function removeFirewallRule(): void
|
||||
/** @var ?FirewallRule $rule */
|
||||
$rule = FirewallRule::query()
|
||||
->where('server_id', $this->service->server_id)
|
||||
->where('port', '54331')
|
||||
->where('port', $this->service->type_data['port'])
|
||||
->first();
|
||||
$rule?->removeFromServer();
|
||||
}
|
||||
|
Reference in New Issue
Block a user