This commit is contained in:
Andras Bacsai
2023-06-16 13:13:09 +02:00
parent 793cae1dfa
commit 0123ae97a1
8 changed files with 46 additions and 25 deletions

View File

@@ -5,12 +5,27 @@ namespace App\Http\Livewire\Server;
use App\Models\Server;
use Illuminate\Support\Facades\Storage;
use Livewire\Component;
use Masmerise\Toaster\Toaster;
class PrivateKey extends Component
{
public Server $server;
public $privateKeys;
public $parameters;
public function checkConnection()
{
try {
$uptime = instant_remote_process(['uptime'], $this->server, false);
if ($uptime) {
Toaster::success('Server is reachable with this private key.');
} else {
Toaster::error('Server is NOT reachable with this private key.');
}
} catch (\Exception $e) {
return general_error_handler(err: $e, that: $this);
}
}
public function setPrivateKey($private_key_id)
{
$this->server->update([
@@ -18,8 +33,9 @@ class PrivateKey extends Component
]);
// Delete the old ssh mux file to force a new one to be created
Storage::disk('ssh-mux')->delete("{$this->server->first()->ip}_{$this->server->first()->port}_{$this->server->first()->user}");
Storage::disk('ssh-mux')->delete($this->server->muxFilename());
$this->server->refresh();
$this->checkConnection();
}
public function mount()
{