MediaWiki  1.23.0
install.php
Go to the documentation of this file.
1 <?php
24 if ( !function_exists( 'version_compare' ) || ( version_compare( phpversion(), '5.3.2' ) < 0 ) ) {
25  require_once dirname( __FILE__ ) . '/../includes/PHPVersionError.php';
26  wfPHPVersionError( 'cli' );
27 }
28 
29 define( 'MW_CONFIG_CALLBACK', 'Installer::overrideConfig' );
30 define( 'MEDIAWIKI_INSTALL', true );
31 
32 require_once dirname( __DIR__ ) . "/maintenance/Maintenance.php";
33 
40  function __construct() {
41  parent::__construct();
42  global $IP;
43 
44  $this->addArg( 'name', 'The name of the wiki', true );
45 
46  $this->addArg( 'admin', 'The username of the wiki administrator (WikiSysop)', true );
47  $this->addOption( 'pass', 'The password for the wiki administrator.', false, true );
48  $this->addOption( 'passfile', 'An alternative way to provide pass option, as the contents of this file', false, true );
49  /* $this->addOption( 'email', 'The email for the wiki administrator', false, true ); */
50  $this->addOption( 'scriptpath', 'The relative path of the wiki in the web server (/wiki)', false, true );
51 
52  $this->addOption( 'lang', 'The language to use (en)', false, true );
53  /* $this->addOption( 'cont-lang', 'The content language (en)', false, true ); */
54 
55  $this->addOption( 'dbtype', 'The type of database (mysql)', false, true );
56  $this->addOption( 'dbserver', 'The database host (localhost)', false, true );
57  $this->addOption( 'dbport', 'The database port; only for PostgreSQL (5432)', false, true );
58  $this->addOption( 'dbname', 'The database name (my_wiki)', false, true );
59  $this->addOption( 'dbpath', 'The path for the SQLite DB (/var/data)', false, true );
60  $this->addOption( 'dbprefix', 'Optional database table name prefix', false, true );
61  $this->addOption( 'installdbuser', 'The user to use for installing (root)', false, true );
62  $this->addOption( 'installdbpass', 'The pasword for the DB user to install as.', false, true );
63  $this->addOption( 'dbuser', 'The user to use for normal operations (wikiuser)', false, true );
64  $this->addOption( 'dbpass', 'The pasword for the DB user for normal operations', false, true );
65  $this->addOption( 'dbpassfile', 'An alternative way to provide dbpass option, as the contents of this file', false, true );
66  $this->addOption( 'confpath', "Path to write LocalSettings.php to, default $IP", false, true );
67  /* $this->addOption( 'dbschema', 'The schema for the MediaWiki DB in pg (mediawiki)', false, true ); */
68  /* $this->addOption( 'namespace', 'The project namespace (same as the name)', false, true ); */
69  $this->addOption( 'env-checks', "Run environment checks only, don't change anything" );
70  }
71 
72  function execute() {
73  global $IP;
74  $siteName = isset( $this->mArgs[0] ) ? $this->mArgs[0] : "Don't care"; // Will not be set if used with --env-checks
75  $adminName = isset( $this->mArgs[1] ) ? $this->mArgs[1] : null;
76 
77  $dbpassfile = $this->getOption( 'dbpassfile', false );
78  if ( $dbpassfile !== false ) {
79  if ( $this->getOption( 'dbpass', false ) !== false ) {
80  $this->error( 'WARNING: You provide the options "dbpass" and "dbpassfile". The content of "dbpassfile" overwrites "dbpass".' );
81  }
83  $dbpass = file_get_contents( $dbpassfile );
85  if ( $dbpass === false ) {
86  $this->error( "Couldn't open $dbpassfile", true );
87  }
88  $this->mOptions['dbpass'] = trim( $dbpass, "\r\n" );
89  }
90 
91  $passfile = $this->getOption( 'passfile', false );
92  if ( $passfile !== false ) {
93  if ( $this->getOption( 'pass', false ) !== false ) {
94  $this->error( 'WARNING: You provide the options "pass" and "passfile". The content of "passfile" overwrites "pass".' );
95  }
97  $pass = file_get_contents( $passfile );
99  if ( $pass === false ) {
100  $this->error( "Couldn't open $passfile", true );
101  }
102  $this->mOptions['pass'] = str_replace( array( "\n", "\r" ), "", $pass );
103  } elseif ( $this->getOption( 'pass', false ) === false ) {
104  $this->error( 'You need to provide the option "pass" or "passfile"', true );
105  }
106 
107  $installer =
108  InstallerOverrides::getCliInstaller( $siteName, $adminName, $this->mOptions );
109 
110  $status = $installer->doEnvironmentChecks();
111  if ( $status->isGood() ) {
112  $installer->showMessage( 'config-env-good' );
113  } else {
114  $installer->showStatusMessage( $status );
115  return;
116  }
117  if ( !$this->hasOption( 'env-checks' ) ) {
118  $installer->execute();
119  $installer->writeConfigurationFile( $this->getOption( 'confpath', $IP ) );
120  }
121  }
122 
124  if ( !$this->hasOption( 'env-checks' ) ) {
125  parent::validateParamsAndArgs();
126  }
127  }
128 }
129 
130 $maintClass = "CommandLineInstaller";
131 
132 require_once RUN_MAINTENANCE_IF_MAIN;
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
$pass
$pass
Definition: UtfNormalGenerate.php:131
Maintenance\addOption
addOption( $name, $description, $required=false, $withArg=false, $shortName=false)
Add a parameter to the script.
Definition: Maintenance.php:169
wfSuppressWarnings
wfSuppressWarnings( $end=false)
Reference-counted warning suppression.
Definition: GlobalFunctions.php:2387
wfPHPVersionError
wfPHPVersionError( $type)
Display something vaguely comprehensible in the event of a totally unrecoverable error.
Definition: PHPVersionError.php:40
RUN_MAINTENANCE_IF_MAIN
require_once RUN_MAINTENANCE_IF_MAIN
Definition: maintenance.txt:50
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: maintenance.txt:39
InstallerOverrides\getCliInstaller
static getCliInstaller( $siteName, $admin=null, array $options=array())
Instantiates and returns an instance of CliInstaller or its descendant classes.
Definition: overrides.php:77
wfRestoreWarnings
wfRestoreWarnings()
Restore error level to previous value.
Definition: GlobalFunctions.php:2417
CommandLineInstaller\validateParamsAndArgs
validateParamsAndArgs()
Run some validation checks on the params, etc.
Definition: install.php:123
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
Maintenance\getOption
getOption( $name, $default=null)
Get an option, or return the default.
Definition: Maintenance.php:191
$maintClass
$maintClass
Definition: install.php:130
Maintenance\addArg
addArg( $arg, $description, $required=true)
Add some args that are needed.
Definition: Maintenance.php:207
CommandLineInstaller\__construct
__construct()
Default constructor.
Definition: install.php:40
Maintenance\error
error( $err, $die=0)
Throw an error to the user.
Definition: Maintenance.php:333
Maintenance\hasOption
hasOption( $name)
Checks to see if a particular param exists.
Definition: Maintenance.php:181
CommandLineInstaller
Maintenance script to install and configure MediaWiki.
Definition: install.php:39
CommandLineInstaller\execute
execute()
Do the actual work.
Definition: install.php:72
$IP
$IP
Definition: WebStart.php:88