Commit ece4d407 authored by Steven Jones's avatar Steven Jones

Fix code style of provision.drush.inc

parent 29a84b93
<?php
/**
* Drush commands
* @file
* Provisoon Drush commands.
*
*
* This module provides a framework for a Drupal site to manage and install new Drupal sites, using the command line
* Drush utility.
* Drush utility.
*
* It allows for pluggable 'provisioning modules' that can extend and modify the tasks that are taken during installation.
*
* Each site has the following commands that can be run on it.
*
* Implemented :
* Implemented :
* install - Install a new Drupal site. The install command uses 3 separate hooks to do its job,
* namely hook_pre_provision_install(), hook_provision_install() and hook_post_provision_install().
* verify - Recreate all configuration files, to be in synch with changes in the front end. And test that they are correct.
......@@ -50,7 +51,7 @@ if ($name['name'] == 'root') {
include_once('provision.inc');
/**
* implementation of hook_drush_init().
* Implements hook_drush_init().
*
* This will abort any process running drush if the load is critical.
*
......@@ -104,14 +105,14 @@ function provision_drush_command() {
'description' => dt('Generate a back up for the site.'),
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT
);
$items['provision-enable'] = array(
'arguments' => array('domain.com' => dt('The domain of the site to enable (only if enabled).')),
'description' => 'Enable a disabled site.',
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT
);
$items['provision-disable'] = array(
'arguments' => array('domain.com' => dt('The domain of the site to disable (only if disabled).')),
'arguments' => array('domain.com' => dt('The domain of the site to disable (only if disabled).')),
'description' => 'Disable a site.',
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT
);
......@@ -127,11 +128,11 @@ function provision_drush_command() {
);
$items['provision-verify'] = array(
'arguments' => array('domain.com' => dt('The domain of the site to verify).')),
'arguments' => array('domain.com' => dt('The domain of the site to verify).')),
'description' => 'Verify that the provisioning framework is correctly installed.',
'bootstrap' => DRUSH_BOOTSTRAP_DRUSH,
'bootstrap' => DRUSH_BOOTSTRAP_DRUSH,
);
$items['provision-restore'] = array(
'description' => 'Restore the site to a previous backup. This will also generate a backup of the site as it was.',
'arguments' => array('domain.com' => dt('The domain of the site to be restored'),
......@@ -160,7 +161,7 @@ function provision_drush_command() {
'/path/to/platform' => dt('The platform to clone the site to.')),
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT
);
$items['provision-delete'] = array(
'description' => 'Delete a site.',
'bootstrap' => DRUSH_BOOTSTRAP_DRUSH
......@@ -170,7 +171,7 @@ function provision_drush_command() {
'description' => 'Generate a one-time login reset URL.',
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT
);
$items['provision-backup_delete'] = array(
'description' => 'Delete a backup file.',
'arguments' => array('backup-file' => dt('The backup file to delete. This will be a gzipped tarball.')),
......@@ -196,7 +197,7 @@ function provision_drush_command() {
'you@example.com' => dt('The email account to send a welcome mail to'),
),
);
$items['backend-parse'] = array(
'description' => dt('Parse the output of --backend commands to a human readable form'),
'bootstrap' => DRUSH_BOOTSTRAP_DRUSH,
......@@ -205,9 +206,9 @@ function provision_drush_command() {
return $items;
}
function drush_provision_save($alias = null) {
if (drush_get_option('delete', false)) {
// remove an existing alias
function drush_provision_save($alias = NULL) {
if (drush_get_option('delete', FALSE)) {
// remove an existing alias
$config = new Provision_Config_Drushrc_Alias($alias);
$config->unlink();
}
......@@ -228,7 +229,7 @@ function _provision_default_web_group() {
$common_groups = array(
'www',
'httpd',
'www-data',
'www-data',
'apache',
'webservd',
'nogroup',
......@@ -241,7 +242,7 @@ function _provision_default_web_group() {
break;
}
}
return null;
return NULL;
}
/**
......@@ -251,7 +252,7 @@ function _provision_default_web_group() {
* useful for calculating sane load threshold.
*
* On Linux, this parses /proc/cpuinfo and looks for lines like this:
*
*
* processor : 0
* ...
* processor : 1
......@@ -307,18 +308,18 @@ function provision_count_cpus() {
*
* @see sys_getloadavg()
*/
function provision_load_critical($load = null, $threshold = null) {
function provision_load_critical($load = NULL, $threshold = NULL) {
if (is_null($load)) {
$load = sys_getloadavg();
}
if (is_null($threshold)) {
if ($ncpus = provision_count_cpus()) {
$threshold = $ncpus * 5;
} else {
}
else {
// can't determine the number of CPU, we hardcode at load 10
$threshold = 10;
}
}
return ($load[0] > $threshold);
}
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