Changeset 362

Show
Ignore:
Timestamp:
09/15/07 19:54:06 (1 year ago)
Author:
bermiferrer
Message:

Making the setup script more XAMPP friendly. The setup will now try to enable InnoDB in my.cnf which is disabled by default.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/script/setup

    r359 r362  
    6363            if(!is_dir($this->options['directory'])){ 
    6464                if(!$this->_makeDir($this->options['directory'])){ 
    65                        $this->addError("Can't create directory: " . $this->options['directory']); 
    66                        return false; 
     65                    $this->addError("Can't create directory: " . $this->options['directory']); 
     66                    return false; 
    6767                } 
    6868            } 
     
    7575            } 
    7676 
     77            $this->runEvironmentSpecificTasks(); 
     78 
    7779            $this->_linkPublicHtmlFolder(); 
    7880 
     
    8991        $source_test_dir = $this->options['source'].DS.'test'; 
    9092        $test_dir = $this->options['directory'].DS.'test'; 
    91          
     93 
    9294        $this->_makeDir($test_dir); 
    9395        $this->_copyFile($source_test_dir.DS.'app.php'); 
    94          
     96 
    9597        $this->_makeDir($test_dir.DS.'fixtures'); 
    9698        $this->_makeDir($test_dir.DS.'fixtures'.DS.'app'); 
    97          
     99 
    98100        $this->_copyFile($source_test_dir.DS.'fixtures'.DS.'app'.DS.'application_controller.php'); 
    99101        $this->_copyFile($source_test_dir.DS.'fixtures'.DS.'app'.DS.'shared_model.php'); 
    100          
     102 
    101103        $this->_makeDir($test_dir.DS.'fixtures'.DS.'config'); 
    102104        $this->_copyFile($source_test_dir.DS.'fixtures'.DS.'config'.DS.'config.php'); 
     
    195197                $this->yield("    Creating directory: ".$dir); 
    196198                if(!@mkdir($dir)) 
    197                        return false; 
     199                return false; 
    198200            } 
    199201        } 
     
    298300 
    299301 
     302    function runEvironmentSpecificTasks() 
     303    { 
     304        if($evironment = $this->guessEnvironment()){ 
     305            $method_name = 'run'.$evironment.'Tasks'; 
     306            if(method_exists($this, $method_name)){ 
     307                $this->$method_name(); 
     308            } 
     309        } 
     310    } 
     311 
     312    // Environment specific tasks 
     313 
     314    function guessEnvironment() 
     315    { 
     316        if(AK_WINDOWS){ 
     317            if(file_exists('C:/xampp/apache/conf/httpd.conf')){ 
     318                return 'DefaultXamppOnWindows'; 
     319            } 
     320        } 
     321        return false; 
     322    } 
     323 
     324    function runDefaultXamppOnWindowsTasks() 
     325    { 
     326        // XAMPP has mod_rewrite disabled by default so we will try to enable it. 
     327        $http_conf = file_get_contents('C:/xampp/apache/conf/httpd.conf'); 
     328        if(strstr($http_conf, '#LoadModule rewrite_module')){ 
     329            $this->yield('Enabling mod_rewrite'); 
     330            file_put_contents('C:/xampp/apache/conf/httpd.conf.akelos', $http_conf); 
     331            file_put_contents('C:/xampp/apache/conf/httpd.conf', 
     332            str_replace( 
     333            '#LoadModule rewrite_module', 
     334            'LoadModule rewrite_module', 
     335            $http_conf 
     336            )); 
     337 
     338            $this->yield('Restarting Apache'); 
     339            // Stop apache 
     340            exec('C:\xampp\apache\bin\pv -f -k apache.exe -q'); 
     341            exec('rm C:\xampp\apache\logs\httpd.pid'); 
     342 
     343            // Start Apache in the background 
     344            $shell = new COM('WScript.Shell'); 
     345            $shell->Run('C:\xampp\apache\bin\apache.exe', 0, false); 
     346        } 
     347 
     348        $my_cnf = @file_get_contents('C:/xampp/mysql/bin/my.cnf'); 
     349        // InnoDB engine is not enabled by default on XAMPP we need it enabled in order to use transactions 
     350        if(strstr($my_cnf, '#innodb_')){ 
     351            $this->yield('Enabling InnoDB MySQL engine.'); 
     352            file_put_contents('C:/xampp/mysql/bin/my.cnf.akelos', $my_cnf); 
     353            file_put_contents('C:/xampp/mysql/bin/my.cnf', 
     354            str_replace( 
     355            array('skip-innodb', '#innodb_', '#set-variable = innodb'), 
     356            array('#skip-innodb', 'innodb_', 'set-variable = innodb') 
     357            ,$my_cnf)); 
     358 
     359            $this->yield('Restarting MySQL server.'); 
     360            $shell = new COM('WScript.Shell'); 
     361            $shell->Run('C:\xampp\mysql\bin\mysqladmin --user=pma --password= shutdown', 0, false); 
     362            $shell = new COM('WScript.Shell'); 
     363            $shell->Run('C:\xampp\mysql\bin\mysqld --defaults-file=C:\xampp\mysql\bin\my.cnf --standalone --console', 0, false); 
     364        } 
     365    } 
    300366} 
    301367