diff --git a/src/cli_plugin/install/index.js b/src/cli_plugin/install/index.js index 177666bca5144..cb5bdaf69bc69 100644 --- a/src/cli_plugin/install/index.js +++ b/src/cli_plugin/install/index.js @@ -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; @@ -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 ') @@ -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 ',