console.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. use Symfony\Component\Console\Application;
  9. try {
  10. require_once 'lib/base.php';
  11. // Don't do anything if ownCloud has not been installed yet
  12. if (!\OC::$server->getConfig()->getSystemValue('installed', false)) {
  13. echo "Console can only be used once ownCloud has been installed" . PHP_EOL;
  14. exit(0);
  15. }
  16. if (!OC::$CLI) {
  17. echo "This script can be run from the command line only" . PHP_EOL;
  18. exit(0);
  19. }
  20. // only load apps if no update is due,
  21. // else only core commands will be available
  22. if (!\OCP\Util::needUpgrade()) {
  23. // load all apps to get all api routes properly setup
  24. OC_App::loadApps();
  25. }
  26. $defaults = new OC_Defaults;
  27. $application = new Application($defaults->getName(), \OC_Util::getVersionString());
  28. require_once 'core/register_command.php';
  29. if (!\OCP\Util::needUpgrade()) {
  30. foreach(OC_App::getAllApps() as $app) {
  31. $file = OC_App::getAppPath($app).'/appinfo/register_command.php';
  32. if(file_exists($file)) {
  33. require $file;
  34. }
  35. }
  36. }
  37. $application->run();
  38. } catch (Exception $ex) {
  39. echo "An unhandled exception has been thrown:" . PHP_EOL;
  40. echo $ex;
  41. }