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