diff --git a/app/Console/Commands/CheckUpdates.php b/app/Console/Commands/CheckUpdates.php index 1c3c0df..b87d756 100644 --- a/app/Console/Commands/CheckUpdates.php +++ b/app/Console/Commands/CheckUpdates.php @@ -24,25 +24,27 @@ 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 + // --check-only via exec() (shell_exec kann auf manchen Servern deaktiviert sein) $fetched = false; if (file_exists($updateBin) && str_contains((string) @file_get_contents($updateBin), '--check-only')) { - $result = @shell_exec('sudo -n ' . escapeshellarg($updateBin) . ' --check-only 2>/dev/null'); - $fetched = ($result !== null); + @exec('sudo -n ' . escapeshellarg($updateBin) . ' --check-only 2>/dev/null', $_, $rc); + $fetched = ($rc === 0); } if (!$fetched && file_exists($fetchHelper)) { - @shell_exec('sudo -n ' . escapeshellarg($fetchHelper) . ' 2>/dev/null'); + @exec('sudo -n ' . escapeshellarg($fetchHelper) . ' 2>/dev/null'); } - // Version_remote wurde von einem der Helfer geschrieben; frisch genug wenn < 2h alt + // version_remote von Helfer geschrieben; als frisch wenn < 2h alt $remoteFile = '/var/lib/mailwolt/version_remote'; $remoteRaw = ''; if (file_exists($remoteFile) && (time() - filemtime($remoteFile)) < 7200) { $remoteRaw = trim((string) file_get_contents($remoteFile)); } - $latestTagRaw = $remoteRaw !== '' ? $remoteRaw - : trim((string) shell_exec("git -C " . escapeshellarg($appPath) . " tag -l 'v*' --sort=-v:refname 2>/dev/null | head -n1")); + // Fallback: lokale Tags (funktioniert nur wenn Tags lokal vorhanden) + $out = []; + @exec("git -C " . escapeshellarg($appPath) . " tag -l 'v*' --sort=-v:refname 2>/dev/null", $out); + $latestTagRaw = $remoteRaw !== '' ? $remoteRaw : trim($out[0] ?? ''); $latestNorm = $this->normalizeVersion($latestTagRaw);