Commit 9059dde9 authored by Adrian Rossouw's avatar Adrian Rossouw

better install and migrate. enforce @server_localhost and @hostmaster aliases.

parent 2074cb98
......@@ -66,7 +66,7 @@ function hostmaster_bootstrap() {
$node = new stdClass();
$node->uid = 1;
$node->type = 'server';
$node->title = $_SERVER['HTTP_HOST'];
$node->title = 'localhost';
$node->status = 1;
$node->services = array();
......@@ -125,7 +125,7 @@ function hostmaster_bootstrap() {
$node = new stdClass();
$node->uid = 1;
$node->type = 'platform';
$node->title = $_SERVER['HTTP_HOST'] . ' (Drupal ' . VERSION . ')';
$node->title = 'hostmaster';
$node->publish_path = drush_locate_root(drush_get_option(array('r', 'root'), NULL));
$node->web_server = variable_get('hosting_default_web_server', 3);
$node->status = 1;
......
......@@ -219,6 +219,8 @@ function hosting_update_6008() {
$records = array();
$result = db_query("SELECT n.nid, title FROM {node} n LEFT JOIN {hosting_site} s ON n.nid=s.nid WHERE s.status <> -2 AND n.type='site'");
while ($object = db_fetch_object($result)) {
$records[$object->nid] = $object->title;
......@@ -234,6 +236,19 @@ function hosting_update_6008() {
$records[$object->nid] = 'platform_' . preg_replace("/[!\W]/", "", $object->title);
}
// we want to enforce that the hostmaster site is always referred to as @hostmaster
$own_site = db_result(db_query("SELECT s.nid FROM {hosting_site} s LEFT JOIN {hosting_package} p ON s.profile=p.nid WHERE p.short_name='hostmaster'"));
$records[$own_site] = 'hostmaster';
// We start with the web server because we assume that the main hostmaster site is installed locally.
$node = node_load($own_site);
$server = node_load($node->web_server);
$server->title = 'localhost';
node_save($server);
$records[$server->nid] = 'server_localhost';
foreach ($records as $nid => $name) {
db_query("INSERT INTO {hosting_context} (nid, name) VALUES (%d, '%s')", $nid, $name);
}
......
......@@ -46,12 +46,6 @@ function drush_hosting_hostmaster_resume() {
db_query("UPDATE {hosting_context} SET name='%s' WHERE nid=%d", ltrim($new_platform, '@'), $platform_id);
}
$server_id = $platform->web_server;
// fix the new platform alias name
if (hosting_context_name($server_id) != $server_name) {
db_query("UPDATE {hosting_context} SET name='%s' WHERE nid=%d", ltrim($server_name, '@'), $server_id);
}
drush_log('fixing platform for site node');
$node->verified = 0;
......
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