open-vault/ui/scripts/start-vault.js
Matthew Irish 5ca987662f
UI - new token renew banner (#5662)
* move warning banner out of token-expire-warning and into user menu
* check renewal status every 5s, and resume auto-renew if a user becomes active again
* use a link in the token-expire-warning
* add test for new expiration functionality
* fix license test
* use features helper in license test
* fix import
* use yarn 1.12.1
* remove mirage
* skip some tests for now
* use eslintignore
* logout after auth tests
* use new alert-banner for auth info warning
* add data-test selector back
* move identity back to a button, and style button.link
* make the warning message the right color
* fix shamir test
* review feedback
2018-11-05 10:56:59 -06:00

75 lines
1.6 KiB
JavaScript
Executable file

#!/usr/bin/env node
/* eslint-disable */
if (process.argv[2]) {
process.kill(process.argv[2], 'SIGINT');
process.exit(0);
}
process.env.TERM = 'dumb';
var fs = require('fs');
var path = require('path');
var readline = require('readline');
var spawn = require('child_process').spawn;
var vault = spawn('vault', [
'server',
'-dev',
'-dev-ha',
'-dev-transactional',
'-dev-root-token-id=root',
'-dev-listen-address=127.0.0.1:9200',
]);
var output = '';
var unseal, root;
readline
.createInterface({
input: vault.stdout,
terminal: false,
})
.on('line', function(line) {
output = output + line;
console.log(line);
var unsealMatch = output.match(/Unseal Key: (.+)$/m);
if (unsealMatch && !unseal) {
unseal = unsealMatch[1];
}
var rootMatch = output.match(/Root Token: (.+)$/m);
if (rootMatch && !root) {
root = rootMatch[1];
}
if (root && unseal) {
fs.writeFile(
path.join(process.cwd(), 'tests/helpers/vault-keys.js'),
`export default ${JSON.stringify({ unseal, root }, null, 2)}`
);
console.log('VAULT SERVER READY');
}
});
vault.stderr.on('data', function(data) {
console.log(data.toString());
});
vault.on('close', function(code) {
console.log(`child process exited with code ${code}`);
process.exit();
});
vault.on('error', function(error) {
console.log(`child process errored: ${error}`);
process.exit();
});
var pidFile = 'vault-ui-integration-server.pid';
process.on('SIGINT', function() {
vault.kill('SIGINT');
process.exit();
});
process.on('exit', function() {
vault.kill('SIGINT');
});
fs.writeFile(pidFile, process.pid);