From f6b6bcfb4f4819a84129c9eaec1588b0d2f40694 Mon Sep 17 00:00:00 2001 From: Jonathan Budzenski Date: Tue, 14 Jun 2016 11:50:40 -0500 Subject: [PATCH] [build] Add data directory that plugins can write to. Closes #7157 Former-commit-id: 5b195343140663dd732ff12dff2d1dab1078b4e9 --- installedPlugins/.empty | 0 tasks/build/installed_plugins.js | 1 + tasks/build/os_packages.js | 5 ++++- tasks/build/package_scripts/post_install.sh | 2 ++ tasks/build/package_scripts/post_remove.sh | 4 ++++ tasks/config/packages.js | 2 ++ 6 files changed, 13 insertions(+), 1 deletion(-) delete mode 100644 installedPlugins/.empty diff --git a/installedPlugins/.empty b/installedPlugins/.empty deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/tasks/build/installed_plugins.js b/tasks/build/installed_plugins.js index 7d8d6618ff488..5d2fcc4d4ed37 100644 --- a/tasks/build/installed_plugins.js +++ b/tasks/build/installed_plugins.js @@ -1,5 +1,6 @@ module.exports = function (grunt) { grunt.registerTask('_build:installedPlugins', function () { grunt.file.mkdir('build/kibana/installedPlugins'); + grunt.file.mkdir('build/kibana/installedPlugins/.data'); }); }; diff --git a/tasks/build/os_packages.js b/tasks/build/os_packages.js index c739bf122e1c2..7a869ca7a2f77 100644 --- a/tasks/build/os_packages.js +++ b/tasks/build/os_packages.js @@ -44,9 +44,11 @@ export default (grunt) => { '--template-value', `optimizeDir=${packages.path.home}/optimize`, '--template-value', `configDir=${packages.path.conf}`, '--template-value', `pluginsDir=${packages.path.plugins}`, + '--template-value', `dataDir=${packages.path.data}`, //config folder is moved to path.conf, exclude {path.home}/config //uses relative path to --prefix, strip the leading / - '--exclude', `${packages.path.home.slice(1)}/config` + '--exclude', `${packages.path.home.slice(1)}/config`, + '--exclude', `${packages.path.home.slice(1)}/installedPlugins/.data` ]; const debOptions = [ '-t', 'deb', @@ -59,6 +61,7 @@ export default (grunt) => { const args = [ `${buildDir}/=${packages.path.home}/`, `${buildDir}/config/=${packages.path.conf}/`, + `${buildDir}/installedPlugins/.data/=${packages.path.data}/`, `${servicesByName.sysv.outputDir}/etc/=/etc/`, `${servicesByName.systemd.outputDir}/lib/=/lib/` ]; diff --git a/tasks/build/package_scripts/post_install.sh b/tasks/build/package_scripts/post_install.sh index beef49af21753..bc31f19f19953 100644 --- a/tasks/build/package_scripts/post_install.sh +++ b/tasks/build/package_scripts/post_install.sh @@ -15,3 +15,5 @@ if ! user_check "<%= user %>" ; then user_create "<%= user %>" fi chown -R <%= user %>:<%= group %> <%= optimizeDir %> +chown <%= user %>:<%= group %> <%= dataDir %> +chown <%= user %>:<%= group %> <%= pluginsDir %> diff --git a/tasks/build/package_scripts/post_remove.sh b/tasks/build/package_scripts/post_remove.sh index d0ac977cdd3b2..c1499c2940d83 100644 --- a/tasks/build/package_scripts/post_remove.sh +++ b/tasks/build/package_scripts/post_remove.sh @@ -59,4 +59,8 @@ if [ "$REMOVE_DIRS" = "true" ]; then if [ -d "<%= configDir %>" ]; then rmdir --ignore-fail-on-non-empty "<%= configDir %>" fi + + if [ -d "<%= dataDir %>" ]; then + rmdir --ignore-fail-on-non-empty "<%= dataDir %>" + fi fi diff --git a/tasks/config/packages.js b/tasks/config/packages.js index 3162c4bffff33..1c6aef8c2934c 100644 --- a/tasks/config/packages.js +++ b/tasks/config/packages.js @@ -14,6 +14,7 @@ export default (grunt) => { const FOLDER_CONFIG = '/etc/kibana'; const FOLDER_HOME = '/usr/share/kibana'; + const FOLDER_DATA = '/var/lib/kibana'; const FOLDER_PLUGINS = `${FOLDER_HOME}/installedPlugins`; const FILE_KIBANA_CONF = `${FOLDER_CONFIG}/kibana.yml`; @@ -43,6 +44,7 @@ export default (grunt) => { version: VERSION, path: { conf: FOLDER_CONFIG, + data: FOLDER_DATA, plugins: FOLDER_PLUGINS, home: FOLDER_HOME, kibanaBin: FILE_KIBANA_BINARY,