WebOrbiton
v1.0.0

PriviMetrics 2

37 lines · 955 B
  1. <?php
  2. ​
  3. declare(strict_types=1);
  4. ​
  5. if (PHP_SAPI !== 'cli') {
  6. http_response_code(404);
  7. exit;
  8. }
  9. ​
  10. require_once __DIR__ . '/functions.php';
  11. require_once __DIR__ . '/updater-functions.php';
  12. ​
  13. if (!envIsInstalled()) {
  14. fwrite(STDERR, "PriviMetrics is not installed.\n");
  15. exit(1);
  16. }
  17. if (env('AUTO_UPDATE', 'false') !== 'true') {
  18. echo "Automatic updates are disabled.\n";
  19. exit(0);
  20. }
  21. ​
  22. try {
  23. $manifest = pmUpdateManifest();
  24. if (!$manifest['is_newer']) {
  25. echo 'Already on the latest version (' . $manifest['version'] . ").\n";
  26. exit(0);
  27. }
  28. $report = pmUpdateRun(true);
  29. echo 'Updated ' . $report['from'] . ' -> ' . $report['to'] . ', '
  30. . count($report['modified']) . ' modified, ' . count($report['added']) . ' added. '
  31. . 'Backup: ' . $report['backup'] . "\n";
  32. exit(0);
  33. } catch (PmUpdateException $e) {
  34. fwrite(STDERR, 'Automatic update failed: ' . $e->getMessage() . "\n");
  35. exit(1);
  36. }
  37. ​