From 996c9c19fe16f39aa9428c4849426a13e75fa8a8 Mon Sep 17 00:00:00 2001 From: boban Date: Sun, 26 Apr 2026 10:13:05 +0200 Subject: [PATCH] =?UTF-8?q?Fix:=20Laravel=20Scheduler=20cron=20+=20sudoers?= =?UTF-8?q?=20f=C3=BCr=20--check-only=20+=20CheckUpdates=20Fallback?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ensure_system() installiert /etc/cron.d/mailwolt für schedule:run - sudoers: www-data darf mailwolt-update --check-only aufrufen - CheckUpdates: if/elseif → echter Fallback auf mailwolt-fetch-tags Co-Authored-By: Claude Sonnet 4.6 --- app/Console/Commands/CheckUpdates.php | 10 +++++++--- scripts/update.sh | 9 +++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/Console/Commands/CheckUpdates.php b/app/Console/Commands/CheckUpdates.php index 4b3d8ba..8e54350 100644 --- a/app/Console/Commands/CheckUpdates.php +++ b/app/Console/Commands/CheckUpdates.php @@ -24,10 +24,14 @@ class CheckUpdates extends Command $updateBin = '/usr/local/sbin/mailwolt-update'; $fetchHelper = '/usr/local/sbin/mailwolt-fetch-tags'; + // Beide versuchen — --check-only schreibt version_remote, fetch-tags als Fallback + $fetched = false; if (file_exists($updateBin) && str_contains((string) @file_get_contents($updateBin), '--check-only')) { - shell_exec('sudo -n ' . escapeshellarg($updateBin) . ' --check-only 2>/dev/null'); - } elseif (file_exists($fetchHelper)) { - shell_exec('sudo -n ' . escapeshellarg($fetchHelper) . ' 2>/dev/null'); + $result = @shell_exec('sudo -n ' . escapeshellarg($updateBin) . ' --check-only 2>/dev/null'); + $fetched = ($result !== null); + } + if (!$fetched && file_exists($fetchHelper)) { + @shell_exec('sudo -n ' . escapeshellarg($fetchHelper) . ' 2>/dev/null'); } // Version_remote wurde von einem der Helfer geschrieben; frisch genug wenn < 2h alt diff --git a/scripts/update.sh b/scripts/update.sh index 2863513..a266423 100644 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -166,8 +166,17 @@ ensure_system(){ # Sudoers-Regeln nachrüsten for f in /etc/sudoers.d/mailwolt-certbot /etc/sudoers.d/mailwolt-dkim; do _sudoers_add "$f" 'www-data ALL=(root) NOPASSWD: /usr/local/sbin/mailwolt-fetch-tags' + _sudoers_add "$f" 'www-data ALL=(root) NOPASSWD: /usr/local/sbin/mailwolt-update --check-only' _sudoers_add "$f" 'www-data ALL=(root) NOPASSWD: /usr/bin/openssl x509 -enddate -noout -in /etc/letsencrypt/live/*/fullchain.pem' done + # Laravel Scheduler cron (schedule:run muss jede Minute laufen) + local cron_file="/etc/cron.d/mailwolt" + local cron_line="* * * * * www-data php ${APP_DIR}/artisan schedule:run >> /dev/null 2>&1" + if ! grep -qF "artisan schedule:run" "${cron_file}" 2>/dev/null; then + printf '%s\n' "${cron_line}" > "${cron_file}" + chmod 644 "${cron_file}" + echo "[✓] Laravel Scheduler cron installiert." + fi } # -------- Guards --------------------------------------------------------------