Add Servers and PrivateKeys
Add new testhost Remove privatekey injection from Dockerfile
This commit is contained in:
@@ -64,12 +64,14 @@ class RunRemoteProcess
|
||||
{
|
||||
$user = $this->activity->getExtraProperty('user');
|
||||
$destination = $this->activity->getExtraProperty('destination');
|
||||
$private_key_location = $this->activity->getExtraProperty('private_key_location');
|
||||
$port = $this->activity->getExtraProperty('port');
|
||||
$command = $this->activity->getExtraProperty('command');
|
||||
|
||||
$delimiter = 'EOF-COOLIFY-SSH';
|
||||
|
||||
return 'ssh '
|
||||
$ssh_command = "ssh "
|
||||
. "-i {$private_key_location} "
|
||||
. '-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null '
|
||||
. '-o PasswordAuthentication=no '
|
||||
. '-o RequestTTY=no '
|
||||
@@ -78,6 +80,7 @@ class RunRemoteProcess
|
||||
. " 'bash -se' << \\$delimiter" . PHP_EOL
|
||||
. $command . PHP_EOL
|
||||
. $delimiter;
|
||||
return $ssh_command;
|
||||
}
|
||||
|
||||
protected function handleOutput(string $type, string $output)
|
||||
|
||||
@@ -10,6 +10,7 @@ class RemoteProcessArgs extends Data
|
||||
{
|
||||
public function __construct(
|
||||
public string $destination,
|
||||
public string $private_key_location,
|
||||
public string $command,
|
||||
public int $port,
|
||||
public string $user,
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use App\Models\Server;
|
||||
use Livewire\Component;
|
||||
|
||||
class RunCommand extends Component
|
||||
@@ -16,6 +17,12 @@ class RunCommand extends Component
|
||||
|
||||
public $server = 'testing-host';
|
||||
|
||||
public $servers = [];
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->servers = Server::all()->pluck('name')->toArray();
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.run-command');
|
||||
|
||||
@@ -31,5 +31,6 @@ class ExecuteRemoteProcess implements ShouldQueue
|
||||
]);
|
||||
|
||||
$remoteProcess();
|
||||
// @TODO: Remove file at $this->activity->getExtraProperty('private_key_location') after process is finished
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,13 @@ namespace App\Models;
|
||||
|
||||
class PrivateKey extends BaseModel
|
||||
{
|
||||
public function private_key_morph()
|
||||
public function private_keyables()
|
||||
{
|
||||
return $this->morphTo();
|
||||
return $this->hasMany(PrivateKeyable::class);
|
||||
}
|
||||
|
||||
public function servers()
|
||||
{
|
||||
return $this->morphedByMany(Server::class, 'private_keyable');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ namespace App\Models;
|
||||
|
||||
class Server extends BaseModel
|
||||
{
|
||||
public function private_key()
|
||||
public function privateKeys()
|
||||
{
|
||||
return $this->morphMany(PrivateKey::class, 'private_key_morph');
|
||||
return $this->morphToMany(PrivateKey::class, 'private_keyable');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user