mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-08 01:12:34 +00:00
refactoring
This commit is contained in:
@ -11,7 +11,7 @@ class Ufw extends AbstractFirewall
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function addRule(string $type, string $protocol, int $port, string $source, string $mask): void
|
||||
public function addRule(string $type, string $protocol, int $port, string $source, ?string $mask): void
|
||||
{
|
||||
$this->service->server->ssh()->exec(
|
||||
new AddRuleCommand('ufw', $type, $protocol, $port, $source, $mask),
|
||||
@ -22,7 +22,7 @@ public function addRule(string $type, string $protocol, int $port, string $sourc
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function removeRule(string $type, string $protocol, int $port, string $source, string $mask): void
|
||||
public function removeRule(string $type, string $protocol, int $port, string $source, ?string $mask): void
|
||||
{
|
||||
$this->service->server->ssh()->exec(
|
||||
new RemoveRuleCommand('ufw', $type, $protocol, $port, $source, $mask),
|
||||
|
@ -5,7 +5,6 @@
|
||||
use App\Enums\ServiceStatus;
|
||||
use App\Jobs\PHP\InstallPHPExtension;
|
||||
use App\Jobs\PHP\SetDefaultCli;
|
||||
use App\Jobs\PHP\UpdatePHPSettings;
|
||||
use App\Models\Service;
|
||||
|
||||
class PHP
|
||||
@ -28,9 +27,4 @@ public function installExtension($name): void
|
||||
{
|
||||
dispatch(new InstallPHPExtension($this->service, $name))->onConnection('ssh-long');
|
||||
}
|
||||
|
||||
public function updateSettings(array $settings): void
|
||||
{
|
||||
dispatch(new UpdatePHPSettings($this->service, $settings))->onConnection('ssh-long');
|
||||
}
|
||||
}
|
||||
|
@ -2,11 +2,11 @@
|
||||
|
||||
namespace App\ServiceHandlers\ProcessManager;
|
||||
|
||||
use App\SSHCommands\ProcessManager\Supervisor\CreateWorkerCommand;
|
||||
use App\SSHCommands\ProcessManager\Supervisor\DeleteWorkerCommand;
|
||||
use App\SSHCommands\ProcessManager\Supervisor\RestartWorkerCommand;
|
||||
use App\SSHCommands\ProcessManager\Supervisor\StartWorkerCommand;
|
||||
use App\SSHCommands\ProcessManager\Supervisor\StopWorkerCommand;
|
||||
use App\SSHCommands\Supervisor\CreateWorkerCommand;
|
||||
use App\SSHCommands\Supervisor\DeleteWorkerCommand;
|
||||
use App\SSHCommands\Supervisor\RestartWorkerCommand;
|
||||
use App\SSHCommands\Supervisor\StartWorkerCommand;
|
||||
use App\SSHCommands\Supervisor\StopWorkerCommand;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Str;
|
||||
use Throwable;
|
||||
@ -111,7 +111,7 @@ private function generateConfigFile(
|
||||
int $numprocs,
|
||||
string $logFile
|
||||
): string {
|
||||
$config = File::get(base_path('system/command-templates/supervisor/worker.conf'));
|
||||
$config = File::get(resource_path('commands/supervisor/worker.conf'));
|
||||
$config = Str::replace('__name__', (string) $id, $config);
|
||||
$config = Str::replace('__command__', $command, $config);
|
||||
$config = Str::replace('__user__', $user, $config);
|
||||
|
@ -6,14 +6,14 @@
|
||||
use App\Exceptions\SSLCreationException;
|
||||
use App\Models\Site;
|
||||
use App\Models\Ssl;
|
||||
use App\SSHCommands\ChangeNginxPHPVersionCommand;
|
||||
use App\SSHCommands\CreateCustomSSLCommand;
|
||||
use App\SSHCommands\CreateLetsencryptSSLCommand;
|
||||
use App\SSHCommands\CreateNginxVHostCommand;
|
||||
use App\SSHCommands\DeleteNginxSiteCommand;
|
||||
use App\SSHCommands\RemoveSSLCommand;
|
||||
use App\SSHCommands\UpdateNginxRedirectsCommand;
|
||||
use App\SSHCommands\UpdateNginxVHostCommand;
|
||||
use App\SSHCommands\Nginx\ChangeNginxPHPVersionCommand;
|
||||
use App\SSHCommands\Nginx\CreateNginxVHostCommand;
|
||||
use App\SSHCommands\Nginx\DeleteNginxSiteCommand;
|
||||
use App\SSHCommands\Nginx\UpdateNginxRedirectsCommand;
|
||||
use App\SSHCommands\Nginx\UpdateNginxVHostCommand;
|
||||
use App\SSHCommands\SSL\CreateCustomSSLCommand;
|
||||
use App\SSHCommands\SSL\CreateLetsencryptSSLCommand;
|
||||
use App\SSHCommands\SSL\RemoveSSLCommand;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Str;
|
||||
use Throwable;
|
||||
@ -132,7 +132,7 @@ public function updateRedirects(Site $site, array $redirects): void
|
||||
{
|
||||
$redirectsPlain = '';
|
||||
foreach ($redirects as $redirect) {
|
||||
$rd = File::get(base_path('system/command-templates/nginx/redirect.conf'));
|
||||
$rd = File::get(resource_path('commands/webserver/nginx/redirect.conf'));
|
||||
$rd = Str::replace('__from__', $redirect->from, $rd);
|
||||
$rd = Str::replace('__mode__', $redirect->mode, $rd);
|
||||
$rd = Str::replace('__to__', $redirect->to, $rd);
|
||||
@ -157,20 +157,20 @@ protected function generateVhost(Site $site, bool $noSSL = false): string
|
||||
if ($noSSL) {
|
||||
$ssl = null;
|
||||
}
|
||||
$vhost = File::get(base_path('system/command-templates/nginx/vhost.conf'));
|
||||
$vhost = File::get(resource_path('commands/webserver/nginx/vhost.conf'));
|
||||
if ($ssl) {
|
||||
$vhost = File::get(base_path('system/command-templates/nginx/vhost-ssl.conf'));
|
||||
$vhost = File::get(resource_path('commands/webserver/nginx/vhost-ssl.conf'));
|
||||
}
|
||||
if ($site->type()->language() === 'php') {
|
||||
$vhost = File::get(base_path('system/command-templates/nginx/php-vhost.conf'));
|
||||
$vhost = File::get(resource_path('commands/webserver/nginx/php-vhost.conf'));
|
||||
if ($ssl) {
|
||||
$vhost = File::get(base_path('system/command-templates/nginx/php-vhost-ssl.conf'));
|
||||
$vhost = File::get(resource_path('commands/webserver/nginx/php-vhost-ssl.conf'));
|
||||
}
|
||||
}
|
||||
if ($site->port) {
|
||||
$vhost = File::get(base_path('system/command-templates/nginx/reverse-vhost.conf'));
|
||||
$vhost = File::get(resource_path('commands/webserver/nginx/reverse-vhost.conf'));
|
||||
if ($ssl) {
|
||||
$vhost = File::get(base_path('system/command-templates/nginx/reverse-vhost-ssl.conf'));
|
||||
$vhost = File::get(resource_path('commands/webserver/nginx/reverse-vhost-ssl.conf'));
|
||||
}
|
||||
$vhost = Str::replace('__port__', (string) $site->port, $vhost);
|
||||
}
|
||||
|
Reference in New Issue
Block a user