Skip to content
Snippets Groups Projects
Select Git revision
  • 186a119d46dc366983a9361183f3168cee1ceee1
  • 7.x-3.x default
  • 7.x-4.x
  • 3353492-drupal-10-support
  • bug/files-import
  • detached
  • release/7.x-4.0-beta2
  • 7.x-5.x
  • 4.2.x
  • feature/no-platforms
  • 7.x-4.x-verify-works
  • 2953349-drush9-composer
  • 4.1.x
  • 4.x-php81
  • feature/php/8.1
  • php81
  • 7.x-4.1.x
  • 3254372-ci_updates_for_focal_and_bullseye
  • 7.x-3.20.x
  • 7.x-3.19.x
  • 2708727-site-install-fail-errors
  • 7.x-4.0-beta19
  • 7.x-4.0-beta18
  • 7.x-4.0-beta17
  • 7.x-4.0-beta16
  • 7.x-4.0-beta15
  • 7.x-4.0-beta14
  • 7.x-4.0-beta13
  • 7.x-4.0-beta12
  • 7.x-4.0-beta11
  • 7.x-4.0-beta10
  • 7.x-4.0-beta9
  • 7.x-4.0-beta8
  • 7.x-4.0-beta7
  • 7.x-4.0-beta6
  • 7.x-4.0-beta5
  • 7.x-4.0-beta4
  • 7.x-4.0-beta3
  • 7.x-4.0-beta2
  • 7.x-4.0-beta1
  • 7.x-3.192
41 results

install.provision.inc

Blame
  • Jon Pugh's avatar
    Issue #2754069: Fixing sites that were breaking because drush option "installed" wasn't being set.
    Jon Pugh authored
    ff393c9d
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    install.provision.inc 4.50 KiB
    <?php
    /**
     * @file
     *   Provision hooks for the provision install command.
     */
    
    /**
     * Provision install command
     *
     * These are the hooks that will be executed by the drush_invoke function
     * when doing a provision_install.
     */
    
    /**
     * Check that we are trying to install a new site , and a new site only
     */
    function drush_provision_drupal_provision_install_validate() {
      if (!d()->uri) {
        return drush_set_error("PROVISION_URL_REQUIRED", dt("You need to specify a valid url to install a site"));
      }
      if (_provision_drupal_site_exists()) {
    
        // If "force-reinstall" option is set, delete the database and files.
        if (drush_get_option('force-reinstall', FALSE)) {
    
          drush_log(dt('Forcing reinstall...'), 'ok');
    
          // Load the current database name from drushrc.php.
          // I cannot find another way to find the current db_name!
          require_once(d()->site_path . '/drushrc.php');
          $old_db_name = $options['db_name'];
    
          if (d()->service('db')->database_exists($old_db_name)) {
            d()->service('db')->drop_database($old_db_name);
            drush_log(dt('Dropped database @database.', array(
              '@database' => $old_db_name,
            )), 'ok');
          }
    
          // Destroy site_path.
          if (file_exists(d()->site_path)) {
            _provision_recursive_delete( d()->site_path );
            drush_log(dt('Deleted @site_path.', array('@site_path' => d()->site_path)), 'ok');
          }
        }
    
        // Check again if site does not exist after the forced reinstall.
        if (_provision_drupal_site_exists()) {
          return drush_set_error('PROVISION_SITE_INSTALLED');
        }
      }
    }
    
    /**
     * Set up the directories and settings.php file that we need.
     */
    function drush_provision_drupal_pre_provision_install() {
      // This is the actual drupal provisioning requirements.
      _provision_drupal_create_directories();
    }
    
    /**
     * If the install went south, and the site is not PROVISION_SITE_INSTALLED, clean up behind ourselves
     */
    function drush_provision_drupal_pre_provision_install_rollback() {
      _provision_recursive_delete( d()->site_path );
      drush_invoke_process('@none', 'provision-save', array(d()->name), array('delete' => TRUE));
      foreach (d()->drush_aliases as $alias) {
        drush_invoke_process('@none', 'provision-save', array($alias), array('delete' => TRUE));
      }
    }
    
    
    /**
     * Install Drupal with the pre-configured settings, by calling an external script
     *
     * This is an external script so that php is running in it's own namespace, and
     * weird problems such as the multiple database connections don't confuse drupal.
     */
    function drush_provision_drupal_provision_install() {
     // Requires at least the database settings to complete.
      provision_prepare_environment();
      _provision_drupal_create_settings_file();
      provision_drupal_push_site($override_slave_authority = TRUE);
    
      provision_save_site_data();
    
      drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_SITE);
    
      // Install site according to install_method.
      drush_log(dt('Installing site with the "!method" method.', array(
        '!method' => d()->install_method,
      )), 'ok');
    
      // Run Drupal installation if option was specified
      if (d()->install_method == 'profile') {
    
        // call a backend task to do the actual installation.
        $result = provision_backend_invoke(d()->name, "provision-install-backend", array(), array('client_email' => drush_get_option('client_email')));
        
        // pass the login link back to the front end.
        drush_set_option('login_link', $result['context']['login_link']);
    
        drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_FULL);
        drush_set_option('profile_installed', TRUE, 'site');
      }
      // If install_method is 'manual', do nothing.
      elseif (d()->install_method == 'manual') {
        drush_set_option('login_link', 'http://' . d()->uri . '/install.php');
      }
      
      drush_set_option('installed', TRUE, 'site');
      _provision_drupal_maintain_aliases();
    
    }
    
    /**
     * Finish the installation, regenerate the caches on the site so that
     * any changes to things such as available modules/ themes can take affect.
     */
    function drush_provision_drupal_post_provision_install() {
    
      // If Drupal profile was installed, rebuild drupal caches and save enabled packages for aegir.
      if (d()->install_method == 'profile' && drush_get_option('profile_installed', FALSE, 'site')) {
        _provision_drupal_rebuild_caches();
        drush_set_option('packages', _scrub_object(provision_drupal_system_map()), 'site');
        _provision_client_create_symlink();
        drush_include_engine('drupal', 'cron_key');
      }
      // For all other install methods, just create the symlink.
      else {
        _provision_client_create_symlink();
      }
    }