update server check

This commit is contained in:
Andras Bacsai 2023-05-03 09:43:01 +02:00
parent ad671cfcf1
commit 581930d8c6
2 changed files with 18 additions and 7 deletions

View File

@ -38,12 +38,20 @@ class Form extends Component
public function checkServer() public function checkServer()
{ {
try { try {
$this->uptime = instantRemoteProcess(['uptime'], $this->server, false);
$this->uptime = instantRemoteProcess(['uptime'], $this->server); if (!$this->uptime) {
$this->uptime = 'Server not reachable.';
throw new \Exception('Server not reachable.');
}
$this->dockerVersion = instantRemoteProcess(['docker version|head -2|grep -i version'], $this->server, false); $this->dockerVersion = instantRemoteProcess(['docker version|head -2|grep -i version'], $this->server, false);
if (!$this->dockerVersion) {
$this->dockerVersion = 'Not installed.';
}
$this->dockerComposeVersion = instantRemoteProcess(['docker compose version|head -2|grep -i version'], $this->server, false); $this->dockerComposeVersion = instantRemoteProcess(['docker compose version|head -2|grep -i version'], $this->server, false);
if (!$this->dockerComposeVersion) {
$this->dockerComposeVersion = 'Not installed.';
}
} catch (\Exception $e) { } catch (\Exception $e) {
$this->addError('server.ip', $e->getMessage());
} }
} }
public function submit() public function submit()

View File

@ -22,14 +22,17 @@
Submit Submit
</button> </button>
<button wire:click.prevent='checkServer'>Check Server</button> <button wire:click.prevent='checkServer'>Check Server</button>
<button wire:click.prevent='installDocker'>Install Docker</button> {{-- <button wire:click.prevent='installDocker'>Install Docker</button> --}}
</div> </div>
</form> </form>
@isset($uptime) @isset($uptime)
<p>Connection OK</p>
<p>Uptime: {{ $uptime }}</p> <p>Uptime: {{ $uptime }}</p>
<p>{{ $dockerVersion }}</p> @endisset
<p>{{ $dockerComposeVersion }}</p> @isset($dockerVersion)
<p>Docker Engine: {{ $dockerVersion }}</p>
@endisset
@isset($dockerComposeVersion)
<p>Docker Compose: {{ $dockerComposeVersion }}</p>
@endisset @endisset
</div> </div>