function drush_hosting_setup in Hostmaster (Aegir) 6
Initial hosting setup drush command.
Runs the 'hosting-dispatch' command, and sets up the crontab.
File
- modules/
hosting/ hosting.module, line 428 - Hosting module.
Code
function drush_hosting_setup() {
if (drush_confirm("This command will replace your crontab for this user. continue?")) {
variable_set('hosting_dispatch_enabled', FALSE);
// attempt to run the dispatch command, to make sure it runs without the queue being enabled.
variable_set('hosting_dispatch_enabled', TRUE);
drush_print(_hosting_dispatch_cmd());
exec(_hosting_dispatch_cmd(), $return, $code);
variable_set('hosting_dispatch_enabled', FALSE);
$return = join("\n", $return);
$data = unserialize($return);
if ($code == DRUSH_SUCCESS) {
variable_set('hosting_dispatch_enabled', TRUE);
drush_log(t("Dispatch command was run successfully"), 'success');
_hosting_setup_cron();
}
else {
drush_set_error('DRUSH_FRAMEWORK_ERROR', dt("Dispatch command could not be run. Returned: \n@return", array(
'@return' => $return,
)));
}
if (drush_get_error()) {
drush_log(t("The command did not complete successfully, please fix the issues and re-run this script"), 'error');
}
}
}