/**
  * Create AWS IAM Policy that S3 Uploads requires
  *
  * It's typically not a good idea to use access keys that have full access to your S3 account,
  * as if the keys are compromised through the WordPress site somehow, you don't
  * want to give full control via those keys.
  *
  * @subcommand generate-iam-policy
  */
 public function generate_iam_policy()
 {
     WP_Cli::print_value($this->get_iam_policy());
 }
 /**
  * Download a remote site.
  * 
  * @subcommand download
  * @synopsis --site-id=<site-id> [--type=<type>]
  */
 public function download($args, $assoc_args)
 {
     $site_id = $assoc_args['site-id'];
     $this->set_account();
     if (empty($assoc_args['type'])) {
         $assoc_args['type'] = 'complete';
     }
     WP_CLI::line(sprintf("Initiating %s archive.", $assoc_args['type']));
     $args = array('endpoint' => '/site/' . $site_id . '/download', 'method' => 'POST', 'body' => array('type' => $assoc_args['type']));
     $response = $this->api_request($args);
     if (is_wp_error($response)) {
         WP_CLI::error($response->get_error_message());
     }
     do {
         $args = array('endpoint' => '/site/' . $site_id . '/download', 'method' => 'GET');
         $response = $this->api_request($args);
         if (!is_wp_error($response) && !empty($response->status) && $response->status == 'error-status') {
             WP_Cli::line('Backup status: ' . strip_tags($response->backup_progress));
             sleep(15);
         }
     } while (!is_wp_error($response) && $response->status != 'backup-complete');
     if (is_wp_error($response)) {
         WP_CLI::error($response->get_error_message());
     }
     WP_CLI::launch(sprintf("wget '%s'", $response->url));
     WP_CLI::success("Site downloaded.");
 }
Example #3
0
 private static function wow()
 {
     $doge = array('wow', 'many', 'such', 'so');
     $words = array('finish', 'done', 'end', 'deploy');
     WP_CLI::line('');
     WP_Cli::success($doge[array_rand($doge, 1)] . ' ' . $words[array_rand($words, 1)] . '!');
 }
Example #4
0
 protected static function _prepare_and_extract($args)
 {
     $out = array();
     self::$_env = $args[0];
     $errors = self::_validate_config();
     if ($errors !== true) {
         foreach ($errors as $error) {
             WP_Cli::error($error);
         }
         return false;
     }
     $out = self::config_constants_to_array();
     $out['env'] = self::$_env;
     $out['db_user'] = escapeshellarg($out['db_user']);
     $out['db_host'] = escapeshellarg($out['db_host']);
     $out['db_password'] = escapeshellarg($out['db_password']);
     $out['ssh_port'] = isset($out['ssh_port']) ? intval($out['ssh_port']) : 22;
     $out['excludes'] = explode(':', $out['excludes']);
     return $out;
 }