Fix: ClamAV wird beim Update automatisch installiert, UI nur Ein/Aus

ensure_system() installiert clamav-daemon falls nicht vorhanden,
deaktiviert aber den Dienst. User sieht nur noch Ein/Ausschalten.
Install-Button, $installed-Property und install()-Methode entfernt.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
main v1.1.340
boban 2026-04-26 21:19:26 +02:00
parent fa65bc1c2e
commit ce66a84c8d
3 changed files with 11 additions and 39 deletions

View File

@ -10,7 +10,6 @@ use Livewire\Component;
#[Title('Virenschutz · Mailwolt')] #[Title('Virenschutz · Mailwolt')]
class ClamavManager extends Component class ClamavManager extends Component
{ {
public bool $installed = false;
public bool $running = false; public bool $running = false;
public bool $enabled = false; public bool $enabled = false;
public string $dbDate = '—'; public string $dbDate = '—';
@ -18,7 +17,6 @@ class ClamavManager extends Component
public ?int $ramMb = null; public ?int $ramMb = null;
public string $lastError = ''; public string $lastError = '';
public string $lastSuccess = ''; public string $lastSuccess = '';
public bool $installing = false;
public bool $starting = false; public bool $starting = false;
public int $startSecs = 0; public int $startSecs = 0;
@ -52,26 +50,10 @@ class ClamavManager extends Component
$this->lastSuccess = ''; $this->lastSuccess = '';
$this->running = $this->serviceActive(); $this->running = $this->serviceActive();
$this->enabled = $this->serviceEnabled(); $this->enabled = $this->serviceEnabled();
$this->installed = $this->isInstalled();
$this->ramMb = $this->running ? $this->readRamMb() : null; $this->ramMb = $this->running ? $this->readRamMb() : null;
[$this->dbDate, $this->dbVersion] = $this->readDbInfo(); [$this->dbDate, $this->dbVersion] = $this->readDbInfo();
} }
public function install(): void
{
$this->installing = true;
$out = [];
@exec('sudo -n /usr/local/sbin/mailwolt-clamav install 2>&1', $out, $rc);
$this->installing = false;
if ($rc !== 0) {
$this->lastError = implode(' ', $out) ?: 'Installation fehlgeschlagen.';
} else {
$this->dispatch('toast', type: 'success', badge: 'ClamAV',
title: 'Installiert', text: 'ClamAV wurde installiert. Sie können ihn jetzt aktivieren.');
}
$this->refresh();
}
public function enable(): void public function enable(): void
{ {
$this->lastError = ''; $this->lastError = '';

View File

@ -47,26 +47,6 @@
</div> </div>
<div style="padding:16px 18px"> <div style="padding:16px 18px">
@if(!$installed)
<div style="display:flex;flex-direction:column;gap:14px">
<div style="display:flex;align-items:center;justify-content:space-between;padding:12px 14px;background:var(--mw-bg4);border:1px solid var(--mw-b2);border-radius:8px">
<div style="display:flex;align-items:center;gap:10px">
<div style="width:8px;height:8px;border-radius:50%;background:#6b7280;flex-shrink:0"></div>
<div>
<div style="font-size:13px;font-weight:500;color:var(--mw-t2)">ClamAV nicht installiert</div>
<div style="font-size:11.5px;color:var(--mw-t4);margin-top:2px">Paket <code style="font-size:11px;background:var(--mw-bg3);padding:1px 5px;border-radius:4px">clamav clamav-daemon</code> fehlt.</div>
</div>
</div>
<button wire:click="install" wire:loading.attr="disabled" wire:target="install"
class="mbx-btn-primary">
<svg width="12" height="12" viewBox="0 0 14 14" fill="none" wire:loading.class="animate-spin" wire:target="install"><path d="M7 1v8M4 6l3 3 3-3" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"/><path d="M2 11h10" stroke="currentColor" stroke-width="1.3" stroke-linecap="round"/></svg>
<span wire:loading.remove wire:target="install">Installieren</span>
<span wire:loading wire:target="install">Installiert… (ca. 1 Min.)</span>
</button>
</div>
</div>
@else
<div style="display:flex;flex-direction:column;gap:16px"> <div style="display:flex;flex-direction:column;gap:16px">
{{-- Status-Zeile --}} {{-- Status-Zeile --}}
@ -137,7 +117,6 @@
</div> </div>
</div> </div>
@endif
</div> </div>
</div> </div>

View File

@ -253,6 +253,17 @@ UNIT
systemctl start mailwolt-ws systemctl start mailwolt-ws
echo "[✓] mailwolt-ws Service gestartet." echo "[✓] mailwolt-ws Service gestartet."
fi fi
# ClamAV installieren falls nicht vorhanden (läuft deaktiviert, User schaltet ein/aus)
if ! dpkg -l clamav-daemon 2>/dev/null | grep -q '^ii'; then
echo "[…] ClamAV wird installiert…"
DEBIAN_FRONTEND=noninteractive apt-get install -y clamav clamav-daemon clamav-freshclam 2>&1 | sed 's/^/ /'
systemctl enable clamav-freshclam 2>/dev/null || true
systemctl start clamav-freshclam 2>/dev/null || true
systemctl disable clamav-daemon 2>/dev/null || true
systemctl stop clamav-daemon 2>/dev/null || true
echo "[✓] ClamAV installiert (deaktiviert User kann es einschalten)."
fi
} }
# -------- Guards -------------------------------------------------------------- # -------- Guards --------------------------------------------------------------