Add passfile option to install.php
authorjan <jan@jans-seite.de>
Fri, 5 Oct 2012 21:35:37 +0000 (23:35 +0200)
committerAlexandre Emsenhuber <ialex.wiki@gmail.com>
Sun, 7 Oct 2012 06:15:28 +0000 (08:15 +0200)
Add passfile option to install.php so a file with the password can be used.

Change-Id: Ibf45933971374c90726359cff16617cb37d002fc

maintenance/install.php

index 762bb94..365791e 100644 (file)
@@ -45,7 +45,8 @@ class CommandLineInstaller extends Maintenance {
                $this->addArg( 'name', 'The name of the wiki', true);
 
                $this->addArg( 'admin', 'The username of the wiki administrator (WikiSysop)', true );
-               $this->addOption( 'pass', 'The password for the wiki administrator.', true, true );
+               $this->addOption( 'pass', 'The password for the wiki administrator.', false, true );
+               $this->addOption( 'passfile', 'An alternative way to provide pass option, as the contents of this file', false, true );
                /* $this->addOption( 'email', 'The email for the wiki administrator', false, true ); */
                $this->addOption( 'scriptpath', 'The relative path of the wiki in the web server (/wiki)', false, true );
 
@@ -86,6 +87,19 @@ class CommandLineInstaller extends Maintenance {
                        $this->mOptions['dbpass'] = trim( $dbpass, "\r\n" );
                }
 
+               $passfile = $this->getOption( 'passfile', false );
+               if ( $passfile !== false ) {
+                       wfSuppressWarnings();
+                       $pass = file_get_contents( $passfile );
+                       wfRestoreWarnings();
+                       if ( $pass === false ) {
+                               $this->error( "Couldn't open $passfile", true );
+                       }
+                       $this->mOptions['pass'] = str_replace( array( "\n", "\r" ), "", $pass );
+               } elseif ( $this->getOption( 'pass', false ) === false ) {
+                       $this->error( "You need to provide the option pass or passfile", true );
+               }
+
                $installer =
                        InstallerOverrides::getCliInstaller( $siteName, $adminName, $this->mOptions );