Commit 8180c5d7 authored by omega8cc's avatar omega8cc

Fix the check for parent site existence - we should look for drush alias file...

Fix the check for parent site existence - we should look for drush alias file and not a vhost (which can be dummy subdir vhost).

Running the parent site re-verify more than once (which would happen when there are two or more aliases) via backend while updating subdir site configuration results with semi-disaster, since it writes parent site db credentials into subdir site config. Not nice. But when auto-running this re-verify via frontend with hosting-task, it results with total disaster - it destroys hostmaster database! The workaround is to use a counter in the aliases loop, to make sure that we run parent site re-verify to update its vhost and add include line for sites in subdirs, if they exist, only once. By the way, DigitalOcean backups s*cks!
parent e4dab7bc
......@@ -31,25 +31,31 @@ class Provision_Config_Apache_SubdirVhost extends Provision_Config_Http {
}
/**
* Check if the parent (domain) site (vhost) exists.
* Check if the (real) parent site (drushrc) exists.
*/
function parent_site() {
$vhost_parent_site = $this->data['http_vhostd_path'] . '/' . $this->uri();
if (provision_file()->exists($vhost_parent_site)->status()) {
$u = explode('/', $this->data['http_vhostd_path'], 6);
$p = '/' . $u[1] . '/' . $u[2] . '/.drush/';
$parent_site_drushrc = $p . $this->uri() . '.alias.drushrc.php';
if (provision_file()->exists($parent_site_drushrc)->status()) {
$e = TRUE;
}
return $e;
}
function write() {
$count = "0";
foreach (d()->aliases as $alias) {
if (strpos($alias, '/')) {
$this->current_alias = $alias;
if ($this->parent_site()) {
$site_parent = TRUE;
$site_is_parent = TRUE;
drush_log(dt('Parent site %vhost already exists for alias %alias, skipping', array('%vhost' => $this->uri(), '%alias' => $alias)), 'notice');
$site_name = '@' . $this->uri();
provision_backend_invoke($site_name, 'provision-verify');
if ($count == "0") {
$site_name = '@' . $this->uri();
provision_backend_invoke($site_name, 'provision-verify');
}
$count++;
}
else {
drush_log("Subdirectory alias `$alias` found. Creating vhost configuration file.", 'notice');
......@@ -67,7 +73,7 @@ class Provision_Config_Apache_SubdirVhost extends Provision_Config_Http {
}
function filename() {
if (!$site_parent) {
if (!$site_is_parent) {
return $this->data['http_vhostd_path'] . '/' . $this->uri();
}
}
......
......@@ -31,25 +31,31 @@ class Provision_Config_Nginx_SubdirVhost extends Provision_Config_Http {
}
/**
* Check if the parent (domain) site (vhost) exists.
* Check if the (real) parent site (drushrc) exists.
*/
function parent_site() {
$vhost_parent_site = $this->data['http_vhostd_path'] . '/' . $this->uri();
if (provision_file()->exists($vhost_parent_site)->status()) {
$u = explode('/', $this->data['http_vhostd_path'], 6);
$p = '/' . $u[1] . '/' . $u[2] . '/.drush/';
$parent_site_drushrc = $p . $this->uri() . '.alias.drushrc.php';
if (provision_file()->exists($parent_site_drushrc)->status()) {
$e = TRUE;
}
return $e;
}
function write() {
$count = "0";
foreach (d()->aliases as $alias) {
if (strpos($alias, '/')) {
$this->current_alias = $alias;
if ($this->parent_site()) {
$site_parent = TRUE;
$site_is_parent = TRUE;
drush_log(dt('Parent site %vhost already exists for alias %alias, skipping', array('%vhost' => $this->uri(), '%alias' => $alias)), 'notice');
$site_name = '@' . $this->uri();
provision_backend_invoke($site_name, 'provision-verify');
if ($count == "0") {
$site_name = '@' . $this->uri();
provision_backend_invoke($site_name, 'provision-verify');
}
$count++;
}
else {
drush_log("Subdirectory alias `$alias` found. Creating vhost configuration file.", 'notice');
......@@ -67,7 +73,7 @@ class Provision_Config_Nginx_SubdirVhost extends Provision_Config_Http {
}
function filename() {
if (!$site_parent) {
if (!$site_is_parent) {
return $this->data['http_vhostd_path'] . '/' . $this->uri();
}
}
......
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