-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[build] Commit install/remove scripts #6674
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
699079d
[build] Commit install/remove scripts instead of generating, stop ser…
jbudz db69085
[build] template user in install/remove scripts
jbudz aaa81a8
[build] Run as group kibana
jbudz 957fb6b
[build] Recursive chown optimize folder
jbudz 322f181
[build] Try service kibana stop before init script
jbudz 0025b31
[build] Attempt to stop service pre-install
jbudz f6d4a63
[build] Fail on errors
jbudz ad2734e
[build] Cleanup postrm
jbudz d771c82
[build] Add comment in postrm explaining empty cases
jbudz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -6,7 +6,7 @@ module.exports = function (grunt) { | |
const exec = require('../utils/exec'); | ||
const targetDir = config.get('target'); | ||
const version = config.get('pkg.version'); | ||
const userScriptsDir = config.get('userScriptsDir'); | ||
const packageScriptsDir = config.get('packageScriptsDir'); | ||
const servicesByName = indexBy(config.get('services'), 'name'); | ||
|
||
grunt.registerTask('_build:osPackages', function () { | ||
|
@@ -22,15 +22,19 @@ module.exports = function (grunt) { | |
'--package', targetDir, | ||
'-s', 'dir', // input type | ||
'--name', 'kibana', | ||
'--description', 'Explore\ and\ visualize\ your\ Elasticsearch\ data.', | ||
'--description', 'Explore\ and\ visualize\ your\ Elasticsearch\ data', | ||
'--version', version, | ||
'--url', 'https://www.elastic.co', | ||
'--vendor', 'Elasticsearch,\ Inc.', | ||
'--maintainer', 'Kibana Team\ \<[email protected]\>', | ||
'--license', 'Apache\ 2.0', | ||
'--after-install', resolve(userScriptsDir, 'installer.sh'), | ||
'--after-remove', resolve(userScriptsDir, 'remover.sh'), | ||
'--config-files', '/opt/kibana/config/kibana.yml' | ||
'--after-install', resolve(packageScriptsDir, 'post_install.sh'), | ||
'--before-install', resolve(packageScriptsDir, 'pre_install.sh'), | ||
'--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'; | ||
|
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,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 |
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,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 |
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,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 |
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,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" |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of these empty cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a catch all at the bottom that echos an error if invalid arguments are used, these are valid arguments we just aren't doing anything with them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gotcha! Makes sense. Maybe add a comment inside the valid arguments clauses (Debian and Red Hat) explaining this so its obvious?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍