Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.5KB

  1. <?php
  2. /**
  3. * @file util/maintenance.php
  4. */
  5. use Friendica\App;
  6. use Friendica\BaseObject;
  7. use Friendica\Core\Config;
  8. use Friendica\Core\L10n;
  9. require_once 'boot.php';
  10. require_once 'include/dba.php';
  11. $a = new App(dirname(__DIR__));
  12. BaseObject::setApp($a);
  13. @include(".htconfig.php");
  14. $lang = L10n::getBrowserLanguage();
  15. L10n::loadTranslationTable($lang);
  16. dba::connect($db_host, $db_user, $db_pass, $db_data, false);
  17. unset($db_host, $db_user, $db_pass, $db_data);
  18. Config::load();
  19. $maint_mode = 1;
  20. if ($argc > 1) {
  21. $maint_mode = intval($argv[1]);
  22. }
  23. Config::set('system', 'maintenance', $maint_mode);
  24. if ($maint_mode && ($argc > 2)) {
  25. $reason_arr = $argv;
  26. array_shift($reason_arr);
  27. array_shift($reason_arr);
  28. $reason = implode(' ', $reason_arr);
  29. Config::set('system', 'maintenance_reason', $reason);
  30. } else {
  31. Config::set('system', 'maintenance_reason', '');
  32. }
  33. if ($maint_mode) {
  34. $mode_str = "maintenance mode";
  35. } else {
  36. $mode_str = "normal mode";
  37. }
  38. echo "\n\tSystem set in $mode_str\n";
  39. if ($reason != '') {
  40. echo "\tMaintenance reason: $reason\n\n";
  41. } else {
  42. echo "\n";
  43. }
  44. echo "Usage:\n\n";
  45. echo "\tphp {$argv[0]} [1] [Maintenance reason|redirection url]\n";
  46. echo "\t\tSet the system in maintenance mode\n\n";
  47. echo "\t\tIf the optionally entered maintenance reason is an url\n";
  48. echo "\t\tthe visitor is redirected to that page.\n";
  49. echo "\n";
  50. echo "\t\tExamples:\n";
  51. echo "\t\t\tphp {$argv[0]} 1 System upgrade\n";
  52. echo "\t\t\tphp {$argv[0]} 1 http://domain.tld/downtime\n";
  53. echo "\n";
  54. echo "\tphp {$argv[0]} 0\n";
  55. echo "\t\tSet the system in normal mode\n\n";