-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Jonathan Budzenski <jon@budzenski.me>
- Loading branch information
1 parent
e64892a
commit 5d0065f
Showing
5 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/dev/build/tasks/os_packages/create_os_package_kibana_yml.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { readFileSync, writeFileSync } from 'fs'; | ||
import { resolve } from 'path'; | ||
import { Build, Config, mkdirp } from '../../lib'; | ||
|
||
export async function createOSPackageKibanaYML(config: Config, build: Build) { | ||
const configReadPath = config.resolveFromRepo('config', 'kibana.yml'); | ||
const configWriteDir = config.resolveFromRepo('build', 'os_packages', 'config'); | ||
const configWritePath = resolve(configWriteDir, 'kibana.yml'); | ||
|
||
await mkdirp(configWriteDir); | ||
|
||
let kibanaYML = readFileSync(configReadPath, { encoding: 'utf8' }); | ||
|
||
[ | ||
[/#pid.file:.*/g, 'pid.file: /run/kibana/kibana.pid'], | ||
[/#logging.dest:.*/g, 'logging.dest: /var/log/kibana/kibana.log'], | ||
].forEach((options) => { | ||
const [regex, setting] = options; | ||
const diff = kibanaYML; | ||
const match = kibanaYML.search(regex) >= 0; | ||
if (match) { | ||
if (typeof setting === 'string') { | ||
kibanaYML = kibanaYML.replace(regex, setting); | ||
} | ||
} | ||
|
||
if (!diff.localeCompare(kibanaYML)) { | ||
throw new Error( | ||
`OS package configuration unmodified. Verify match for ${regex} is available` | ||
); | ||
} | ||
}); | ||
|
||
try { | ||
writeFileSync(configWritePath, kibanaYML, { flag: 'wx' }); | ||
} catch (err) { | ||
if (err.code === 'EEXIST') { | ||
return; | ||
} | ||
throw err; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters