'$refresh', ]; public function init(bool $install = true) { $this->install = $install; $this->uptime = null; $this->supported_os_type = null; $this->docker_installed = null; $this->docker_version = null; $this->docker_compose_installed = null; $this->proxy_started = null; $this->error = null; $this->number_of_tries = 0; if (!$this->ask) { $this->dispatch('validateConnection'); } } public function startValidatingAfterAsking() { $this->ask = false; $this->init(); } public function startProxy() { try { $shouldStart = CheckProxy::run($this->server); if ($shouldStart) { $proxy = StartProxy::run($this->server, false); if ($proxy === 'OK') { $this->proxy_started = true; } else { throw new \Exception("Proxy could not be started."); } } else { $this->proxy_started = true; } } catch (\Throwable $e) { return handleError($e, $this); } } public function validateConnection() { $this->uptime = $this->server->validateConnection(); if (!$this->uptime) { $this->error = 'Server is not reachable. Please validate your configuration and connection.

Check this documentation for further help.'; return; } $this->dispatch('validateOS'); } public function validateOS() { $this->supported_os_type = $this->server->validateOS(); if (!$this->supported_os_type) { $this->error = 'Server OS type is not supported. Please install Docker manually before continuing: documentation.'; return; } $this->dispatch('validateDockerEngine'); } public function validateDockerEngine() { $this->docker_installed = $this->server->validateDockerEngine(); $this->docker_compose_installed = $this->server->validateDockerCompose(); if (!$this->docker_installed || !$this->docker_compose_installed) { if ($this->install) { if ($this->number_of_tries == $this->max_tries) { $this->error = 'Docker Engine could not be installed. Please install Docker manually before continuing: documentation.'; return; } else { if ($this->number_of_tries == 0) { $activity = $this->server->installDocker(); $this->number_of_tries++; $this->dispatch('newActivityMonitor', $activity->id, 'init'); } return; } } else { $this->error = 'Docker Engine is not installed. Please install Docker manually before continuing: documentation.'; return; } } $this->dispatch('validateDockerVersion'); } public function validateDockerVersion() { if ($this->server->isSwarm()) { $swarmInstalled = $this->server->validateDockerSwarm(); if ($swarmInstalled) { $this->dispatch('success', 'Docker Swarm is initiated.'); } } else { $this->docker_version = $this->server->validateDockerEngineVersion(); if ($this->docker_version) { $this->dispatch('serverInstalled'); $this->dispatch('success', 'Server validated successfully.'); } else { $this->error = 'Docker Engine version is not 22+. Please install Docker manually before continuing: documentation.'; return; } } $this->dispatch('startProxy'); } public function render() { return view('livewire.server.validate-and-install'); } }