From d5d5fd819c230f52332f64251f127071931fd75a Mon Sep 17 00:00:00 2001 From: boban Date: Thu, 23 Apr 2026 22:24:28 +0200 Subject: [PATCH] Fix: mailwolt-apply-domains Helper + sudoers + Monit aktiviert MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - mailwolt-apply-domains Script im Installer erstellt - sudoers-Eintrag für www-data (certbot + apply-domains ohne Passwort) - Wizard State-Dir Owner www-data - Monit standardmäßig aktiviert (nicht mehr disabled) Co-Authored-By: Claude Sonnet 4.6 --- installer.sh | 106 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 103 insertions(+), 3 deletions(-) diff --git a/installer.sh b/installer.sh index ec23c4f..c471f45 100644 --- a/installer.sh +++ b/installer.sh @@ -557,9 +557,110 @@ fi # ===== Wizard State-Verzeichnis ===== mkdir -p /var/lib/mailwolt/wizard -chown "$APP_USER":"$APP_GROUP" /var/lib/mailwolt/wizard +chown www-data:www-data /var/lib/mailwolt/wizard chmod 775 /var/lib/mailwolt/wizard +# ===== mailwolt-apply-domains Helper ===== +log "mailwolt-apply-domains Helper installieren…" +cat > /usr/local/sbin/mailwolt-apply-domains <<'HELPER' +#!/usr/bin/env bash +set -euo pipefail + +UI_HOST=""; WEBMAIL_HOST=""; MAIL_HOST=""; SSL_AUTO=0 +while [[ $# -gt 0 ]]; do + case "$1" in + --ui-host) UI_HOST="$2"; shift 2 ;; + --webmail-host) WEBMAIL_HOST="$2"; shift 2 ;; + --mail-host) MAIL_HOST="$2"; shift 2 ;; + --ssl-auto) SSL_AUTO="$2"; shift 2 ;; + *) shift ;; + esac +done + +PHPV=$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;') +PHP_FPM_SOCK="/run/php/php${PHPV}-fpm.sock" +[ -S "$PHP_FPM_SOCK" ] || PHP_FPM_SOCK="/run/php/php-fpm.sock" + +APP_DIR="/var/www/mailwolt" +NGINX_SITE="/etc/nginx/sites-available/mailwolt.conf" + +# Alle Server-Namen sammeln +ALL_NAMES="${UI_HOST} ${WEBMAIL_HOST}" + +# Zertifikat-Pfade ermitteln (certbot oder self-signed) +if [ "$SSL_AUTO" = "1" ] && [ -f "/etc/letsencrypt/live/${UI_HOST}/fullchain.pem" ]; then + CERT="/etc/letsencrypt/live/${UI_HOST}/fullchain.pem" + KEY="/etc/letsencrypt/live/${UI_HOST}/privkey.pem" +else + CERT="/etc/mailwolt/ssl/cert.pem" + KEY="/etc/mailwolt/ssl/key.pem" +fi + +cat > "$NGINX_SITE" < /etc/sudoers.d/mailwolt-www <<'SUDOERS' +www-data ALL=(root) NOPASSWD: /usr/bin/certbot +www-data ALL=(root) NOPASSWD: /usr/local/sbin/mailwolt-apply-domains +SUDOERS +chmod 440 /etc/sudoers.d/mailwolt-www + # git safe.directory damit spätere pulls als root möglich sind git config --global --add safe.directory "${APP_DIR}" || true @@ -662,8 +763,7 @@ check process nginx with pidfile /run/nginx.pid if failed port 443 type tcp ssl then restart EOF chmod 600 /etc/monit/monitrc -systemctl disable --now monit || true -apt-mark hold monit >/dev/null 2>&1 || true +systemctl enable --now monit || true # ===== Smoke-Test (alle Ports, mit Timeouts) ===== log "Smoke-Test (Ports & Banner):"