diff --git a/app/Livewire/Ui/Security/ClamavManager.php b/app/Livewire/Ui/Security/ClamavManager.php index bb7fedb..a22ffc5 100644 --- a/app/Livewire/Ui/Security/ClamavManager.php +++ b/app/Livewire/Ui/Security/ClamavManager.php @@ -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) { diff --git a/resources/views/livewire/ui/security/clamav-manager.blade.php b/resources/views/livewire/ui/security/clamav-manager.blade.php index 7a403fa..aa6c834 100644 --- a/resources/views/livewire/ui/security/clamav-manager.blade.php +++ b/resources/views/livewire/ui/security/clamav-manager.blade.php @@ -43,17 +43,20 @@ @if(!$installed)
clamav clamav-daemon ist nicht verfügbar.clamav clamav-daemon fehlt.apt install clamav clamav-daemon -y
-