Skip to content
Commits on Source (24)
......@@ -15,11 +15,16 @@ class Provision_Config_Drupal_Settings extends Provision_Config {
}
function process() {
if (drush_drupal_major_version() >= 8) {
$this->data['config_directories_active_var'] = 'config_directories_active';
$this->data['config_directories_staging_var'] = 'config_directories_staging';
}
if (drush_drupal_major_version() >= 7) {
$this->data['db_type'] = ($this->data['db_type'] == 'mysqli') ? 'mysql' : $this->data['db_type'];
$this->data['file_directory_path_var'] = 'file_public_path';
$this->data['file_directory_temp_var'] = 'file_temporary_path';
$this->data['file_directory_private_var'] = 'file_private_path';
$this->data['drupal_hash_salt_var'] = 'empty';
}
else {
$this->data['file_directory_path_var'] = 'file_directory_path';
......
......@@ -130,7 +130,18 @@ if (isset($_SERVER['db_name'])) {
$conf['<?php print $file_directory_temp_var ?>'] = 'sites/<?php print $this->uri ?>/private/temp';
<?php if (isset($file_directory_private_var)): ?>
$conf['<?php print $file_directory_private_var ?>'] = 'sites/<?php print $this->uri ?>/private/files';
<?php endif; ?>
<?php endif; ?>
<?php if (isset($drupal_hash_salt_var)): ?>
$drupal_hash_salt = '';
<?php endif; ?>
<?php if (isset($config_directories_active_var)): ?>
$config_directories['active']['path'] = 'sites/<?php print $this->uri ?>/private/config/active';
$config_directories['active']['absolute'] = TRUE;
<?php endif; ?>
<?php if (isset($config_directories_staging_var)): ?>
$config_directories['staging']['path'] = 'sites/<?php print $this->uri ?>/private/config/staging';
$config_directories['staging']['absolute'] = TRUE;
<?php endif; ?>
$conf['clean_url'] = 1;
$conf['aegir_api'] = <?php print !$this->backup_in_progress ? $this->api_version : 0 ?>;
......
......@@ -3,9 +3,9 @@ api = 2
projects[drupal][type] = "core"
projects[drupal][version] = "6.28"
projects[drupal][patch][] = "https://drupal.org/files/common.inc_6.28.patch"
projects[drupal][patch][] = "http://drupal.org/files/common.inc_6.28.patch"
projects[hostmaster][type] = "profile"
projects[hostmaster][download][type] = "git"
projects[hostmaster][download][url] = "http://git.drupal.org/project/hostmaster.git"
projects[hostmaster][download][tag] = "6.x-2.0-rc4"
projects[hostmaster][download][branch] = "6.x-2.x"
......@@ -44,9 +44,9 @@ if (sizeof($this->aliases)) {
RewriteEngine on
<?php
if ($this->redirection) {
// Redirect all aliases to the main https url.
print " RewriteCond %{HTTP_HOST} !^{$this->uri}$ [NC]\n";
print " RewriteRule ^/*(.*)$ https://{$this->uri}/$1 [NE,L,R=301]\n";
// Redirect to the selected alias.
print " RewriteCond %{HTTP_HOST} !^{$this->redirection}$ [NC]\n";
print " RewriteRule ^/*(.*)$ https://{$this->redirection}/$1 [NE,L,R=301]\n";
}
?>
RewriteRule ^/files/(.*)$ /sites/<?php print $this->uri; ?>/files/$1 [L]
......
<?php
// $Id$
/**
* @file
* Rebuild all the caches
*/
drupal_flush_all_caches();
drush_log(t('All caches flushed'));
<?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 = d()->uri;
/**
* @deprecated in drush3 it's 'options', in drush 4 it's 'cli', drop
* 'options' when we drop drush3 support
*/
$context = drush_get_context('cli') ? 'cli' : 'options';
$old_url = drush_get_option('old_uri', $new_url, $context);
/**
* @file
* Handle site migration tasks for redeployed sites.
* This is primarily to handle the rename of the sites
* directories.
*/
if (db_table_exists('file_managed')) {
db_query("UPDATE {file_managed} SET uri = REPLACE(uri, :old, :new)", array(':old' => 'sites/default', ':new' => 'sites/$new_url'));
db_query("UPDATE {file_managed} SET uri = REPLACE(uri, :old, :new)", array(':old' => 'sites/$old_url', ':new' => 'sites/$new_url'));
}
if (db_table_exists('files')) {
db_query("UPDATE {files} SET filepath = REPLACE(filepath, :old, :new)", array(':old' => 'sites/$old_url', ':new' => 'sites/$new_url'));
db_query("UPDATE {files} SET filepath = REPLACE(filepath, :old, :new)", array(':old' => 'sites/default', ':new' => 'sites/$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");
drush_log(
dt('Changed paths from sites/@old_url to sites/@new_url',
array('@old_url' => $old_url, '@new_url' => $new_url)));
......@@ -7,7 +7,7 @@ if ($db = $databases['default']['default']) {
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');
drush_set_option('profile', variable_get('install_profile', 'standard'), 'site');
$language = language_default();
drush_set_option('language', $language->language, 'site');
}
<?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', 'standard'), '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'));
$username = $account->getUsername();
$site = variable_get('site_name', 'Drupal');
$uri_brief = preg_replace('!^https?://!', '', $base_url);
$mailto = $account->getEmail();
$date = format_date(time());
$login_uri = url('user', array('absolute' => TRUE));
$edit_uri = url('user/'. $account->id() .'/edit', array('absolute' => TRUE));
$mail_params['variables'] = array(
'!username' => $username,
'!site' => $site,
'!login_url' => $onetime,
'!uri' => $base_url,
'!uri_brief' => $uri_brief,
'!mailto' => $mailto,
'!date' => $date,
'!login_uri' => $login_uri,
'!edit_uri' => $edit_uri,
);
$langcode = $account->getPreferredLangcode();
$mail_success = drupal_mail('install', 'welcome-admin', $mailto, $langcode, $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'] = t($mail['subject'], $params['variables']);
$message['body'][] = t($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 . '/core/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 if (function_exists('_drush_sql_get_db_spec')) {
$db_spec = _drush_sql_get_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);
$account->name = 'admin';
$account->pass = $account_pass;
$account->mail = $client_email;
$account->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->save();
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 . '/login');
drush_log(t('Login url: !onetime', array('!onetime' => $onetime . '/login')), '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 8
*/
/**
* 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;
}
<?php
// $Id$
/**
* @file
* Find modules, themes and themes engines
*/
drush_set_option('modules', _scrub_object(module_rebuild_cache()), 'site');
// Find theme engines
drush_set_option('engines', _scrub_object(drupal_system_listing('\.engine$', 'themes/engines')), 'site');
drush_set_option('themes', _scrub_object(system_theme_data()), 'site');
if (drush_drupal_major_version() >= 7) {
drush_set_option('modules', _scrub_object(system_rebuild_module_data()), 'site');
drush_set_option('themes', _scrub_object(system_rebuild_theme_data()), 'site');
}
else {
drush_set_option('modules', _scrub_object(module_rebuild_cache()), 'site');
drush_set_option('themes', _scrub_object(system_theme_data()), 'site');
}
drush_set_option('engines', _scrub_object(drupal_system_listing('\.engine$', 'themes/engines')), 'site');
......@@ -233,6 +233,19 @@ function _provision_drupal_create_directories($url = NULL, $profile = NULL) {
$mkdir["sites/$url/private/temp"] = 02770;
$chgrp["sites/$url/private/temp"] = d('@server_master')->web_group;
$mkdir["sites/$url/files/styles"] = 02770;
$chgrp["sites/$url/files/styles"] = d('@server_master')->web_group;
// d8 support
$mkdir["sites/$url/private/config"] = 02770;
$chgrp["sites/$url/private/config"] = d('@server_master')->web_group;
$mkdir["sites/$url/private/config/active"] = 02770;
$chgrp["sites/$url/private/config/active"] = d('@server_master')->web_group;
$mkdir["sites/$url/private/config/staging"] = 02770;
$chgrp["sites/$url/private/config/staging"] = d('@server_master')->web_group;
}
// These paths should not have recursive operations performed on them.
......@@ -249,11 +262,17 @@ function _provision_drupal_create_directories($url = NULL, $profile = NULL) {
"sites/$url/files/locations",
"sites/$url/private",
"sites/$url/private/files",
"sites/$url/private/temp"
"sites/$url/private/temp",
"sites/$url/files/styles",
"sites/$url/files/private",
"sites/$url/private/config",
"sites/$url/private/config/active",
"sites/$url/private/config/staging"
);
// Allow other commands to add or alter the directories to be created.
drush_command_invoke_all('provision_drupal_create_directories_alter', $mkdir, $url);
drush_command_invoke_all_ref('provision_drupal_create_directories_alter', $mkdir, $url);
drush_command_invoke_all_ref('provision_drupal_chgrp_directories_alter', $chgrp, $url);
foreach ($mkdir as $path => $perm) {
if (!is_dir($path)) {
......@@ -286,15 +305,21 @@ function _provision_drupal_rebuild_caches() {
* Find available profiles on this platform.
*/
function _provision_find_profiles() {
include_once('includes/install.inc');
if (!$dir = opendir("./profiles")) {
if (drush_drupal_major_version() >= 8) {
include_once('core/includes/install.inc');
$profiles_subdir = "./core/profiles";
}
else {
include_once('includes/install.inc');
$profiles_subdir = "./profiles";
}
if (!$dir = opendir($profiles_subdir)) {
drush_log(dt("Cannot find profiles directory"), 'error');
return FALSE;
}
while (FALSE !== ($name = readdir($dir))) {
$languages = array();
$file = "./profiles/$name/$name.profile";
$file = "$profiles_subdir/$name/$name.profile";
if ($name == '..' || $name == '.' || !file_exists($file)) {
continue;
}
......@@ -306,7 +331,7 @@ function _provision_find_profiles() {
$profile->info = array();
$info_file = "./profiles/$name/$name.info";
$info_file = "$profiles_subdir/$name/$name.info";
if (file_exists($info_file)) {
$profile->info = provision_parse_info_file($info_file);
// Skip hidden profiles
......@@ -323,8 +348,8 @@ function _provision_find_profiles() {
$languages['en'] = 1;
// Find languages available
$files = array_keys(drush_scan_directory('./profiles/' . $name . '/translations', '/\.po$/', array('.', '..', 'CVS'), 0, FALSE, 'filepath'));
$files = array_merge($files, array_keys(drush_scan_directory('./profiles/' . $name , '/\.po$/', array('.', '..', 'CVS'), 0, FALSE, 'filepath')));
$files = array_keys(drush_scan_directory($profiles_subdir . '/' . $name . '/translations', '/\.po$/', array('.', '..', 'CVS'), 0, FALSE, 'filepath'));
$files = array_merge($files, array_keys(drush_scan_directory($profiles_subdir . '/' . $name , '/\.po$/', array('.', '..', 'CVS'), 0, FALSE, 'filepath')));
if (is_array($files)) {
foreach ($files as $file) {
if (preg_match('!(/|\.)([^\./]+)\.po$!', $file, $langcode)) {
......@@ -504,7 +529,7 @@ function _provision_find_platforms() {
return array(
'drupal' => array(
'short_name' => 'drupal', 'version' => drush_drupal_version(),
'description' => dt("This platform is running @short_name @version", array('@short_name' => 'Drupal', '@version' => VERSION))));
'description' => dt("This platform is running @short_name @version", array('@short_name' => 'Drupal', '@version' => drush_drupal_version()))));
}
/**
......@@ -602,6 +627,7 @@ function _provision_drupal_search_paths($scope, $key = '', $type = 'modules') {
switch ($scope) {
case 'base' :
$searchpaths[] = sprintf("%s/%s", $drupal_root, $type);
$searchpaths[] = sprintf("%s/core/%s", $drupal_root, $type);
break;
default :
if ($key) {
......
......@@ -9,9 +9,15 @@
*/
$mail = array();
$mail['subject'] = st('Your new site !site has been created.');
$mail['body'] = st("!username,
if (drush_drupal_major_version() >= 8) {
$t = 't';
}
else {
$t = 'st';
}
$mail['subject'] = $t('Your new site !site has been created.');
$mail['body'] = $t("!username,
Your new site !site has been created.
......
......@@ -31,6 +31,10 @@ function drush_provision_drupal_provision_login_reset() {
drush_set_option('login_link', $onetime);
drush_log(t('Login url: !onetime', array('!onetime' => $onetime)), 'success');
if (drush_drupal_major_version() >= 8) {
require_once 'core/includes/session.inc';
}
if (drush_drupal_major_version() >= 7) {
drupal_session_destroy_uid(1);
}
......
......@@ -76,7 +76,7 @@ function drush_provision_drupal_pre_provision_verify() {
->fail('Drupal sites directory @path is not writable by the provisioning script', 'PROVISION_SITES_DIR_NOT_WRITABLE');
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' => VERSION)));
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();
}
......
name=Provision
description="Aegir backend"
version=6.x-2.0-rc4
version=6.x-2.0-rc2
......@@ -15,7 +15,7 @@ msg() {
}
# basic variables, change before running
AEGIR_VERSION="6.x-2.0-rc4"
AEGIR_VERSION="6.x-2.0-rc2"
DRUSH_DIR=$HOME/drush
DRUSH=$DRUSH_DIR/drush.php
if which drush 2> /dev/null > /dev/null && which drush | grep -v 'no drush in' > /dev/null; then
......