3 use Drush\Log\LogLevel;
8 function drush_core_site_install_version($profile, array $additional_form_options = array()) {
9 require_once DRUSH_DRUPAL_CORE . '/includes/install.core.inc';
10 $class_loader = drush_drupal_load_autoloader(DRUPAL_ROOT);
12 if (!isset($profile)) {
13 // If there is an installation profile that acts as a distribution, use that
15 $install_state = array('interactive' => FALSE) + install_state_defaults();
17 install_begin_request($class_loader, $install_state);
18 $profile = _install_select_profile($install_state);
20 catch (\Exception $e) {
21 // This is only a best effort to provide a better default, no harm done
24 if (empty($profile)) {
25 $profile = 'standard';
29 $sql = drush_sql_get_class();
30 $db_spec = $sql->db_spec();
32 $account_name = drush_get_option('account-name', 'admin');
33 $account_pass = drush_get_option('account-pass', FALSE);
34 $show_password = drush_get_option('show-passwords', !$account_pass);
36 $account_pass = drush_generate_password();
39 'parameters' => array(
40 'profile' => $profile,
41 'langcode' => drush_get_option('locale', 'en'),
44 'install_settings_form' => array(
45 'driver' => $db_spec['driver'],
46 $db_spec['driver'] => $db_spec,
47 'op' => dt('Save and continue'),
49 'install_configure_form' => array(
50 'site_name' => drush_get_option('site-name', 'Site-Install'),
51 'site_mail' => drush_get_option('site-mail', 'admin@example.com'),
53 'name' => $account_name,
54 'mail' => drush_get_option('account-mail', 'admin@example.com'),
56 'pass1' => $account_pass,
57 'pass2' => $account_pass,
60 'enable_update_status_module' => TRUE,
61 'enable_update_status_emails' => TRUE,
62 'clean_url' => drush_get_option('clean-url', TRUE),
63 'op' => dt('Save and continue'),
68 // Merge in the additional options.
69 foreach ($additional_form_options as $key => $value) {
70 $current = &$settings['forms'];
71 foreach (explode('.', $key) as $param) {
72 $current = &$current[$param];
77 $msg = 'Starting Drupal installation. This takes a while.';
78 if (is_null(drush_get_option('notify'))) {
79 $msg .= ' Consider using the --notify global option.';
81 drush_log(dt($msg), LogLevel::OK);
82 drush_op('install_drupal', $class_loader, $settings);
84 drush_log(dt('Installation complete. User name: @name User password: @pass', array('@name' => $account_name, '@pass' => $account_pass)), LogLevel::OK);
87 drush_log(dt('Installation complete.'), LogLevel::OK);