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.

console.php 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * @author Bart Visscher <bartv@thisnet.nl>
  4. * @author Christian Kampka <christian@kampka.net>
  5. * @author Morris Jobke <hey@morrisjobke.de>
  6. * @author Thomas Müller <thomas.mueller@tmit.eu>
  7. * @author Vincent Petry <pvince81@owncloud.com>
  8. *
  9. * @copyright Copyright (c) 2015, ownCloud, Inc.
  10. * @license AGPL-3.0
  11. *
  12. * This code is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License, version 3,
  14. * as published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License, version 3,
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>
  23. *
  24. */
  25. use OC\Console\Application;
  26. use Symfony\Component\Console\Output\ConsoleOutput;
  27. define('OC_CONSOLE', 1);
  28. try {
  29. require_once 'lib/base.php';
  30. // set to run indefinitely if needed
  31. set_time_limit(0);
  32. if (!OC::$CLI) {
  33. echo "This script can be run from the command line only" . PHP_EOL;
  34. exit(0);
  35. }
  36. if (!OC_Util::runningOnWindows()) {
  37. if (!function_exists('posix_getuid')) {
  38. echo "The posix extensions are required - see http://php.net/manual/en/book.posix.php" . PHP_EOL;
  39. exit(0);
  40. }
  41. $user = posix_getpwuid(posix_getuid());
  42. $configUser = posix_getpwuid(fileowner(OC::$SERVERROOT . '/config/config.php'));
  43. if ($user['name'] !== $configUser['name']) {
  44. echo "Console has to be executed with the same user as the web server is operated" . PHP_EOL;
  45. echo "Current user: " . $user['name'] . PHP_EOL;
  46. echo "Web server user: " . $configUser['name'] . PHP_EOL;
  47. exit(0);
  48. }
  49. }
  50. $application = new Application(\OC::$server->getConfig());
  51. $application->loadCommands(new ConsoleOutput());
  52. $application->run();
  53. } catch (Exception $ex) {
  54. echo "An unhandled exception has been thrown:" . PHP_EOL;
  55. echo $ex;
  56. exit(1);
  57. }