Skip to content

Instantly share code, notes, and snippets.

@jonpugh
Created February 13, 2019 12:04
Show Gist options
  • Save jonpugh/9bafef86919b0ceeac9293d4c5bf0d3e to your computer and use it in GitHub Desktop.
Save jonpugh/9bafef86919b0ceeac9293d4c5bf0d3e to your computer and use it in GitHub Desktop.
git diff 5.x-0.1 7.x-3.x
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..4a07b38
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+themes/*
+modules/*
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..7df5cca
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,50 @@
+language: generic
+
+sudo: required
+
+env:
+ globaL:
+ - DOCKER_VERSION=1.11.2-0~trusty
+ - DOCKER_COMPOSE_VERSION=1.7.1
+ - AEGIR_HOSTING_VERSION=7.x-3.x
+ - AEGIR_TESTS_VERSION=master
+
+#env:
+# - test: Ubuntu 14.04 Apache
+# distribution: ubuntu
+# version: 14.04
+# init: /sbin/init
+# run_opts: ""
+
+addons:
+ hosts:
+ - aegir.travis
+ - sitetest.aegir.travis
+
+services:
+ - docker
+
+before_install:
+ # Show travis build dir variable.
+ - echo $TRAVIS_BUILD_DIR
+
+ # Get test scripts
+ - git clone http://github.com/aegir-project/tests.git /home/travis/build/aegir-project/tests
+ - cd /home/travis/build/aegir-project/tests
+ - git checkout $AEGIR_TESTS_VERSION
+
+ # Get Hosting
+ - git clone http://git.drupal.org/project/hosting.git /home/travis/build/aegir-project/hosting
+ - cd /home/travis/build/aegir-project/hosting
+ - git checkout $AEGIR_HOSTING_VERSION
+
+
+ # Run prepare scripts.
+ - cd /home/travis/build/aegir-project/tests/travis
+ - sudo bash prepare-docker.sh
+ - bash prepare-testenv.sh
+
+script:
+
+ # Tests are included in the docker-compose.yml file in the tests repo.
+ - sudo docker-compose -f docker-compose-hostmaster.yml run hostmaster
diff --git a/README.txt b/README.txt
index fdcb3da..5ea1427 100644
--- a/README.txt
+++ b/README.txt
@@ -1,32 +1,20 @@
-=== The hostmaster system ===
-This install profile is part of the front end of a system that also consists of the hosting framework (front end) and the provisioning framework (backend).
+The Aegir system
+================
-The front end and back end are designed to be run separately, and each front end will also be able to drive multiple back ends (in the simplest case, each drupal release will be a back end implementation of it's own)
+This install profile is part of the front end of the Aegir hosting
+system that also consists of the hosting framework (front end) and the
+provisioning framework (backend).
-Once installed go to admin -> help -> hosting for more elaborate and translatable help.
+The front end and back end are designed to be run separately, and each
+front end will also be able to drive multiple back ends.
-The most up to date information regarding the project and it's goal can be found in the hostmaster wiki page - http://groups.drupal.org/hm2/overview .
+The most up to date information regarding the project and its goals
+can be found on the Aegir website and the community portal:
-=== Hostmaster Layout ===
-The installation profile should reside under the profiles directory under the drupal root and is named hostmaster.
+ http://aegirproject.org
+ http://community.aegirproject.org
-Modules Location:
-Hostmaster requires modules to be installed in -
- profiles/hostmaster/modules to avoid conflicts with different sites versions.
+To install the complete Aegir system, you first need to install Drush
+and Provision, see the install manual on the community site:
-When installed your filesystem should look like this..
-
- profiles/hostmaster/hostmaster.profile
- /modules/hosting
- /modules/provision
- /modules/views
- /modules/drush
-
-Note: Don't be alarmed by the existence of views both in your profiles and sites/all directory. Hostmaster uses it's own views so it does not rely on a specific site to work.
-
-=== Pre Requirements ===
-Required Modules:
- * hosting
- * provision
- * views
- * drush
+ http://community.aegirproject.org/installing
diff --git a/build-hostmaster.make b/build-hostmaster.make
new file mode 100644
index 0000000..cfe3475
--- /dev/null
+++ b/build-hostmaster.make
@@ -0,0 +1,9 @@
+core = 7.x
+api = 2
+
+
+
+; This makefile is designed to be able to bootstrap hostmaster without having to
+; use provosion's makefile
+projects[drupal][type] = core
+includes[hostmaster] = drupal-org.make
diff --git a/drupal-org-core.make b/drupal-org-core.make
new file mode 100644
index 0000000..23a09e6
--- /dev/null
+++ b/drupal-org-core.make
@@ -0,0 +1,12 @@
+api = 2
+core = 7.x
+
+; MAKE file for Drupal core. Used by the Drupal.org packager.
+
+
+projects[drupal][type] = core
+
+; Pin a core version, only as long as we have a core patch below.
+; Sync manually with aegir.make in the provision repo
+;projects[drupal][version] = 7.61
+
diff --git a/drupal-org.make b/drupal-org.make
new file mode 100644
index 0000000..32e55b1
--- /dev/null
+++ b/drupal-org.make
@@ -0,0 +1,87 @@
+core = 7.x
+api = 2
+
+defaults[projects][subdir] = "contrib"
+defaults[projects][type] = "module"
+
+
+; Aegir core
+
+projects[eldir][type] = theme
+projects[eldir][download][type] = git
+projects[eldir][subdir] = aegir
+projects[eldir][download][tag] = 7.x-3.170
+
+projects[hosting][download][type] = git
+projects[hosting][subdir] = aegir
+projects[hosting][download][tag] = 7.x-3.170
+
+
+
+; Modules - Aegir "golden"
+
+projects[hosting_git][download][type] = git
+projects[hosting_git][subdir] = aegir
+projects[hosting_git][download][tag] = 7.x-3.170
+
+projects[hosting_remote_import][download][type] = git
+projects[hosting_remote_import][subdir] = aegir
+projects[hosting_remote_import][download][tag] = 7.x-3.170
+
+projects[hosting_site_backup_manager][download][type] = git
+projects[hosting_site_backup_manager][subdir] = aegir
+projects[hosting_site_backup_manager][download][tag] = 7.x-3.170
+
+projects[hosting_tasks_extra][download][type] = git
+projects[hosting_tasks_extra][subdir] = aegir
+projects[hosting_tasks_extra][download][tag] = 7.x-3.170
+
+projects[hosting_civicrm][download][type] = git
+projects[hosting_civicrm][subdir] = aegir
+projects[hosting_civicrm][download][tag] = 7.x-3.170
+
+projects[hosting_logs][download][type] = git
+projects[hosting_logs][subdir] = aegir
+projects[hosting_logs][download][tag] = 7.x-3.170
+
+projects[hosting_dns][download][type] = git
+projects[hosting_dns][subdir] = aegir
+projects[hosting_dns][download][branch] = 7.x-3.x
+
+projects[hosting_https][download][type] = git
+projects[hosting_https][subdir] = aegir
+projects[hosting_https][download][tag] = 7.x-3.171
+
+; Modules - contrib
+
+projects[admin_menu][version] = 3.0-rc6
+projects[betterlogin][version] = 1.5
+projects[ctools][version] = 1.14
+projects[entity][version] = 1.9
+projects[module_filter][version] = 2.1
+projects[openidadmin][version] = 1.0
+projects[overlay_paths][version] = 1.3
+projects[r4032login][version] = 1.8
+projects[views][version] = 3.20
+projects[views_bulk_operations][version] = 3.5
+
+; Two factor authentication
+projects[libraries][version] = 2.5
+projects[tfa][version] = 2.0
+projects[tfa_basic][version] = 1.1
+projects[tfa_basic][patch][] = "https://www.drupal.org/files/issues/use_libraries_module-2807953-8.patch"
+
+libraries[qrcodejs][download][type] = git
+libraries[qrcodejs][download][url] = https://github.com/davidshimjs/qrcodejs.git
+libraries[qrcodejs][download][revision] = 04f46c6a0708418cb7b96fc563eacae0fbf77674
+
+; JQuery TimeAgo plugin
+projects[timeago][version] = 2.3
+libraries[timeago][download][type] = get
+libraries[timeago][download][url] = https://raw.githubusercontent.com/rmm5t/jquery-timeago/v1.6.1/jquery.timeago.js
+libraries[timeago][destination] = libraries
+
+; Vue.js
+libraries[vuejs][download][type] = get
+libraries[vuejs][download][url] = https://github.com/vuejs/vue/raw/v2.4.4/dist/vue.min.js
+libraries[vuejs][destination] = libraries
diff --git a/hostmaster.info b/hostmaster.info
new file mode 100644
index 0000000..c155d8d
--- /dev/null
+++ b/hostmaster.info
@@ -0,0 +1,41 @@
+name = Hostmaster
+description = Select this profile to manage the installation and maintenance of hosted Drupal sites.
+core = 7.x
+
+distribution_name = "Hostmaster (Aegir)"
+exclusive = TRUE
+
+
+;; Drupal core ;;
+dependencies[] = block
+dependencies[] = color
+dependencies[] = filter
+dependencies[] = help
+dependencies[] = menu
+dependencies[] = node
+dependencies[] = overlay
+dependencies[] = system
+dependencies[] = user
+
+;; Aegir core ;;
+dependencies[] = hosting
+dependencies[] = hosting_task
+dependencies[] = hosting_client
+dependencies[] = hosting_db_server
+dependencies[] = hosting_package
+dependencies[] = hosting_platform
+dependencies[] = hosting_site
+dependencies[] = hosting_web_server
+dependencies[] = hosting_server
+;dependencies[] = hosting_clone
+;dependencies[] = hosting_cron
+;dependencies[] = hosting_migrate
+
+;; Drupal contrib ;;
+dependencies[] = admin_menu
+dependencies[] = betterlogin
+dependencies[] = overlay_paths
+dependencies[] = views
+dependencies[] = views_bulk_operations
+dependencies[] = actions_permissions
+dependencies[] = r4032login
diff --git a/hostmaster.install b/hostmaster.install
new file mode 100644
index 0000000..8d80e28
--- /dev/null
+++ b/hostmaster.install
@@ -0,0 +1,347 @@
+<?php
+
+/**
+ * Implement hook_install().
+ *
+ * Perform actions to set up the site for this profile.
+ */
+function hostmaster_install() {
+
+ variable_set('install_profile', 'hostmaster');
+
+// add support for nginx
+ if (d()->platform->server->http_service_type === 'nginx') {
+ module_enable(array('hosting_nginx'));
+ }
+
+ // Bootstrap and create all the initial nodes
+ hostmaster_bootstrap();
+
+ // Finalize and setup themes, optional modules etc
+ hostmaster_task_finalize();
+
+}
+
+function hostmaster_bootstrap() {
+ /* Default node types and default node */
+ $types = node_types_rebuild();
+
+ // Initialize the hosting defines
+ hosting_init();
+
+ /* Default client */
+ $node = new stdClass();
+ $node->uid = 1;
+ $node->type = 'client';
+ $node->title = drush_get_option('client_name', 'admin');
+ $node->status = 1;
+ node_save($node);
+ variable_set('hosting_default_client', $node->nid);
+ variable_set('hosting_admin_client', $node->nid);
+
+ $client_id = $node->nid;
+
+ /* Default server */
+ $node = new stdClass();
+ $node->uid = 1;
+ $node->type = 'server';
+ $node->title = php_uname('n');
+ $node->status = 1;
+ $node->hosting_name = 'server_master';
+ $node->services = array();
+
+ /* Make it compatible with more than apache and nginx */
+ $master_server = d()->platform->server;
+ hosting_services_add($node, 'http', $master_server->http_service_type, array(
+ 'restart_cmd' => $master_server->http_restart_cmd,
+ 'port' => $master_server->http_port,
+ 'available' => 1,
+ ));
+
+ /* examine the db server associated with the hostmaster site */
+ $db_server = d()->db_server;
+ $master_db = parse_url($db_server->master_db);
+ /* if it's not the same server as the master server, create a new node
+ * for it */
+ if ($db_server->remote_host == $master_server->remote_host) {
+ $db_node = $node;
+ } else {
+ $db_node = new stdClass();
+ $db_node->uid = 1;
+ $db_node->type = 'server';
+ $db_node->title = $master_db['host'];
+ $db_node->status = 1;
+ $db_node->hosting_name = 'server_' . $db_server->remote_host;
+ $db_node->services = array();
+ }
+ hosting_services_add($db_node, 'db', $db_server->db_service_type, array(
+ 'db_type' => $master_db['scheme'],
+ 'db_user' => urldecode($master_db['user']),
+ 'db_passwd' => isset($master_db['pass']) ? urldecode($master_db['pass']) : '',
+ 'port' => $db_server->db_port,
+ 'available' => 1,
+ ));
+
+ drupal_set_message(st('Creating master server node'));
+ node_save($node);
+ if ($db_server->remote_host != $master_server->remote_host) {
+ drupal_set_message(st('Creating db server node'));
+ node_save($db_node);
+ }
+ variable_set('hosting_default_web_server', $node->nid);
+ variable_set('hosting_own_web_server', $node->nid);
+
+ variable_set('hosting_default_db_server', $db_node->nid);
+ variable_set('hosting_own_db_server', $db_node->nid);
+
+ // Create the hostmaster platform & packages
+ $node = new stdClass();
+ $node->uid = 1;
+ $node->title = 'Drupal';
+ $node->type = 'package';
+ $node->package_type = 'platform';
+ $node->short_name = 'drupal';
+ $node->old_short_name = 'drupal';
+ $node->description = 'Drupal code-base.';
+ $node->status = 1;
+ node_save($node);
+ $package_id = $node->nid;
+
+ $node = new stdClass();
+ $node->uid = 1;
+ $node->type = 'platform';
+ $node->title = 'hostmaster';
+ $node->publish_path = d()->root;
+ $node->makefile = '';
+ $node->verified = 1;
+ $node->web_server = variable_get('hosting_default_web_server', 2);
+ $node->platform_status = 1;
+ $node->status = 1;
+ $node->make_working_copy = 0;
+ node_save($node);
+ $platform_id = $node->nid;
+ variable_set('hosting_own_platform', $node->nid);
+
+ $instance = new stdClass();
+ $instance->rid = $node->nid;
+ $instance->version = VERSION;
+ $instance->filename = '';
+ $instance->version_code = 1;
+ //$instance->schema_version = drupal_get_installed_schema_version('system');
+ $instance->schema_version = 0;
+ $instance->package_id = $package_id;
+ $instance->status = 0;
+ $instance->platform = $platform_id;
+ hosting_package_instance_save($instance);
+
+ // Create the hostmaster profile package node
+ $node = new stdClass();
+ $node->uid = 1;
+ $node->title = 'hostmaster';
+ $node->type = 'package';
+ $node->old_short_name = 'hostmaster';
+ $node->description = 'The Hostmaster profile.';
+ $node->package_type = 'profile';
+ $node->short_name = 'hostmaster';
+ $node->status = 1;
+ node_save($node);
+ $profile_id = $node->nid;
+
+ $instance = new stdClass();
+ $instance->rid = $node->nid;
+ $instance->version = VERSION;
+ $instance->filename = '';
+ $instance->version_code = 1;
+ //$instance->schema_version = drupal_get_installed_schema_version('system');
+ $instance->schema_version = 0;
+ $instance->package_id = $profile_id;
+ $instance->status = 0;
+ $instance->platform = $platform_id;
+ hosting_package_instance_save($instance);
+
+ // Create the main Aegir site node
+ $node = new stdClass();
+ $node->uid = 1;
+ $node->type = 'site';
+ $node->title = d()->uri;
+ $node->platform = $platform_id;
+ $node->client = $client_id;
+ $node->db_name = '';
+ $node->db_server = $db_node->nid;
+ $node->profile = $profile_id;
+ $node->import = true;
+ $node->hosting_name = 'hostmaster';
+ $node->site_status = 1;
+ $node->verified = 1;
+ $node->status = 1;
+ node_save($node);
+
+ // Save the hostmaster site nid.
+ variable_set('aegir_hostmaster_site_nid', $node->nid);
+
+ // Enable the hosting features of modules that we enable by default.
+ // The module will already be enabled,
+ // this makes sure we also set the default permissions.
+ $default_hosting_features = array(
+ 'hosting_web_server' => 'web_server',
+ 'hosting_db_server' => 'db_server',
+ 'hosting_platform' => 'platform',
+ 'hosting_client' => 'client',
+ 'hosting_task' => 'task',
+ 'hosting_server' => 'server',
+ 'hosting_package' => 'package',
+ 'hosting_site' => 'site',
+ 'hosting' => 'hosting',
+ );
+ hosting_features_enable($default_hosting_features, $rebuild = TRUE, $enable = FALSE);
+
+ variable_set('site_frontpage', 'hosting/sites');
+
+ // do not allow user registration: the signup form will do that
+ variable_set('user_register', 0);
+
+ // This is saved because the config generation script is running via drush, and does not have access to this value
+ variable_set('install_url' , $GLOBALS['base_url']);
+}
+
+function hostmaster_task_finalize() {
+ variable_set('install_profile', 'hostmaster');
+
+ // Enable Eldir, and set is as default theme
+ theme_enable(array('eldir'));
+ variable_set('theme_default', 'eldir');
+
+ // Disable the default Bartik theme
+ theme_disable(array('bartik'));
+
+ drupal_set_message(st('Configuring default blocks'));
+ hostmaster_place_blocks('eldir');
+
+ // Save "menu_options" for our content types, so they don't offer to be put in menus.
+ variable_set('menu_options_client', array());
+ variable_set('menu_options_platform', array());
+ variable_set('menu_options_server', array());
+ variable_set('menu_options_site', array());
+
+ // Rebuild node access permissions.
+ node_access_rebuild();
+}
+
+/**
+ * Helper function to place block.
+ */
+function hostmaster_place_blocks($theme) {
+ $blocks = array(
+ array(
+ 'module' => 'hosting',
+ 'delta' => 'hosting_queues',
+ 'theme' => $theme,
+ 'status' => 1,
+ 'weight' => -2,
+ 'region' => 'sidebar_first',
+ 'visibility' => 0,
+ 'pages' => '',
+ 'cache' => -1,
+ ),
+ array(
+ 'module' => 'system',
+ 'delta' => 'navigation',
+ 'theme' => $theme,
+ 'status' => 1,
+ 'weight' => 0,
+ 'region' => 'sidebar_first',
+ 'visibility' => 0,
+ 'pages' => '',
+ 'cache' => -1,
+ ),
+ array(
+ 'module' => 'views',
+ 'delta' => 'hosting_task_list-block',
+ 'theme' => $theme,
+ 'status' => 1,
+ 'weight' => -2,
+ 'region' => 'sidebar_first',
+ 'visibility' => 0,
+ 'pages' => '',
+ 'cache' => -1,
+ ),
+ array(
+ 'module' => 'views',
+ 'delta' => 'hosting_site_list-block_sites',
+ 'theme' => $theme,
+ 'status' => 1,
+ 'weight' => 0,
+ 'region' => 'content_bottom',
+ 'visibility' => 1,
+ 'pages' => 'hosting/c/platform_*',
+ 'cache' => -1,
+ ),
+ array(
+ 'module' => 'views',
+ 'delta' => 'hosting_platform_list-block_1',
+ 'theme' => $theme,
+ 'status' => 1,
+ 'weight' => 0,
+ 'region' => 'content_bottom',
+ 'visibility' => 1,
+ 'pages' => 'hosting/c/server_*',
+ 'cache' => -1,
+ ),
+ array(
+ 'module' => 'views',
+ 'delta' => 'hosting_site_list-block_profile',
+ 'theme' => $theme,
+ 'status' => 1,
+ 'weight' => 0,
+ 'region' => 'content_bottom',
+ 'visibility' => 0,
+ 'pages' => '',
+ //"<?php\n\$node = menu_get_object();\nif (!empty(\$node)) {\n return \$node->package_type == 'profile';\n}\n
+ 'cache' => -1,
+ ),
+ array(
+ 'module' => 'views',
+ 'delta' => 'hosting_site_list-block_client',
+ 'theme' => $theme,
+ 'status' => 1,
+ 'weight' => 0,
+ 'region' => 'content_bottom',
+ 'visibility' => 0,
+ 'pages' => '',
+ //"<?php\n\$node = menu_get_object();\n\$menu_item = menu_get_item();\nif (!empty(\$node) && \$menu_item['number_parts'] == 2) {\n return \$node->type == 'client';\n}\n
+ 'cache' => -1,
+ ),
+ array(
+ 'module' => 'views',
+ 'delta' => 'hosting_site_list-block_client2',
+ 'theme' => $theme,
+ 'status' => 1,
+ 'weight' => 0,
+ 'region' => 'content_bottom',
+ 'visibility' => 0,
+ 'pages' => '',
+ //"<?php\nglobal \$user;\$node = menu_get_object();\n\$menu_item = menu_get_item();\nif (!empty(\$node)) && \$menu_item['number_parts'] == 2) {\n return \$node->type == 'client' && $user->uid != 1;\n}\n
+ 'cache' => -1,
+ ),
+ array(
+ 'module' => 'views',
+ 'delta' => 'hosting_package_list-block_1',
+ 'theme' => $theme,
+ 'status' => 1,
+ 'weight' => 0,
+ 'region' => 'content_bottom',
+ 'visibility' => 0,
+ 'pages' => '',
+ //"<?php\n\$node = menu_get_object();\nif (!empty(\$node)) {\n return \$node->type == 'package' && \$node->package_type != 'profile';\n}\n
+ 'cache' => -1,
+ ),
+ );
+
+ $query = db_insert('block')->fields(array('module', 'delta', 'theme', 'status', 'weight', 'region', 'visibility', 'pages', 'cache'));
+
+ foreach ($blocks as $block) {
+ $query->values($block);
+ }
+ $query->execute();
+
+}
diff --git a/hostmaster.make b/hostmaster.make
new file mode 100644
index 0000000..9ece95a
--- /dev/null
+++ b/hostmaster.make
@@ -0,0 +1,54 @@
+core = 7.x
+api = 2
+
+
+
+; Includes
+
+; This makefile will make sure we get the development code from the Aegir
+; modules instead of the tagged releases.
+includes[hostmaster] = drupal-org.make
+
+
+
+; Aegir core
+
+projects[eldir][download][type] = git
+projects[eldir][download][branch] = 7.x-3.x
+
+projects[hosting][download][type] = git
+projects[hosting][download][branch] = 7.x-3.x
+
+
+
+; Modules - Aegir "golden"
+
+projects[hosting_git][download][type] = git
+projects[hosting_git][download][branch] = 7.x-3.x
+
+projects[hosting_remote_import][download][type] = git
+projects[hosting_remote_import][download][branch] = 7.x-3.x
+
+projects[hosting_site_backup_manager][download][type] = git
+projects[hosting_site_backup_manager][download][branch] = 7.x-3.x
+
+projects[hosting_tasks_extra][download][type] = git
+projects[hosting_tasks_extra][download][branch] = 7.x-3.x
+
+projects[hosting_civicrm][download][type] = git
+projects[hosting_civicrm][download][branch] = 7.x-3.x
+
+projects[hosting_logs][download][type] = git
+projects[hosting_logs][download][branch] = 7.x-3.x
+
+projects[hosting_dns][download][type] = git
+projects[hosting_dns][download][branch] = 7.x-3.x
+
+projects[hosting_https][download][type] = git
+projects[hosting_https][download][branch] = 7.x-3.x
+
+
+; Modules - Dev
+
+projects[devel][subdir] = developer
+projects[devel_debug_log][subdir] = developer
diff --git a/hostmaster.profile b/hostmaster.profile
index 2f62efd..0470ca4 100644
--- a/hostmaster.profile
+++ b/hostmaster.profile
@@ -1,200 +1,16 @@
<?php
-// $Id$
-/**
- * Return an array of the modules to be enabled when this profile is installed.
- *
- * @return
- * An array of modules to be enabled.
- */
-function hostmaster_profile_modules() {
- return array(
- /* core */ 'block', 'color', 'filter', 'help', 'menu', 'node', 'system', 'user', 'watchdog',
- /* contrib */ 'drush', 'cvs_deploy', //'ahah_forms', 'dynamic_subform',
- /* custom */ 'provision', 'provision_apache', 'provision_mysql', 'provision_drupal', 'hosting', 'hosting_task', 'hosting_client', 'hosting_db_server', 'hosting_package', 'hosting_platform', 'hosting_site', 'hosting_web_server');
-}
-
-/**
- * Return a description of the profile for the initial installation screen.
- *
- * @return
- * An array with keys 'name' and 'description' describing this profile.
- */
-function hostmaster_profile_details() {
- return array(
- 'name' => 'Hostmaster',
- 'description' => 'Select this profile to manage the installation and maintenance of hosted Drupal sites.'
- );
-}
-
-/**
- * Perform any final installation tasks for this profile.
- *
- * @return
- * An optional HTML string to display to the user on the final installation
- * screen.
- */
-function hostmaster_profile_final() {
- /* Default node types and default node */
- $types = node_types_rebuild();
-
- //set up needed PROVISION_CONSTANTS
- if (function_exists('provision_init')) {
- provision_init();
- }
- // Initialize the hosting defines
- hosting_init();
-
- /**
- * Generate administrator account
- */
- $user = new stdClass();
- $edit['name'] = 'Administrator';
- $edit['pass'] = user_password();
- $edit['mail'] = valid_email_address($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : 'changeme@example.com';
- $edit['status'] = 1;
- $user = user_save($user, $edit);
- $GLOBALS['user'] = $user;
-
-
- /* Default client */
- $node = new stdClass();
- $node->uid = 1;
- $node->type = 'client';
- $node->email = ($_SERVER['SERVER_ADMIN']) ? $_SERVER['SERVER_ADMIN'] : 'changeme@example.com';
- $node->client_name = 'Administrator';
- $node->status = 1;
- node_save($node);
- variable_set('hosting_default_client', $node->nid);
-
- /* Default database server */
- global $db_url;
- $url = parse_url($db_url);
-
- $node = new stdClass();
- $node->uid = 1;
- $node->type = 'db_server';
- $node->title = $url['host'];
- $node->db_type = $url['scheme'];
- if (_provision_mysql_can_create_database()) {
- $node->db_user = $url['user'];
- $node->db_passwd = $url['pass'];
- }
- else {
- $node->db_user = 'root';
- $node->db_passwd = 'password';
- }
- $node->status = 1;
-
- node_save($node);
- variable_set('hosting_default_db_server', $node->nid);
- variable_set('hosting_own_db_server', $node->nid);
-
- $node = new stdClass();
- $node->uid = 1;
- $node->type = 'web_server';
- $node->title = $_SERVER['HTTP_HOST'];
- $node->script_user = PROVISION_SCRIPT_USER;
- $node->web_group = PROVISION_WEB_GROUP;
- $node->status = 1;
- node_save($node);
- variable_set('hosting_default_web_server', $node->nid);
-
- $node = new stdClass();
- $node->uid = 1;
- $node->title = 'Drupal';
- $node->type = 'package';
- $node->package_type = 'platform';
- $node->short_name = 'drupal';
- $node->status = 1;
- node_save($node);
- $package_id = $node->nid;
-
- $node = new stdClass();
- $node->uid = 1;
- $node->type = 'package_release';
- $node->title = 'Drupal ' . VERSION;
- $node->package = $package_id;
- $node->version = VERSION;
- $node->schema_version = drupal_get_installed_schema_version('system');
- $node->status = 1;
- node_save($node);
- $release_id = $node->nid;
-
- $node = new stdClass();
- $node->uid = 1;
- $node->type = 'platform';
- $node->title = $_SERVER['HTTP_HOST'] . ' (Drupal ' . VERSION . ')';
- $node->publish_path = $_SERVER['DOCUMENT_ROOT'];
- $node->web_server = variable_get('hosting_default_web_server', 3);
- $node->release_id = $release_id;
- $node->status = 1;
- node_save($node);
- variable_set('hosting_default_platform', $node->nid);
- variable_set('hosting_own_platform', $node->nid);
-
-
- #initial configuration of hostmaster - todo
- variable_set('site_name', t('Hostmaster'));
- variable_set('site_frontpage', 'hosting/sites');
-
- // This is set to true, because the node/add/site form needs
- // to use AHAH to create a valid node, and ahah_forms requires clean_urls
- variable_set('clean_url', TRUE);
-
- // This is saved because the config generation script is running via drush, and does not have access to this value
- variable_set('install_url' , $GLOBALS['base_url']);
-
- // add default blocks
- hostmaster_install_add_block('hosting', 'hosting_summary', 'garland', 1, 10, 'left');
- hostmaster_install_add_block('hosting', 'hosting_queues', 'garland', 1, 0, 'right');
- hostmaster_install_add_block('hosting', 'hosting_queues_summary', 'garland', 1, 2, 'right');
-
- // @todo create proper roles, and set up views to be role based
- hostmaster_install_set_permissions(hostmaster_install_get_rid('anonymous user'), array('access content', 'access all views'));
- hostmaster_install_set_permissions(hostmaster_install_get_rid('authenticated user'), array('access content', 'access all views'));
- hostmaster_install_create_role('aegir client');
- // @todo we may need to have a hook here to consider plugins
- hostmaster_install_set_permissions(hostmaster_install_get_rid('aegir client'), array('access content', 'access all views', 'edit own client', 'view client', 'create site', 'delete site', 'view site', 'create backup task', 'create delete task', 'create disable task', 'create enable task', 'create restore task', 'view own tasks', 'view task'));
- menu_rebuild();
-
- node_access_rebuild();
- drupal_goto('hosting/wizard');
-}
-
-/**
- * Set the permission for a certain role
- */
-function hostmaster_install_set_permissions($rid, $perms) {
- db_query('DELETE FROM {permission} WHERE rid = %d', $rid);
- db_query("INSERT INTO {permission} (rid, perm) VALUES (%d, '%s')", $rid, implode(', ', $perms));
-}
+// We need this (empty) file for Drupal to recognize our profile
/**
- * Get the role id for the role name
+ * Implements hook_update_projects_alter().
*/
-function hostmaster_install_get_rid($name) {
- return db_result(db_query("SELECT rid FROM {role} WHERE name ='%s' LIMIT 1", $name));
+function hostmaster_update_projects_alter(&$projects) {
+ // Enable update status for the Hostmaster profile.
+ $modules = system_rebuild_module_data();
+
+ // The module object is shared in the request, so we need to clone it here.
+ $hostmaster = clone $modules['hostmaster'];
+ $hostmaster->info['hidden'] = FALSE;
+ _update_process_info_list($projects, array('hostmaster' => $hostmaster), 'module', TRUE);
}
-
-
-/**
- * Create a role
- */
-function hostmaster_install_create_role($role_name) {
- db_query("INSERT INTO {role} (name) VALUES ('%s')", $role_name);
-}
-
-/**
- * Creates a new block.
- */
-function hostmaster_install_add_block($module, $delta, $theme, $status, $weight, $region, $visibility = 0, $pages = '', $custom = 0, $throttle = 0, $title = '') {
- db_query("INSERT INTO {blocks} (module, delta, theme, status, weight, region, visibility, pages, custom, throttle, title)
- VALUES ('%s', '%s', '%s', %d, %d, '%s', %d, '%s', %d, %d, '%s')",
- $module, $delta, $theme, $status, $weight, $region, $visibility, $pages, $custom, $throttle, $title);
- if ($module == 'block') {
- $box = db_fetch_object(db_query('SELECT * FROM {boxes} WHERE bid=%d', $delta));
- db_query("INSERT INTO {boxes} (bid, body, info, format) VALUES (%d, '%s', '%s', '%s')", $box->bid, $box->body, $box->info, $box->format);
- }
-}
-
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment