示例#1
0
 public function testChmodRecursive()
 {
     if (substr(PHP_OS, 0, 3) == 'WIN') {
         $this->markTestSkipped("chmod may not work for Windows");
     }
     $permsBefore = 0700;
     $expected = 0777;
     $this->assertEquals($permsBefore, fileperms($this->_dir) & $permsBefore, "Wrong permissions set for " . $this->_dir);
     $this->assertEquals($permsBefore, fileperms($this->_file) & $permsBefore, "Wrong permissions set for " . $this->_file);
     Varien_Io_File::chmodRecursive($this->_dir, $expected);
     $this->assertEquals($expected, fileperms($this->_dir) & $expected, "Directory permissions were changed incorrectly.");
     $this->assertEquals($expected, fileperms($this->_file) & $expected, "File permissions were changed incorrectly.");
 }
示例#2
0
 /**
  * Update permissions for `var` directory
  */
 protected function _updateFilesystemPermissions()
 {
     Varien_Io_File::chmodRecursive(Mage::getBaseDir('var'), 0777);
 }
示例#3
0
 /**
  * Install Magento
  *
  * @param array $options
  * @return string|boolean
  */
 public function install(array $options)
 {
     try {
         $options = $this->_getInstallOptions($options);
         if (!$options) {
             return false;
         }
         /**
          * Check if already installed
          */
         if (Mage::isInstalled()) {
             $this->addError('ERROR: Magento is already installed.');
             return false;
         }
         /**
          * Skip URL validation, if set
          */
         $this->_getDataModel()->setSkipUrlValidation($options['skip_url_validation']);
         $this->_getDataModel()->setSkipBaseUrlValidation($options['skip_url_validation']);
         /**
          * Locale settings
          */
         $this->_getDataModel()->setLocaleData(array('locale' => $options['locale'], 'timezone' => $options['timezone'], 'currency' => $options['default_currency']));
         /**
          * Database and web config
          */
         $this->_getDataModel()->setConfigData(array('db_model' => $options['db_model'], 'db_host' => $options['db_host'], 'db_name' => $options['db_name'], 'db_user' => $options['db_user'], 'db_pass' => $options['db_pass'], 'db_prefix' => $options['db_prefix'], 'use_rewrites' => $this->_getFlagValue($options['use_rewrites']), 'use_secure' => $this->_getFlagValue($options['use_secure']), 'unsecure_base_url' => $options['url'], 'secure_base_url' => $options['secure_base_url'], 'use_secure_admin' => $this->_getFlagValue($options['use_secure_admin']), 'session_save' => $this->_checkSessionSave($options['session_save']), 'backend_frontname' => $this->_checkBackendFrontname($options['backend_frontname']), 'admin_no_form_key' => $this->_getFlagValue($options['admin_no_form_key']), 'skip_url_validation' => $this->_getFlagValue($options['skip_url_validation']), 'enable_charts' => $this->_getFlagValue($options['enable_charts']), 'order_increment_prefix' => $options['order_increment_prefix']));
         /**
          * Primary admin user
          */
         $this->_getDataModel()->setAdminData(array('firstname' => $options['admin_firstname'], 'lastname' => $options['admin_lastname'], 'email' => $options['admin_email'], 'username' => $options['admin_username'], 'new_password' => $options['admin_password']));
         $installer = $this->_getInstaller();
         /**
          * Install configuration
          */
         $installer->installConfig($this->_getDataModel()->getConfigData());
         if (!empty($options['cleanup_database'])) {
             $this->_cleanUpDatabase();
         }
         if ($this->hasErrors()) {
             return false;
         }
         /**
          * Install database
          */
         $installer->installDb();
         if ($this->hasErrors()) {
             return false;
         }
         // apply data updates
         Mage_Core_Model_Resource_Setup::applyAllDataUpdates();
         /**
          * Validate entered data for administrator user
          */
         $user = $installer->validateAndPrepareAdministrator($this->_getDataModel()->getAdminData());
         if ($this->hasErrors()) {
             return false;
         }
         /**
          * Prepare encryption key and validate it
          */
         $encryptionKey = empty($options['encryption_key']) ? $this->generateEncryptionKey() : $options['encryption_key'];
         $this->_getDataModel()->setEncryptionKey($encryptionKey);
         $installer->validateEncryptionKey($encryptionKey);
         if ($this->hasErrors()) {
             return false;
         }
         /**
          * Create primary administrator user
          */
         $installer->createAdministrator($user);
         if ($this->hasErrors()) {
             return false;
         }
         /**
          * Save encryption key or create if empty
          */
         $installer->installEnryptionKey($encryptionKey);
         if ($this->hasErrors()) {
             return false;
         }
         /**
          * Installation finish
          */
         $installer->finish();
         if ($this->hasErrors()) {
             return false;
         }
         /**
          * Change directories mode to be writable by apache user
          */
         Varien_Io_File::chmodRecursive(Mage::getBaseDir('var'), 0777);
         return $encryptionKey;
     } catch (Exception $e) {
         $this->addError('ERROR: ' . $e->getMessage());
         return false;
     }
 }