function drush_lockr_register in Lockr 7.3
Same name and namespace in other branches
- 8.4 lockr.drush.inc \drush_lockr_register()
- 8.2 lockr.drush.inc \drush_lockr_register()
- 8.3 lockr.drush.inc \drush_lockr_register()
- 7.2 lockr.drush.inc \drush_lockr_register()
- 4.x lockr.drush.inc \drush_lockr_register()
Registers the site with lockr.
File
- ./
lockr.drush.inc, line 39 - Hooks and callbacks for drush.
Code
function drush_lockr_register($email) {
$name = variable_get('site_name', '');
$lc = lockr_client();
$password = drush_get_option('password');
if (!$password) {
return drush_set_error('LOCKR_PASS_REQUIRED', '--password is required');
}
$data = $lc
->requestClientToken($email, $password, $name, $name, drush_get_option('keyring-id'));
if (isset($data['error'])) {
return drush_set_error('LOCKR_CLIENT_TOKEN', $data['error']);
}
$client_token_id = $data['client_token'];
$partner = lockr_get_partner();
try {
if ($partner) {
if ($partner['name'] === 'pantheon') {
$lc
->createPantheonClient($client_token_id);
}
else {
throw new \Exception('Unknown lockr partner');
}
}
else {
$dn = [
'countryName' => 'US',
'stateOrProvinceName' => 'Washington',
'localityName' => 'Tacoma',
'organizationName' => 'Lockr',
];
$result = $lc
->createClientCert($client_token_id, $dn);
$dir = "private://lockr/dev";
_lockr_write_key_files($dir, $result);
variable_set('lockr_cert', "{$dir}/pair.pem");
variable_set('lockr_custom', TRUE);
}
} catch (\Exception $e) {
return drush_set_error('LOCKR_CREATE_CLIENT', $e
->getMessage());
}
drush_log('Site has been registered.', 'success');
}