Skip to content

Commit

Permalink
Merge pull request elastic#7440 from jbudz/plugin-paths
Browse files Browse the repository at this point in the history
[plugin installer] check multiple default paths for config
  • Loading branch information
jbudz authored Jun 15, 2016
2 parents b32949d + 3ce2c5f commit a167253
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/cli_plugin/install/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { fromRoot } from '../../utils';
import fs from 'fs';
import install from './install';
import Logger from '../lib/logger';
import pkg from '../../utils/package_json';
import { parse, parseMilliseconds } from './settings';
import { find } from 'lodash';

function processCommand(command, options) {
let settings;
Expand All @@ -18,6 +20,24 @@ function processCommand(command, options) {
install(settings, logger);
}

function getDefaultConfigPath() {
const paths = [
fromRoot('config/kibana.yml'),
'/etc/kibana/kibana.yml'
];

const availablePath = find(paths, configPath => {
try {
fs.accessSync(configPath, fs.R_OK);
return true;
} catch (e) {
//Check the next path
}
});

return availablePath || paths[0];
}

export default function pluginInstall(program) {
program
.command('install <plugin/url>')
Expand All @@ -26,7 +46,7 @@ export default function pluginInstall(program) {
.option(
'-c, --config <path>',
'path to the config file',
fromRoot('config/kibana.yml')
getDefaultConfigPath()
)
.option(
'-t, --timeout <duration>',
Expand Down

0 comments on commit a167253

Please sign in to comment.