34 lines
1.5 KiB
PHP
34 lines
1.5 KiB
PHP
<?php
|
|
|
|
use App\Services\OpportunityResourceInstallation;
|
|
use Illuminate\Contracts\Console\Kernel;
|
|
|
|
// Read-only installation readiness; never applies migrations or authenticates an actor.
|
|
require dirname(__DIR__).'/vendor/autoload.php';
|
|
$app = require dirname(__DIR__).'/bootstrap/app.php';
|
|
$app->make(Kernel::class)->bootstrap();
|
|
$db = $app->make('db')->connection();
|
|
$db->beginTransaction();
|
|
try {
|
|
$db->statement('SET TRANSACTION READ ONLY');
|
|
$preview = $app->make(OpportunityResourceInstallation::class)->preview();
|
|
$proofPath = storage_path('app/private/investmoz-v2/opportunity-resources-activation-proof.json');
|
|
$proof = is_file($proofPath) ? json_decode(file_get_contents($proofPath), true, 512, JSON_THROW_ON_ERROR) : [];
|
|
$result = [
|
|
'captured_at' => gmdate('c'),
|
|
'read_only' => $db->selectOne("SELECT current_setting('transaction_read_only') AS value")->value,
|
|
'installed' => $preview['installed'],
|
|
'ready' => $preview['ready'],
|
|
'target' => $preview['target'],
|
|
'current_code_hash' => $preview['code_hash'],
|
|
'proof_code_hash' => $proof['code_hash'] ?? null,
|
|
'code_matches_proof' => ($proof['code_hash'] ?? '') === $preview['code_hash'],
|
|
'backup_date' => $preview['backupDate'],
|
|
'active_writes' => 0,
|
|
];
|
|
file_put_contents(storage_path('app/private/investmoz-v2/opportunity-resources-readiness.json'), json_encode($result, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR));
|
|
echo json_encode($result, JSON_THROW_ON_ERROR).PHP_EOL;
|
|
} finally {
|
|
$db->rollBack();
|
|
}
|