runScript.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * Convenience maintenance script wrapper, useful for scripts
  4. * or extensions located outside of standard locations.
  5. *
  6. * To use, give the maintenance script as a relative or full path.
  7. *
  8. * Example usage:
  9. *
  10. * If your pwd is mediawiki base folder:
  11. * php maintenance/runScript.php extensions/Wikibase/lib/maintenance/dispatchChanges.php
  12. *
  13. * If your pwd is maintenance folder:
  14. * php runScript.php ../extensions/Wikibase/lib/maintenance/dispatchChanges.php
  15. *
  16. * Or full path:
  17. * php /var/www/mediawiki/maintenance/runScript.php maintenance/runJobs.php
  18. *
  19. * This program is free software; you can redistribute it and/or modify
  20. * it under the terms of the GNU General Public License as published by
  21. * the Free Software Foundation; either version 2 of the License, or
  22. * (at your option) any later version.
  23. *
  24. * This program is distributed in the hope that it will be useful,
  25. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  27. * GNU General Public License for more details.
  28. *
  29. * You should have received a copy of the GNU General Public License along
  30. * with this program; if not, write to the Free Software Foundation, Inc.,
  31. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  32. * http://www.gnu.org/copyleft/gpl.html
  33. *
  34. * @author Katie Filbert < aude.wiki@gmail.com >
  35. * @file
  36. * @ingroup Maintenance
  37. */
  38. $IP = getenv( 'MW_INSTALL_PATH' );
  39. if ( $IP === false ) {
  40. $IP = dirname( __DIR__ );
  41. putenv( "MW_INSTALL_PATH=$IP" );
  42. }
  43. require_once "$IP/maintenance/Maintenance.php";
  44. if ( !isset( $argv[1] ) ) {
  45. fwrite( STDERR, "This script requires a maintainance script as an argument.\n"
  46. . "Usage: runScript.php extensions/Wikibase/lib/maintenance/dispatchChanges\n" );
  47. exit( 1 );
  48. }
  49. $scriptFilename = $argv[1];
  50. array_shift( $argv );
  51. $scriptFile = realpath( $scriptFilename );
  52. if ( !$scriptFile ) {
  53. fwrite( STDERR, "The MediaWiki script file \"{$scriptFilename}\" does not exist.\n" );
  54. exit( 1 );
  55. }
  56. require_once $scriptFile;