function drush_hosting_setup

7.x-3.x hosting.module drush_hosting_setup()

Initial hosting setup drush command.

Runs the 'hosting-dispatch' command, and sets up the crontab.

File

./hosting.module, line 642
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 = implode("\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');
    }
  }
}