diff --git a/app/Console/Commands/WizardDomains.php b/app/Console/Commands/WizardDomains.php index 9ba2980..7ac4775 100644 --- a/app/Console/Commands/WizardDomains.php +++ b/app/Console/Commands/WizardDomains.php @@ -59,7 +59,7 @@ class WizardDomains extends Command // Das Script erstellt erst die Vhosts (mit ACME-Location), dann certbot --webroot $helper = '/usr/local/sbin/mailwolt-apply-domains'; $out = shell_exec(sprintf( - 'sudo -n %s --ui-host %s --webmail-host %s --mail-host %s --ssl-auto %d 2>&1', + 'sudo -n %s --ui-host %s --webmail-host %s --mail-host %s --ssl-auto %d', escapeshellarg($helper), escapeshellarg($ui), escapeshellarg($webmail), @@ -67,31 +67,31 @@ class WizardDomains extends Command $ssl ? 1 : 0, )); - $outStr = (string) $out; - $helperOk = $out !== null - && !str_contains($outStr, '[x]') - && !str_contains($outStr, 'command not found') - && !str_contains($outStr, 'No such file') - && trim($outStr) !== ''; - + // Shell-Script schreibt per-Domain-Status selbst in die State-Dateien. + // Fallback: Domains die noch auf running/pending stehen auf error setzen. foreach (['ui', 'mail', 'webmail'] as $key) { - $status = file_get_contents(self::STATE_DIR . "/{$key}"); + $status = trim((string) @file_get_contents(self::STATE_DIR . "/{$key}")); if ($status === 'running' || $status === 'pending') { - $domain = $domains[$key] ?? ''; - if ($domain && str_contains($outStr, "[!] {$domain}:")) { - file_put_contents(self::STATE_DIR . "/{$key}", 'noipv6'); - } else { - file_put_contents(self::STATE_DIR . "/{$key}", $helperOk ? 'done' : 'error'); - } + file_put_contents(self::STATE_DIR . "/{$key}", 'error'); } } - // Shell-Script schreibt done bereits vor dem nginx-Switch — nicht überschreiben - $alreadyDone = trim((string) @file_get_contents(self::STATE_DIR . '/done')) === '1'; - if (!$alreadyDone) { - file_put_contents(self::STATE_DIR . '/done', $helperOk ? '1' : '0'); + // done-Datei: Shell-Script schreibt "1"/"0"; Fallback wenn Script abstürzte. + $doneVal = trim((string) @file_get_contents(self::STATE_DIR . '/done')); + if ($doneVal === '') { + file_put_contents(self::STATE_DIR . '/done', '0'); + $doneVal = '0'; } - Setting::set('ssl_configured', ($helperOk || $alreadyDone) ? '1' : '0'); + + // ssl_configured anhand tatsächlich ausgestellter LE-Zertifikate bestimmen + $hasAnyCert = false; + foreach ($domains as $domain) { + if ($domain && is_dir("/etc/letsencrypt/live/{$domain}")) { + $hasAnyCert = true; + break; + } + } + Setting::set('ssl_configured', $hasAnyCert ? '1' : '0'); // SESSION_SECURE_COOKIE wird nicht automatisch gesetzt — // nginx leitet HTTP→HTTPS weiter, Secure-Flag wird im Admin gesetzt