Skip to content
provision.install 3.11 KiB
Newer Older
// $Id$
/**
 * @file Install file for provision module
 */

/**
 * Configure the module weights for the core modules, to ensure that the
 * hooks always fire in a predictable pattern.
 *
 * Provision module - does necessary setup for an task to occur.
 * Mysql module - creates the necessary database settings
 * Drupal module - manages installations and the like.
 * Apache module - ensures that web server can see the site
 */
function provision_install() {
  db_query("UPDATE {system} SET weight = 0 WHERE type='module' AND name='provision'");
  db_query("UPDATE {system} SET weight = 1 WHERE type='module' AND name='provision_mysql'");
  db_query("UPDATE {system} SET weight = 2 WHERE type='module' AND name='provision_drupal'");
  db_query("UPDATE {system} SET weight = 3 WHERE type='module' AND name='provision_apache'");

}
 * Make sure that the POSIX library is available, and that we are not running on a windows based host.
 * Make sure that site is not installed in a subdirectory, but that the DocumentRoot directive points at the installation.
 * Make sure the site is not being installed in sites/default
 * @TODO: make sure the required modules are installed in the right places
 */
function provision_requirements($phase) {
  $t = get_t();
  $has_posix = function_exists('posix_uname');

  $requirements['posix']['title'] = $t('POSIX library');
  $requirements['posix']['value'] = ($has_posix) ? $t('Enabled') : $t('Not found');

  if (!$has_posix) {
    $requirements['posix']['description'] = $t('<p>The <a href="@helpurl">POSIX library</a> has not been compiled into PHP.</p>', array("@helpurl" => 'http://www.php.net/manual/en/book.posix.php')) .
      $t("<p><strong>This library is not available on Windows based hosts</strong>, and you will not be able to install this system.</p>");
    $requirements['posix']['severity'] = REQUIREMENT_ERROR;
  }

  $is_in_docroot = $base_path == '/';
  $docroot = $_SERVER['DOCUMENT_ROOT']; 
  $requirements['docroot']['title'] = $t("Document root");
  $requirements['docroot']['value'] = ($is_in_docroot) ? $t('Correct') : 
    $t("Installed in the @subdir sub directory of @root", array('@root' => rtrim($docroot, '/'), '@subdir' => trim($base_path, '/')));
  if (!$is_in_docroot) {
    $requirements['docroot']['value'] = $t("Drupal has been installed in a subdirectory. 
      You will need to modify your virtual host configuration to point a ServerName directly at the installation path.");
    $requirements['docroot']['severity'] = REQUIREMENT_ERROR;
  }
  $conf_path = (conf_path() == 'sites/default');
  $requirements['confpath']['title'] = $t('Configuration path');
  $requirements['confpath']['value'] = conf_path();
  if (!$conf_path) {
    $requirements['confpath']['description'] = $t('Provision may only be installed as the default site in a Drupal installation. It is currently installed in the "sites/@url" directory. Please move this directory to "sites/default".', array('@url' => $url['host']));
    $requirements['confpath']['severity'] = REQUIREMENT_ERROR;
  }