Feature: ClamAV Installation direkt aus der UI + install-Befehl im Wrapper

- mailwolt-clamav: install) apt-get install clamav clamav-daemon clamav-freshclam
- ClamavManager: install() Methode + $installing State
- Blade: Installieren-Button wenn nicht installiert (statt nur Text-Hinweis)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
main v1.1.325
boban 2026-04-26 20:32:30 +02:00
parent b721b7b0df
commit 6fa77f9f9b
3 changed files with 44 additions and 18 deletions

View File

@ -10,13 +10,14 @@ use Livewire\Component;
#[Title('Virenschutz · Mailwolt')]
class ClamavManager extends Component
{
public bool $installed = false;
public bool $running = false;
public bool $enabled = false;
public string $dbDate = '—';
public string $dbVersion = '—';
public ?int $ramMb = null;
public string $lastError = '';
public bool $installed = false;
public bool $running = false;
public bool $enabled = false;
public string $dbDate = '—';
public string $dbVersion = '—';
public ?int $ramMb = null;
public string $lastError = '';
public bool $installing = false;
public function mount(): void
{
@ -33,6 +34,21 @@ class ClamavManager extends Component
[$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
{
if (!$this->installed) {

View File

@ -43,17 +43,20 @@
@if(!$installed)
<div style="display:flex;flex-direction:column;gap:14px">
<div style="display:flex;align-items:center;gap:10px;padding:12px 14px;background:var(--mw-bg4);border:1px solid var(--mw-b2);border-radius:8px">
<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">Das Paket <code style="font-size:11px;background:var(--mw-bg3);padding:1px 5px;border-radius:4px">clamav clamav-daemon</code> ist nicht verfügbar.</div>
<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>
</div>
<div style="padding:12px 14px;background:var(--mw-bg4);border:1px solid var(--mw-b2);border-radius:8px">
<div style="font-size:12px;font-weight:500;color:var(--mw-t3);margin-bottom:6px">Installation</div>
<code style="font-size:11.5px;color:var(--mw-t2);background:var(--mw-bg3);padding:6px 10px;border-radius:6px;display:block">apt install clamav clamav-daemon -y</code>
<div style="font-size:11.5px;color:var(--mw-t4);margin-top:6px">Nach der Installation diese Seite neu laden.</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>

View File

@ -5,6 +5,13 @@ set -euo pipefail
CMD="${1:-status}"
case "$CMD" in
install)
export DEBIAN_FRONTEND=noninteractive
apt-get install -y clamav clamav-daemon clamav-freshclam 2>&1
systemctl enable clamav-freshclam 2>/dev/null || true
systemctl start clamav-freshclam 2>/dev/null || true
echo "ClamAV installiert."
;;
enable)
systemctl enable clamav-daemon
systemctl start clamav-daemon
@ -25,7 +32,7 @@ case "$CMD" in
systemctl is-active clamav-daemon 2>/dev/null && echo "active" || echo "inactive"
;;
*)
echo "Usage: mailwolt-clamav {enable|disable|freshclam|status}" >&2
echo "Usage: mailwolt-clamav {install|enable|disable|freshclam|status}" >&2
exit 1
;;
esac