mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Backport PR #6674
This commit is contained in:
parent
bc7bc228c1
commit
54e763c95d
7 changed files with 99 additions and 11 deletions
|
@ -67,7 +67,7 @@ module.exports = function (grunt) {
|
||||||
|
|
||||||
grunt.config.merge(config);
|
grunt.config.merge(config);
|
||||||
|
|
||||||
config.userScriptsDir = __dirname + '/build/userScripts';
|
config.packageScriptsDir = __dirname + '/tasks/build/package_scripts';
|
||||||
// ensure that these run first, other configs need them
|
// ensure that these run first, other configs need them
|
||||||
config.services = require('./tasks/config/services')(grunt);
|
config.services = require('./tasks/config/services')(grunt);
|
||||||
config.platforms = require('./tasks/config/platforms')(grunt);
|
config.platforms = require('./tasks/config/platforms')(grunt);
|
||||||
|
|
|
@ -6,7 +6,7 @@ module.exports = function (grunt) {
|
||||||
const exec = require('../utils/exec');
|
const exec = require('../utils/exec');
|
||||||
const targetDir = config.get('target');
|
const targetDir = config.get('target');
|
||||||
const version = config.get('pkg.version');
|
const version = config.get('pkg.version');
|
||||||
const userScriptsDir = config.get('userScriptsDir');
|
const packageScriptsDir = config.get('packageScriptsDir');
|
||||||
const servicesByName = indexBy(config.get('services'), 'name');
|
const servicesByName = indexBy(config.get('services'), 'name');
|
||||||
|
|
||||||
grunt.registerTask('_build:osPackages', function () {
|
grunt.registerTask('_build:osPackages', function () {
|
||||||
|
@ -22,15 +22,19 @@ module.exports = function (grunt) {
|
||||||
'--package', targetDir,
|
'--package', targetDir,
|
||||||
'-s', 'dir', // input type
|
'-s', 'dir', // input type
|
||||||
'--name', 'kibana',
|
'--name', 'kibana',
|
||||||
'--description', 'Explore\ and\ visualize\ your\ Elasticsearch\ data.',
|
'--description', 'Explore\ and\ visualize\ your\ Elasticsearch\ data',
|
||||||
'--version', version,
|
'--version', version,
|
||||||
'--url', 'https://www.elastic.co',
|
'--url', 'https://www.elastic.co',
|
||||||
'--vendor', 'Elasticsearch,\ Inc.',
|
'--vendor', 'Elasticsearch,\ Inc.',
|
||||||
'--maintainer', 'Kibana Team\ \<info@elastic.co\>',
|
'--maintainer', 'Kibana Team\ \<info@elastic.co\>',
|
||||||
'--license', 'Apache\ 2.0',
|
'--license', 'Apache\ 2.0',
|
||||||
'--after-install', resolve(userScriptsDir, 'installer.sh'),
|
'--after-install', resolve(packageScriptsDir, 'post_install.sh'),
|
||||||
'--after-remove', resolve(userScriptsDir, 'remover.sh'),
|
'--before-install', resolve(packageScriptsDir, 'pre_install.sh'),
|
||||||
'--config-files', '/opt/kibana/config/kibana.yml'
|
'--before-remove', resolve(packageScriptsDir, 'pre_remove.sh'),
|
||||||
|
'--after-remove', resolve(packageScriptsDir, 'post_remove.sh'),
|
||||||
|
'--config-files', '/opt/kibana/config/kibana.yml',
|
||||||
|
'--template-value', 'user=kibana',
|
||||||
|
'--template-value', 'group=kibana'
|
||||||
];
|
];
|
||||||
|
|
||||||
const files = buildDir + '/=/opt/kibana';
|
const files = buildDir + '/=/opt/kibana';
|
||||||
|
|
17
tasks/build/package_scripts/post_install.sh
Normal file
17
tasks/build/package_scripts/post_install.sh
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
user_check() {
|
||||||
|
getent passwd "$1" > /dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
user_create() {
|
||||||
|
# Create a system user. A system user is one within the system uid range and
|
||||||
|
# has no expiration
|
||||||
|
useradd -r "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
if ! user_check "<%= user %>" ; then
|
||||||
|
user_create "<%= user %>"
|
||||||
|
fi
|
||||||
|
chown -R <%= user %>:<%= group %> /opt/kibana/optimize
|
42
tasks/build/package_scripts/post_remove.sh
Normal file
42
tasks/build/package_scripts/post_remove.sh
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
user_check() {
|
||||||
|
getent passwd "$1" > /dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
user_remove() {
|
||||||
|
userdel "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
REMOVE_USER=false
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
# Includes cases for all valid arguments, exit 1 otherwise
|
||||||
|
# Debian
|
||||||
|
purge)
|
||||||
|
REMOVE_USER=true
|
||||||
|
;;
|
||||||
|
|
||||||
|
remove|failed-upgrade|abort-install|abort-upgrade|disappear|upgrade|disappear)
|
||||||
|
;;
|
||||||
|
|
||||||
|
# Red Hat
|
||||||
|
0)
|
||||||
|
REMOVE_USER=true
|
||||||
|
;;
|
||||||
|
|
||||||
|
1)
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo "post remove script called with unknown argument \`$1'" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ "$REMOVE_USER" = "true" ]; then
|
||||||
|
if user_check "<%= user %>" ; then
|
||||||
|
user_remove "<%= user %>"
|
||||||
|
fi
|
||||||
|
fi
|
14
tasks/build/package_scripts/pre_install.sh
Normal file
14
tasks/build/package_scripts/pre_install.sh
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if command -v systemctl >/dev/null && systemctl is-active kibana.service >/dev/null; then
|
||||||
|
systemctl --no-reload stop kibana.service
|
||||||
|
elif [ -x /etc/init.d/kibana ]; then
|
||||||
|
if command -v invoke-rc.d >/dev/null; then
|
||||||
|
invoke-rc.d kibana stop
|
||||||
|
elif command -v service >/dev/null; then
|
||||||
|
service kibana stop
|
||||||
|
else
|
||||||
|
/etc/init.d/kibana stop
|
||||||
|
fi
|
||||||
|
fi
|
16
tasks/build/package_scripts/pre_remove.sh
Normal file
16
tasks/build/package_scripts/pre_remove.sh
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo -n "Stopping kibana service..."
|
||||||
|
if command -v systemctl >/dev/null && systemctl is-active kibana.service >/dev/null; then
|
||||||
|
systemctl --no-reload stop kibana.service
|
||||||
|
elif [ -x /etc/init.d/kibana ]; then
|
||||||
|
if command -v invoke-rc.d >/dev/null; then
|
||||||
|
invoke-rc.d kibana stop
|
||||||
|
elif command -v service >/dev/null; then
|
||||||
|
service kibana stop
|
||||||
|
else
|
||||||
|
/etc/init.d/kibana stop
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo " OK"
|
|
@ -2,7 +2,6 @@ module.exports = function createServices(grunt) {
|
||||||
const { resolve } = require('path');
|
const { resolve } = require('path');
|
||||||
const { appendFileSync } = require('fs');
|
const { appendFileSync } = require('fs');
|
||||||
const exec = require('../utils/exec');
|
const exec = require('../utils/exec');
|
||||||
const userScriptsDir = grunt.config.get('userScriptsDir');
|
|
||||||
|
|
||||||
grunt.registerTask('_build:pleaseRun', function () {
|
grunt.registerTask('_build:pleaseRun', function () {
|
||||||
// TODO(sissel): Detect if 'pleaserun' is found, and provide a useful error
|
// TODO(sissel): Detect if 'pleaserun' is found, and provide a useful error
|
||||||
|
@ -23,9 +22,5 @@ module.exports = function createServices(grunt) {
|
||||||
'/opt/kibana/bin/kibana'
|
'/opt/kibana/bin/kibana'
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
grunt.file.mkdir(userScriptsDir);
|
|
||||||
exec('please-manage-user', ['--output', userScriptsDir, 'kibana']);
|
|
||||||
appendFileSync(resolve(userScriptsDir, 'installer.sh'), 'chown kibana:kibana /opt/kibana/optimize');
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue