From 9be15fb7b9f8e3008c49f92cefe713efceb322b8 Mon Sep 17 00:00:00 2001 From: Jonathan Budzenski Date: Mon, 13 Jun 2016 10:55:31 -0500 Subject: [PATCH 1/2] [plugin installer] check multiple default paths for config --- src/cli_plugin/install/index.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/cli_plugin/install/index.js b/src/cli_plugin/install/index.js index 177666bca5144..198b7dac61f80 100644 --- a/src/cli_plugin/install/index.js +++ b/src/cli_plugin/install/index.js @@ -1,4 +1,5 @@ import { fromRoot } from '../../utils'; +import fs from 'fs'; import install from './install'; import Logger from '../lib/logger'; import pkg from '../../utils/package_json'; @@ -18,6 +19,25 @@ function processCommand(command, options) { install(settings, logger); } +function getDefaultConfigPath() { + const paths = [ + fromRoot('config/kibana.yml'), + '/etc/kibana/kibana.yml' + ]; + + let defaultPath = paths[0]; + paths.some(configPath => { + try { + fs.accessSync(configPath, fs.R_OK); + defaultPath = configPath; + return true; + } catch (e) { + //Check the next path + } + }); + return defaultPath; +} + export default function pluginInstall(program) { program .command('install ') @@ -26,7 +46,7 @@ export default function pluginInstall(program) { .option( '-c, --config ', 'path to the config file', - fromRoot('config/kibana.yml') + getDefaultConfigPath() ) .option( '-t, --timeout ', From 3ce2c5ffe74dcade58c0ba6be2a477840ea285c3 Mon Sep 17 00:00:00 2001 From: Jonathan Budzenski Date: Tue, 14 Jun 2016 10:06:04 -0500 Subject: [PATCH 2/2] [plugin installer] Use find instead of some when looking for path --- src/cli_plugin/install/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cli_plugin/install/index.js b/src/cli_plugin/install/index.js index 198b7dac61f80..cb5bdaf69bc69 100644 --- a/src/cli_plugin/install/index.js +++ b/src/cli_plugin/install/index.js @@ -4,6 +4,7 @@ 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; @@ -25,17 +26,16 @@ function getDefaultConfigPath() { '/etc/kibana/kibana.yml' ]; - let defaultPath = paths[0]; - paths.some(configPath => { + const availablePath = find(paths, configPath => { try { fs.accessSync(configPath, fs.R_OK); - defaultPath = configPath; return true; } catch (e) { //Check the next path } }); - return defaultPath; + + return availablePath || paths[0]; } export default function pluginInstall(program) {