Read upgrade status file via SSH from localhost server

The status file is on the host filesystem, not inside the container.
Use instant_remote_process() to read the file via SSH to Server::find(0).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Andras Bacsai
2025-12-12 21:20:35 +01:00
parent 3cc416a806
commit f0d6ae289c

View File

@@ -3,6 +3,7 @@
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Models\Server;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;
use OpenApi\Attributes as OA;
@@ -234,13 +235,25 @@ class OtherController extends Controller
return response()->json(['message' => 'You are not allowed to view upgrade status.'], 403);
}
$statusFile = '/data/coolify/source/.upgrade-status';
if (! file_exists($statusFile)) {
$server = Server::find(0);
if (! $server) {
return response()->json(['status' => 'none']);
}
$statusFile = '/data/coolify/source/.upgrade-status';
// Read status file from localhost via SSH
try {
$content = instant_remote_process(
["cat {$statusFile} 2>/dev/null || echo ''"],
$server,
false
);
$content = trim($content ?? '');
} catch (\Exception $e) {
return response()->json(['status' => 'none']);
}
$content = trim(file_get_contents($statusFile));
if (empty($content)) {
return response()->json(['status' => 'none']);
}