Files
coolify/app/Events/DatabaseImportFinished.php
T
Andras Bacsai ab3b3926aa feat: add database import API and Cloudflare DNS management
Queue database imports from upload, S3, or server paths via REST, and
manage Cloudflare DNS records from integration tokens and domain UIs.
2026-09-09 11:14:22 +02:00

35 lines
1.2 KiB
PHP

<?php
namespace App\Events;
use App\Models\Server;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class DatabaseImportFinished
{
use Dispatchable, SerializesModels;
public function __construct(array $data)
{
$commands = [];
if (filled($data['containerName'] ?? null)) {
$commands[] = 'docker rm -f '.escapeshellarg($data['containerName']).' 2>/dev/null || true';
}
if (isSafeTmpPath($data['serverTmpPath'] ?? null)) {
$commands[] = 'rm -f '.escapeshellarg($data['serverTmpPath']).' 2>/dev/null || true';
}
if (filled($data['container'] ?? null)) {
foreach (['containerTmpPath', 'scriptPath'] as $key) {
if (isSafeTmpPath($data[$key] ?? null)) {
$commands[] = 'docker exec '.escapeshellarg($data['container']).' rm -f '.escapeshellarg($data[$key]).' 2>/dev/null || true';
}
}
}
$server = Server::find($data['serverId'] ?? null);
if ($server && $commands !== []) {
instant_remote_process($commands, $server, throwError: false);
}
}
}