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 nicht installiert
-
Das Paket clamav clamav-daemon ist nicht verfügbar.
+
+
+
+
+
ClamAV nicht installiert
+
Paket clamav clamav-daemon fehlt.
+
-
-
-
Installation
- apt install clamav clamav-daemon -y -
Nach der Installation diese Seite neu laden.
+
diff --git a/scripts/mailwolt-clamav b/scripts/mailwolt-clamav index ea09923..dbc1fe7 100755 --- a/scripts/mailwolt-clamav +++ b/scripts/mailwolt-clamav @@ -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