v1.0.3
PriviMetrics 2
- <?php
-
- declare(strict_types=1);
-
- if (PHP_SAPI !== 'cli') {
- http_response_code(404);
- exit;
- }
-
- require_once __DIR__ . '/functions.php';
- require_once __DIR__ . '/updater-functions.php';
-
- if (!envIsInstalled()) {
- fwrite(STDERR, "PriviMetrics is not installed.\n");
- exit(1);
- }
- if (env('AUTO_UPDATE', 'false') !== 'true') {
- echo "Automatic updates are disabled.\n";
- exit(0);
- }
-
- try {
- $manifest = pmUpdateManifest();
- if (!$manifest['is_newer']) {
- echo 'Already on the latest version (' . $manifest['version'] . ").\n";
- exit(0);
- }
- $report = pmUpdateRun(true);
- echo 'Updated ' . $report['from'] . ' -> ' . $report['to'] . ', '
- . count($report['modified']) . ' modified, ' . count($report['added']) . ' added. '
- . 'Backup: ' . $report['backup'] . "\n";
- exit(0);
- } catch (PmUpdateException $e) {
- fwrite(STDERR, 'Automatic update failed: ' . $e->getMessage() . "\n");
- exit(1);
- }
-