console.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. // load all apps to get all api routes properly setup
  21. OC_App::loadApps();
  22. $defaults = new OC_Defaults;
  23. $application = new Application($defaults->getName(), \OC_Util::getVersionString());
  24. require_once 'core/register_command.php';
  25. foreach(OC_App::getAllApps() as $app) {
  26. $file = OC_App::getAppPath($app).'/appinfo/register_command.php';
  27. if(file_exists($file)) {
  28. require $file;
  29. }
  30. }
  31. $application->run();
  32. } catch (Exception $ex) {
  33. echo "An unhandled exception has been thrown:" . PHP_EOL;
  34. echo $ex;
  35. }