type === 'site') { drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_SITE); provision_prepare_environment(); _provision_drupal_create_settings_file(); provision_drupal_push_site(); drush_errors_on(); drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_FULL); } } /** * Implements drush_hook_pre_COMMAND(). */ function drush_provision_drupal_pre_provision_verify() { if (d()->type === 'server') { $config_root = dirname(d()->config_path); provision_file()->create_dir($config_root, dt('Provision configuration root'), 0711); provision_file()->create_dir(d()->config_path, dt('Provision configuration'), 0711); provision_file()->create_dir(d()->clients_path, dt('Provision client home'), 0711); if (d()->name == '@server_master') { provision_file()->create_dir(d()->backup_path, dt('Backup'), 0700); provision_file()->create_dir(d()->include_path, dt('Provision PHP configuration'), 0711); if (!provision_file()->exists(d()->include_path . '/global.inc')->succeed('Global configuration file exists')->status()) { // Create an empty global.inc so the include doesn't fail with // open_basedir restrictions. $config = new Provision_Config_Global_Settings(d()->name); $config->write(); } } else { if (provision_file()->exists(d()->include_path)) { d()->service('http')->sync(d()->include_path); } } } elseif (d()->type === 'platform') { // Create a platform from a makefile, if it doesnt already exist and the makefile does. if (!provision_file()->exists(d()->root)->status() && !empty(d()->makefile)) { drush_log(dt("Platform path does not exist, fetching from drush makefile")); $arguments = array(); $options = array(); // Propagate working-copy args downward. if (drush_get_option('working-copy') || !empty(d()->make_working_copy)) { $options[] = '--working-copy'; } $arguments[] = d()->makefile; $arguments[] = d()->root; // Change current directory to makefile's directory until Drush fixes this bug: https://github.com/drush-ops/drush/issues/2482 // @TODO: Remove this once is committed. chdir(dirname(d()->makefile)); drush_invoke_process('@none', "make", $arguments, $options); if (drush_get_error()) { return drush_set_error("DRUSH_MAKE_FAILED", "Could not download platform using drush make. No platform present"); } } // Re-set the ROOT PATH for Drush. // In cases where we just build the platform Drush would have cleared this value. // See Drush commit 3b74d40b1228f022464b92243c16127eb613c2df drush_set_context('DRUSH_SELECTED_DRUPAL_ROOT', d()->root); drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_ROOT); // If we couldn't bootstrap, there's no sense in continuing past this point. if (drush_get_error()) { $errors = drush_get_error_log(); return drush_set_error("DRUSH_INVALID_DRUPAL_ROOT", dt("Drush could not bootstrap the platform at @path. Please check the platform directory exists and is readable. The errors were: @errors", array( '@path' => d()->root, '@errors' => implode('|', $errors) ))); } provision_file()->writable(d()->root . '/sites') ->succeed('Drupal sites directory @path is writable by the provisioning script') ->fail('Drupal sites directory @path is not writable by the provisioning script', 'PROVISION_SITES_DIR_NOT_WRITABLE'); // Ensure sites.php file exists for Drupal 8 and above. $sitesfile = "sites/sites.php"; if (drush_drupal_major_version() >= 8 && !file_exists($sitesfile)) { if (!drush_op('copy', 'sites/example.sites.php', $sitesfile) && !drush_get_context('DRUSH_SIMULATE')) { return drush_set_error(dt('Failed to copy sites/sites.php to @sitesfile', array('@sitesfile' => $sitesfile))); } } drush_set_option('sites', array_keys((array) provision_drupal_find_sites()), 'drupal'); drush_log(dt("This platform is running @short_name @version", array('@short_name' => 'drupal', '@version' => drush_drupal_version()))); drush_set_option('packages', _scrub_object(provision_find_packages()), 'drupal'); provision_drupal_push_site(); } elseif (d()->type === 'site') { drush_set_option('packages', _scrub_object(provision_drupal_system_map()), 'site'); // This is the actual drupal provisioning requirements. _provision_drupal_create_directories(); _provision_drupal_maintain_aliases(); _provision_drupal_ensure_htaccess_update(); // Requires at least the database settings to complete. _provision_drupal_create_settings_file(); // If this is the hostmaster site, save the ~/.drush/drushrc.php file. if (d()->root == d('@hostmaster')->root && d()->uri == d('@hostmaster')->uri) { $aegir_drushrc = new Provision_Config_Drushrc_Aegir(); $aegir_drushrc->write(); } provision_drupal_push_site(drush_get_option('override_slave_authority', FALSE)); } } /** * Implements drush_hook_provision_post_COMMAND(). */ function drush_provision_drupal_post_provision_verify() { if (d()->type === 'site') { _provision_drupal_rebuild_caches(); drush_set_option('installed', TRUE, 'site'); _provision_client_create_symlink(); drush_include_engine('drupal', 'cron_key'); } }