Fix: ClamAV enable non-blocking – Hintergrund-Start + Poll alle 3s

- enable() startet Dienst via nohup im Hintergrund (kein Request-Timeout)
- $starting=true → wire:poll.3s ruft pollStatus() auf
- Overlay zeigt "ClamAV wird gestartet… lädt Viren-DB / bis 60s"
- pollStatus() erkennt wenn Dienst läuft → Overlay weg, Erfolg-Banner

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
main v1.1.330
boban 2026-04-26 20:44:56 +02:00
parent dc5d8582e1
commit 79b1eeb93c
2 changed files with 29 additions and 9 deletions

View File

@ -19,6 +19,7 @@ class ClamavManager extends Component
public string $lastError = '';
public string $lastSuccess = '';
public bool $installing = false;
public bool $starting = false;
public function mount(): void
{
@ -29,6 +30,7 @@ class ClamavManager extends Component
{
$this->lastError = '';
$this->lastSuccess = '';
$this->starting = false;
$this->running = $this->serviceActive();
$this->enabled = $this->serviceEnabled();
$this->installed = true;
@ -36,6 +38,18 @@ class ClamavManager extends Component
[$this->dbDate, $this->dbVersion] = $this->readDbInfo();
}
public function pollStatus(): void
{
if (!$this->starting) return;
$this->running = $this->serviceActive();
$this->enabled = $this->serviceEnabled();
if ($this->running) {
$this->starting = false;
$this->lastSuccess = 'ClamAV wurde aktiviert und läuft.';
$this->ramMb = $this->readRamMb();
}
}
public function install(): void
{
$this->installing = true;
@ -53,11 +67,11 @@ class ClamavManager extends Component
public function enable(): void
{
[$ok, $msg] = $this->runCmd('enable');
if ($ok) $this->lastSuccess = 'ClamAV wurde aktiviert und gestartet.';
else $this->lastError = $msg;
$this->running = $this->serviceActive();
$this->enabled = $this->serviceEnabled();
$this->lastError = $this->lastSuccess = '';
// Im Hintergrund starten systemctl start kann 30-60s dauern (DB-Laden)
shell_exec('nohup sudo -n /usr/local/sbin/mailwolt-clamav enable > /tmp/mw-clamav-start.log 2>&1 &');
$this->starting = true;
$this->enabled = true; // systemctl enable ist sofort wirksam
}
public function disable(): void

View File

@ -1,7 +1,7 @@
<x-slot:breadcrumbParent>Sicherheit</x-slot:breadcrumbParent>
<x-slot:breadcrumb>Virenschutz</x-slot:breadcrumb>
<div>
<div @if($starting) wire:poll.3s="pollStatus" @endif>
<div class="mbx-page-header">
<div class="mbx-page-title">
@ -39,12 +39,18 @@
{{-- Status-Karte --}}
<div class="mbx-section" style="position:relative">
<div wire:loading wire:target="enable,disable,install" style="position:absolute;inset:0;background:rgba(0,0,0,.45);border-radius:11px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;z-index:10">
<div wire:loading wire:target="disable,install" style="position:absolute;inset:0;background:rgba(0,0,0,.45);border-radius:11px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;z-index:10">
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" style="color:#a78bfa;animation:spin 1s linear infinite"><path d="M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>
<span style="font-size:12.5px;color:#e2d9fa;font-weight:500" wire:loading wire:target="enable">ClamAV wird gestartet…</span>
<span style="font-size:12.5px;color:#e2d9fa;font-weight:500" wire:loading wire:target="disable">ClamAV wird gestoppt…</span>
<span style="font-size:12.5px;color:#e2d9fa;font-weight:500" wire:loading wire:target="install">ClamAV wird installiert…</span>
<span style="font-size:12.5px;color:#e2d9fa;font-weight:500" wire:loading wire:target="install">ClamAV wird installiert… (ca. 1 Min.)</span>
</div>
@if($starting)
<div style="position:absolute;inset:0;background:rgba(0,0,0,.45);border-radius:11px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;z-index:10">
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" style="color:#a78bfa;animation:spin 1s linear infinite"><path d="M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>
<span style="font-size:12.5px;color:#e2d9fa;font-weight:500">ClamAV wird gestartet… (lädt Viren-DB)</span>
<span style="font-size:11px;color:rgba(226,217,250,.6)">Das kann bis zu 60 Sekunden dauern</span>
</div>
@endif
<div class="mbx-domain-head">
<div class="mbx-domain-info">
<span class="mbx-badge-mute">Status</span>