2023-05-03 10:38:57 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Livewire\Server;
|
|
|
|
|
|
|
|
use App\Models\PrivateKey as ModelsPrivateKey;
|
|
|
|
use App\Models\Server;
|
|
|
|
use Illuminate\Support\Facades\Route;
|
2023-05-16 09:39:18 +00:00
|
|
|
use Illuminate\Support\Facades\Storage;
|
2023-05-03 10:38:57 +00:00
|
|
|
use Livewire\Component;
|
|
|
|
|
|
|
|
class PrivateKey extends Component
|
|
|
|
{
|
|
|
|
public $private_keys;
|
|
|
|
public $parameters;
|
|
|
|
public function setPrivateKey($private_key_id)
|
|
|
|
{
|
2023-05-16 09:39:18 +00:00
|
|
|
$server = Server::where('uuid', $this->parameters['server_uuid']);
|
|
|
|
$server->update([
|
2023-05-03 10:38:57 +00:00
|
|
|
'private_key_id' => $private_key_id
|
|
|
|
]);
|
2023-05-16 09:39:18 +00:00
|
|
|
// Delete the old ssh mux file to force a new one to be created
|
|
|
|
Storage::disk('local')->delete(".ssh/ssh_mux_{$server->first()->ip}_{$server->first()->port}_{$server->first()->user}");
|
|
|
|
|
2023-05-03 10:38:57 +00:00
|
|
|
return redirect()->route('server.show', $this->parameters['server_uuid']);
|
|
|
|
}
|
|
|
|
public function mount()
|
|
|
|
{
|
2023-05-24 12:26:50 +00:00
|
|
|
$this->parameters = get_parameters();
|
2023-05-03 10:38:57 +00:00
|
|
|
$this->private_keys = ModelsPrivateKey::where('team_id', session('currentTeam')->id)->get();
|
|
|
|
}
|
|
|
|
}
|