Commit 39de65b8 authored by anarcat's avatar anarcat

1115960 - create symlinks within a new 'clients' directory for sites

parent 635c68ee
......@@ -72,5 +72,6 @@ function drush_provision_drupal_post_provision_install() {
drush_set_option('installed', TRUE, 'site');
_provision_drupal_rebuild_caches();
drush_set_option('packages', _scrub_object(provision_drupal_system_map()), 'site');
_provision_client_create_symlink();
}
......@@ -699,3 +699,35 @@ function provision_reload_config($context, $file = null) {
}
}
}
/**
* Maintain a symlink to the site within a client directory
*
* This creates a directory structure like this:
*
* ~/clients/foo/example.org -> ~/platforms/.../sites/example.org
* ~/clients/bar/bar.example.com -> ~/platforms/.../sites/bar.example.com
*
* @todo this probably doesn't belong in this file
*/
function _provision_client_create_symlink() {
$sites_dir = d()->server->clients_path . '/' . d()->client_name;
provision_file()->create_dir($sites_dir, dt('Client home directory for @client', array('@client' => d()->client_name)));
provision_file()->unlink($sites_dir . '/' . d()->uri); // deliberatly ignore errors
provision_file()->symlink(d()->site_path, $sites_dir . '/' . d()->uri)
->succeed('Created symlink @path to @target')
->fail('Could not create symlink @path to @target: @reason');
}
/**
* Delete the site symlink within the client directory
*
* This deletes the site symlink created on verify/install
*
* @see _provision_client_create_symlink()
*/
function _provision_client_delete_symlink() {
provision_file()->unlink(d()->server->clients_path . '/' . d()->client_name . '/' . d()->uri)
->succeed('Deleted symlink @path')
->fail('Failed to delete symlink @path: @reason');
}
......@@ -27,6 +27,7 @@ function drush_provision_drupal_pre_provision_verify() {
$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);
......@@ -96,6 +97,8 @@ 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();
}
}
......@@ -60,6 +60,7 @@ class provisionContext_server extends provisionContext {
$this->backup_path = $this->aegir_root . '/backups';
$this->config_path = $this->aegir_root . '/config/' . ltrim($this->name, '@');
$this->include_path = $this->aegir_root . '/config/includes';
$this->clients_path = $this->aegir_root . '/clients';
$this->setProperty('master_url');
$this->setProperty('admin_email', 'admin@' . $this->remote_host);
......
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