Commit ecede8f1 authored by Steven Jones's avatar Steven Jones Committed by helmo

Issue #1194602 by tstoeckler: Added Support Drupal 8 sites.

parent b0108641
<?php
// $Id$
/**
* @file
* Rebuild all the caches
*/
cache_clear_all();
drush_log(t('Cleared all caches'));
node_types_rebuild();
drush_log(t('Rebuilt node type cache'));
registry_rebuild();
drush_log(t('Rebuilt code registry'));
system_rebuild_theme_data();
drush_log(t('Rebuilt theme cache'));
menu_rebuild();
drush_log(t('Rebuilt menu cache'));
<?php
// Fetch the cron key from the Drupal site and set in a drush context.
drush_set_option('cron_key', variable_get('cron_key', 'drupal'));
\ No newline at end of file
<?php
// $Id$
$new_url = drush_get_option('uri');
$old_url = drush_get_option('uri', 'site');
/**
* @file
* Handle site migration tasks for redeployed sites.
* This is primarily to handle the rename of the sites
* directories.
*/
drush_log(
dt('Changed paths from sites/@old_url to sites/@new_url',
array('@old_url' => $old_url, '@new_url' => $new_url)));
variable_set('file_public_path', "sites/$new_url/files");
variable_set('file_private_path', "sites/$new_url/private/files");
variable_set('file_temporary_path', "sites/$new_url/private/temp");
<?php
global $databases;
if ($db = $databases['default']['default']) {
drush_set_option('db_type', urldecode($db['driver']), 'site');
drush_set_option('db_user', urldecode($db['username']), 'site');
drush_set_option('db_host', urldecode($db['host']), 'site');
drush_set_option('db_passwd', urldecode($db['password']), 'site');
drush_set_option('db_name', urldecode($db['database']), 'site');
drush_set_option('profile', variable_get('install_profile', 'default'), 'site');
$language = language_default();
drush_set_option('language', $language->language, 'site');
}
<?php
/**
* @file
* Rebuild all the caches
*/
$GLOBALS['url'] = d()->uri;
$GLOBALS['profile'] = d()->profile;
$GLOBALS['install_locale'] = d()->language;
$GLOBALS['base_url'] = provision_get_base_url();
define('MAINTENANCE_MODE', 'install');
function install_send_welcome_mail($url, $account, $language, $client_email, $onetime) {
global $base_url;
if ($client_email) {
// Mail one time login URL and instructions.
$from = variable_get('site_mail', ini_get('sendmail_from'));
$mail_params['variables'] = array(
'!username' => $account->name, '!site' => variable_get('site_name', 'Drupal'), '!login_url' => $onetime,
'!uri' => $base_url, '!uri_brief' => preg_replace('!^https?://!', '', $base_url), '!mailto' => $account->mail,
'!date' => format_date(time()), '!login_uri' => url('user', array('absolute' => TRUE)),
'!edit_uri' => url('user/'. $account->uid .'/edit', array('absolute' => TRUE)));
$mail_success = drupal_mail('install', 'welcome-admin', $account->mail, user_preferred_language($account), $mail_params, $from, TRUE);
if ($mail_success) {
drush_log(t('Sent welcome mail to @client', array('@client' => $client_email)), 'message');
}
else {
drush_log(t('Could not send welcome mail to @client', array('@client' => $client_email)));
}
}
}
function install_mail($key, &$message, $params) {
global $profile;
switch ($key) {
case 'welcome-admin':
// allow the profile to override welcome email text
if (file_exists("./profiles/$profile/provision_welcome_mail.inc")) {
require_once "./profiles/$profile/provision_welcome_mail.inc";
$custom = TRUE;
}
elseif (file_exists(dirname(__FILE__) . '/../provision_welcome_mail.inc')) {
/** use the module provided welcome email
* We can not use drupal_get_path here,
* as we are connected to the provisioned site's database
*/
require_once dirname(__FILE__) . '/../provision_welcome_mail.inc';
$custom = TRUE;
}
else {
// last resort use the user-pass mail text
$custom = FALSE;
}
if ($custom) {
$message['subject'] = st($mail['subject'], $params['variables']);
$message['body'][] = st($mail['body'], $params['variables']);
}
else {
$message['subject'] = _user_mail_text('pass_subject', $params['variables']);
$message['body'][] = _user_mail_text('pass_body', $params['variables']);
}
break;
}
}
function install_main() {
global $profile, $install_locale, $conf, $url, $base_url;
$client_email = drush_get_option('client_email');
require_once DRUPAL_ROOT . '/includes/install.core.inc';
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_CONFIGURATION);
// We have an existing settings.php.
if (function_exists('drush_sql_read_db_spec')) {
$db_spec = drush_sql_read_db_spec();
}
else {
$db_spec = drush_core_site_install_db_spec();
}
$db_spec['db_prefix'] = $GLOBALS['db_prefix'];
if ($db_spec['driver'] == 'mysqli') {
$db_spec['driver'] = 'mysql';
}
unset($conf['site_name']);
unset($conf['site_mail']);
unset($GLOBALS['db_url']);
$account_pass = provision_password();
$settings = array(
'parameters' => array(
'profile' => $profile,
'locale' => $install_locale,
),
'settings_verified' => TRUE,
'forms' => array(
'install_settings_form' => $db_spec,
'install_configure_form' => array(
'site_name' => $url,
'site_mail' => $client_email ? $client_email : 'admin@example.com',
'account' => array(
'name' => 'admin',
'mail' => $client_email ? $client_email : 'admin@example.com',
'pass' => array(
'pass1' => $account_pass,
'pass2' => $account_pass,
),
),
'update_status_module' => array(
1 => TRUE,
2 => TRUE,
),
'clean_url' => drush_get_option('clean_url', TRUE),
),
),
);
try {
install_drupal($settings);
}
catch (Exception $e) {
drush_set_error('DRUPAL_INSTALL_FAILED');
dlm($e);
}
_provision_drupal_create_directories();
// create the admin account
$account = user_load(1);
$edit['name'] = 'admin';
$edit['pass'] = $account_pass;
$edit['mail'] = $client_email;
$edit['status'] = 1;
// temporarily disable drupal's default mail notification
$prev = variable_get('user_mail_status_activated_notify', TRUE);
variable_set('user_mail_status_activated_notify', FALSE);
$account = user_save($account, $edit);
variable_set('user_mail_status_activated_notify', $prev);
$onetime = user_pass_reset_url($account);
// Store the one time login link in an option so the front end can direct the user to their new site.
drush_set_option('login_link', $onetime);
drush_log(t('Login url: !onetime', array('!onetime' => $onetime)), 'message');
if ($client_email) {
install_send_welcome_mail($url, $account, $install_locale, $client_email, $onetime);
}
}
install_main();
function install_exception_handler() {
dlm(func_get_args());
}
<?php
// $Id$
/**
* @file Package management code for Drupal 7
*/
/**
* Find themes in a certain scope
*
* This function is based on _system_theme_data in Drupal 6 and Drupal 7.
* We do not support, nor need information on subthemes at this point.
*/
function _provision_drupal_find_themes($scope, $key = '') {
$paths = _provision_drupal_search_paths($scope, $key, 'themes');
$files = array();
$engines = array();
foreach ($paths as $path) {
$files = array_merge($files, drush_scan_directory($path, "/\.info$/", array('.', '..', 'CVS', '.svn'), 0, true, 'name'));
$engines = array_merge($engines, drush_scan_directory($path . "/engines", "/\.engine$/", array('.', '..', 'CVS', '.svn'), 0, true, 'name'));
}
foreach ($files as $name => $file) {
$files[$name]->info = _provision_drupal_parse_info_file($file->filename);
if (!empty($files[$name]->info['name'])) {
$files[$name]->name = $files[$name]->info['name'];
}
if (empty($files[$name]->info['engine'])) {
$filename = dirname($files[$name]->filename) .'/'. $files[$name]->name .'.theme';
if (file_exists($filename)) {
$files[$name]->owner = $filename;
$files[$name]->prefix = $name;
}
}
else {
$engine = $files[$name]->info['engine'];
if (isset($engines[$engine])) {
$files[$name]->owner = $engines[$engine]->filename;
$files[$name]->prefix = $engines[$engine]->name;
$files[$name]->template = TRUE;
}
}
_provision_cvs_deploy($files[$name]);
}
return $files;
}
/**
* This code is based on the Drupal 6 and Drupal 7 drupal_parse_info_file
*/
function _provision_drupal_parse_info_file($filename) {
$info = array();
$constants = get_defined_constants();
if (!file_exists($filename)) {
return $info;
}
$data = file_get_contents($filename);
if (preg_match_all('
@^\s* # Start at the beginning of a line, ignoring leading whitespace
((?:
[^=;\[\]]| # Key names cannot contain equal signs, semi-colons or square brackets,
\[[^\[\]]*\] # unless they are balanced and not nested
)+?)
\s*=\s* # Key/value pairs are separated by equal signs (ignoring white-space)
(?:
("(?:[^"]|(?<=\\\\)")*")| # Double-quoted string, which may contain slash-escaped quotes/slashes
(\'(?:[^\']|(?<=\\\\)\')*\')| # Single-quoted string, which may contain slash-escaped quotes/slashes
([^\r\n]*?) # Non-quoted string
)\s*$ # Stop at the next end of a line, ignoring trailing whitespace
@msx', $data, $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) {
// Fetch the key and value string
$i = 0;
foreach (array('key', 'value1', 'value2', 'value3') as $var) {
$$var = isset($match[++$i]) ? $match[$i] : '';
}
$value = stripslashes(substr($value1, 1, -1)) . stripslashes(substr($value2, 1, -1)) . $value3;
// Parse array syntax
$keys = preg_split('/\]?\[/', rtrim($key, ']'));
$last = array_pop($keys);
$parent = &$info;
// Create nested arrays
foreach ($keys as $key) {
if ($key == '') {
$key = count($parent);
}
if (!isset($parent[$key]) || !is_array($parent[$key])) {
$parent[$key] = array();
}
$parent = &$parent[$key];
}
// Handle PHP constants.
if (isset($constants[$value])) {
$value = $constants[$value];
}
// Insert actual value
if ($last == '') {
$last = count($parent);
}
$parent[$last] = $value;
}
}
return $info;
}
function _provision_system_query($type) {
$entries = array();
$result = db_query("SELECT * FROM {system} WHERE type=:type", array(':type' => $type));
foreach ($result as $entry) {
$entries[] = $entry;
}
return $entries;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment