-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcreate-xmpw.js
executable file
·39 lines (33 loc) · 1.07 KB
/
create-xmpw.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env node
const readline = require('readline');
const xm = require('./index');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
let keyName = '';
let success = false;
rl.question('What is your xMatters subdomain? ', function (subdomain) {
keyName = `XM_KEY_${subdomain.toUpperCase().replace(/\-/g, '_')}`;
rl.question('What is your xMatters password? ', function (password) {
rl.question('Please provide a 32 character encryption key ', function (key) {
subdomain = subdomain.toLowerCase();
const passFilePath = `${subdomain}.xmpw`;
xm.util.EncryptToFile(passFilePath, password, key);
if (subdomain && password && key) success = true;
rl.close();
});
});
});
rl.on('close', function () {
if (success) {
console.log(
'To automatically have xmtoolbox decrypt your password and use it, provide your key as your password or ' +
'set your key in the environment variable: ' +
keyName
);
process.exit(0);
}
console.log('Failure');
process.exit(0);
});