fix: able to change localhost's private key

This commit is contained in:
Andras Bacsai
2023-07-25 14:43:49 +02:00
parent 341f64839b
commit 6cd29ad7e4
9 changed files with 142 additions and 121 deletions

View File

@@ -16,16 +16,14 @@ class PrivateKey extends Component
public function checkConnection()
{
try {
$uptime = instant_remote_process(['uptime'], $this->server);
['uptime' => $uptime, 'dockerVersion' => $dockerVersion] = validateServer($this->server);
if ($uptime) {
Toaster::success('Server is reachable with this private key.');
$this->server->settings->is_reachable = true;
$this->server->settings->is_usable = true;
}
if ($dockerVersion) {
Toaster::success('Server is usable for Coolify.');
}
} catch (\Exception $e) {
$this->server->settings->is_reachable = false;
$this->server->settings->is_usable = false;
$this->server->settings->save();
return general_error_handler(customErrorMessage: "Server is not reachable. Reason: {$e->getMessage()}", that: $this);
}
}
@@ -34,9 +32,7 @@ class PrivateKey extends Component
$this->server->update([
'private_key_id' => $private_key_id
]);
// Delete the old ssh mux file to force a new one to be created
Storage::disk('ssh-mux')->delete($this->server->muxFilename());
refreshPrivateKey($this->server->privateKey);
$this->server->refresh();
$this->checkConnection();
}