MediaWiki  REL1_20
install.php
Go to the documentation of this file.
00001 <?php
00024 if ( !function_exists( 'version_compare' ) || ( version_compare( phpversion(), '5.3.2' ) < 0 ) ) {
00025         echo "You are using PHP version " . phpversion() . " but MediaWiki needs PHP 5.3.2 or higher. ABORTING.\n" .
00026         "Check if you have a newer php executable with a different name, such as php5.\n";
00027         die( 1 );
00028 }
00029 
00030 define( 'MW_CONFIG_CALLBACK', 'Installer::overrideConfig' );
00031 define( 'MEDIAWIKI_INSTALL', true );
00032 
00033 require_once( dirname( __DIR__ )."/maintenance/Maintenance.php" );
00034 
00040 class CommandLineInstaller extends Maintenance {
00041         function __construct() {
00042                 parent::__construct();
00043                 global $IP;
00044 
00045                 $this->addArg( 'name', 'The name of the wiki', true);
00046 
00047                 $this->addArg( 'admin', 'The username of the wiki administrator (WikiSysop)', true );
00048                 $this->addOption( 'pass', 'The password for the wiki administrator.', true, true );
00049                 /* $this->addOption( 'email', 'The email for the wiki administrator', false, true ); */
00050                 $this->addOption( 'scriptpath', 'The relative path of the wiki in the web server (/wiki)', false, true );
00051 
00052                 $this->addOption( 'lang', 'The language to use (en)', false, true );
00053                 /* $this->addOption( 'cont-lang', 'The content language (en)', false, true ); */
00054 
00055                 $this->addOption( 'dbtype', 'The type of database (mysql)', false, true );
00056                 $this->addOption( 'dbserver', 'The database host (localhost)', false, true );
00057                 $this->addOption( 'dbport', 'The database port; only for PostgreSQL (5432)', false, true );
00058                 $this->addOption( 'dbname', 'The database name (my_wiki)', false, true );
00059                 $this->addOption( 'dbpath', 'The path for the SQLite DB (/var/data)', false, true );
00060                 $this->addOption( 'dbprefix', 'Optional database table name prefix', false, true );
00061                 $this->addOption( 'installdbuser', 'The user to use for installing (root)', false, true );
00062                 $this->addOption( 'installdbpass', 'The pasword for the DB user to install as.', false, true );
00063                 $this->addOption( 'dbuser', 'The user to use for normal operations (wikiuser)', false, true );
00064                 $this->addOption( 'dbpass', 'The pasword for the DB user for normal operations', false, true );
00065                 $this->addOption( 'dbpassfile', 'An alternative way to provide dbpass option, as the contents of this file', false, true );
00066                 $this->addOption( 'confpath', "Path to write LocalSettings.php to, default $IP", false, true );
00067                 /* $this->addOption( 'dbschema', 'The schema for the MediaWiki DB in pg (mediawiki)', false, true ); */
00068                 /* $this->addOption( 'namespace', 'The project namespace (same as the name)', false, true ); */
00069                 $this->addOption( 'env-checks', "Run environment checks only, don't change anything" );
00070         }
00071 
00072         function execute() {
00073                 global $IP, $wgTitle;
00074                 $siteName = isset( $this->mArgs[0] ) ? $this->mArgs[0] : "Don't care"; // Will not be set if used with --env-checks
00075                 $adminName = isset( $this->mArgs[1] ) ? $this->mArgs[1] : null;
00076                 $wgTitle = Title::newFromText( 'Installer script' );
00077 
00078                 $dbpassfile = $this->getOption( 'dbpassfile', false );
00079                 if ( $dbpassfile !== false ) {
00080                         wfSuppressWarnings();
00081                         $dbpass = file_get_contents( $dbpassfile );
00082                         wfRestoreWarnings();
00083                         if ( $dbpass === false ) {
00084                                 $this->error( "Couldn't open $dbpassfile", true );
00085                         }
00086                         $this->mOptions['dbpass'] = trim( $dbpass, "\r\n" );
00087                 }
00088 
00089                 $installer =
00090                         InstallerOverrides::getCliInstaller( $siteName, $adminName, $this->mOptions );
00091 
00092                 $status = $installer->doEnvironmentChecks();
00093                 if( $status->isGood() ) {
00094                         $installer->showMessage( 'config-env-good' );
00095                 } else {
00096                         $installer->showStatusMessage( $status );
00097                         return;
00098                 }
00099                 if( !$this->hasOption( 'env-checks' ) ) {
00100                         $installer->execute();
00101                         $installer->writeConfigurationFile( $this->getOption( 'confpath', $IP ) );
00102                 }
00103         }
00104 
00105         function validateParamsAndArgs() {
00106                 if ( !$this->hasOption( 'env-checks' ) ) {
00107                         parent::validateParamsAndArgs();
00108                 }
00109         }
00110 }
00111 
00112 $maintClass = "CommandLineInstaller";
00113 
00114 require_once( RUN_MAINTENANCE_IF_MAIN );