array('domain.com' => dt('The domain of the site to install.')), 'description' => dt('Provision a new site using the provided data.'), 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT ); $items['provision import'] = array( 'arguments' => array('domain.com' => dt('The domain of the site to import.')), 'description' => dt('Turn an already running site into a provisioned site.'), 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT ); $items['provision backup'] = array( 'arguments' => array('domain.com' => dt('The domain of the site to back up.')), 'optional arguments' => array('backup-file' => dt('The file to save the backup to. This will be a gzipped tarball.')), '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).')), 'description' => 'Disable a site.', 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT ); $items['provision verify'] = array( 'arguments' => array('domain.com' => dt('The domain of the site to verify).')), 'description' => 'Verify that the provisioning framework is correctly installed.', 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT, ); $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'), 'site_backup.tar.gz' => dt('The backup to restore the site to.')), 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT ); $items['provision deploy'] = array( 'description' => 'Deploy an existing backup to a new url.', 'arguments' => array('domain.com' => dt('The domain to deploy the site package to.'), 'site_backup.tar.gz' => dt('The backup to deploy.')), 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT ); $items['provision migrate'] = array( 'description' => 'Migrate a site between platforms.', 'arguments' => array('domain.com' => dt('The domain to migrate. Any outstanding updates will be run.'), '/path/to/platform' => dt('The platform to migrate the site to.')), 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT ); $items['provision clone'] = array( 'description' => 'Clone a site between platforms.', 'arguments' => array('domain.com' => dt('The domain to clone. Any outstanding updates will be run.'), 'new.domain.com' => dt('The new domain name to use.'), '/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_DRUPAL_ROOT ); $items['hostmaster migrate'] = array( 'description' => dt('Migrate an instance of the Hostmaster front end to a new platform'), 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT, 'arguments' => array( 'example.com' => dt('The name of the site to migrate'), '/path/to/platform' => dt('The platform to migrate the site to.') ), ); $items['hostmaster make'] = array( 'description' => dt('Build a platform containing the Hostmaster user interface for provision.'), 'bootstrap' => DRUSH_BOOTSTRAP_DRUSH, 'arguments' => array( '/path/to/platform' => dt('The path to create the platform in.') ), ); $items['hostmaster park'] = array( 'description' => dt('Prepare the site to be migrated to a new platform.'), 'arguments' => array( 'example.com' => dt('The url of the site being migrated.')), ); $items['hostmaster unpark'] = array( 'description' => dt('Complete the migration of the site to a new platform.'), 'arguments' => array( 'example.com' => dt('The url of the site being migrated.')), ); return $items; } function drush_provision_hostmaster_make($platform) { drush_backend_invoke('make', array(dirname(__FILE__) . '/aegir.make', $platform)); } /** * Generate a provision.settings.php file to configure provision */ function _provision_generate_config() { $exists = provision_path_exists(drush_get_option('docroot_path') . '/drushrc.php'); if ($exists) { drush_log(dt("Found existing drushrc.php file")); provision_path("chmod", drush_get_option('docroot_path') . '/drushrc.php', 0600, dt('Changed permissions of drushrc.php to @confirm'), dt('Could not change permissions of drushrc.php to @confirm')); } else { drush_log(dt("Generating drushrc.php file")); } provision_save_platform_data(); provision_path("chmod", drush_get_option('docroot_path') . '/drushrc.php', 0400, dt('Changed permissions of drushrc.php to @confirm'), dt('Could not change permissions of drushrc.php to @confirm')); return TRUE; } function _provision_default_restart_cmd() { $command = '/usr/sbin/apachectl'; # a proper default for most of the world foreach (explode(':', $_SERVER['PATH']) as $path) { $options[] = "$path/apache2ctl"; $options[] = "$path/apachectl"; } # try to detect the apache restart command $options[] = '/usr/local/sbin/apachectl'; # freebsd $options[] = '/usr/sbin/apache2ctl'; # debian + apache2 $options[] = $command; foreach ($options as $test) { if (is_executable($test)) { $command = $test; break; } } return "sudo $command graceful"; } function _provision_default_web_group() { $info = posix_getgrgid(posix_getgid()); $common_groups = array( 'httpd', 'www-data', 'apache', 'nogroup', 'nobody', $info['name']); foreach ($common_groups as $group) { if (provision_posix_groupname($group)) { return $group; break; } } return null; }