2025-01-07 13:02:19 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Events;
|
|
|
|
|
|
|
|
|
|
use App\Models\Server;
|
|
|
|
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
|
|
|
|
use Illuminate\Foundation\Events\Dispatchable;
|
|
|
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
|
|
|
|
|
|
class RestoreJobFinished
|
|
|
|
|
{
|
|
|
|
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
|
|
|
|
|
|
|
|
|
public function __construct($data)
|
|
|
|
|
{
|
|
|
|
|
$scriptPath = data_get($data, 'scriptPath');
|
|
|
|
|
$tmpPath = data_get($data, 'tmpPath');
|
|
|
|
|
$container = data_get($data, 'container');
|
|
|
|
|
$serverId = data_get($data, 'serverId');
|
2025-11-17 09:05:18 +00:00
|
|
|
|
|
|
|
|
if (filled($container) && filled($serverId)) {
|
|
|
|
|
$commands = [];
|
|
|
|
|
|
|
|
|
|
if (isSafeTmpPath($scriptPath)) {
|
2025-11-25 15:40:35 +00:00
|
|
|
$commands[] = 'docker exec '.escapeshellarg($container)." sh -c 'rm ".escapeshellarg($scriptPath)." 2>/dev/null || true'";
|
2025-11-17 09:05:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isSafeTmpPath($tmpPath)) {
|
2025-11-25 15:40:35 +00:00
|
|
|
$commands[] = 'docker exec '.escapeshellarg($container)." sh -c 'rm ".escapeshellarg($tmpPath)." 2>/dev/null || true'";
|
2025-11-17 09:05:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! empty($commands)) {
|
2025-11-17 13:13:10 +00:00
|
|
|
$server = Server::find($serverId);
|
|
|
|
|
if ($server) {
|
|
|
|
|
instant_remote_process($commands, $server, throwError: false);
|
|
|
|
|
}
|
2025-01-07 14:31:43 +00:00
|
|
|
}
|
2025-01-07 13:02:19 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|