You are here

function hosting_init in Hosting 5

Same name and namespace in other branches
  1. 6.2 hosting.module \hosting_init()
  2. 7.4 hosting.module \hosting_init()
  3. 7.3 hosting.module \hosting_init()

Implementation of hook_init

File

./hosting.module, line 153
Hosting module

Code

function hosting_init() {

  // Definitions for the default platforms, clients etc.
  // Done to avoid using 'magic numbers'
  define('HOSTING_DEFAULT_CLIENT', variable_get('hosting_default_client', 1));
  define('HOSTING_DEFAULT_DB_SERVER', variable_get('hosting_default_db_server', 2));
  define('HOSTING_DEFAULT_WEB_SERVER', variable_get('hosting_default_web_server', 3));
  define('HOSTING_DEFAULT_PLATFORM', variable_get('hosting_default_platform', 6));
  define('HOSTING_OWN_DB_SERVER', variable_get('hosting_own_db_server', 2));
  define('HOSTING_OWN_WEB_SERVER', variable_get('hosting_own_web_server', 3));
  define('HOSTING_OWN_PLATFORM', variable_get('hosting_own_platform', 6));

  // These defaults could be temporary.
  $info = posix_getgrgid(posix_getgid());
  define('HOSTING_DEFAULT_WEB_GROUP', $info['name']);
  $user = get_current_user();
  if ($user == 'root') {
    $user = 'aegir';

    # a better default than root
  }
  define('HOSTING_DEFAULT_SCRIPT_USER', $user);
  define('HOSTING_DEFAULT_RESTART_CMD', _hosting_default_restart_cmd());
  $path = $_SERVER['PWD'] ? $_SERVER['PWD'] : $_SERVER['DOCUMENT_ROOT'];
  define('HOSTING_DEFAULT_DOCROOT_PATH', rtrim($path, '/'));
  $parts = explode("/", rtrim($path, '/'));
  array_pop($parts);
  define('HOSTING_DEFAULT_PARENT_PATH', rtrim(implode("/", $parts), '/'));
  define('HOSTING_DEFAULT_BACKUP_PATH', HOSTING_DEFAULT_PARENT_PATH . '/backups');
  define('HOSTING_DEFAULT_CONFIG_PATH', HOSTING_DEFAULT_PARENT_PATH . '/config');
  define('HOSTING_DEFAULT_VHOST_PATH', HOSTING_DEFAULT_CONFIG_PATH . '/vhost.d');
}