Skip to content

Commit

Permalink
app-admin/logstash-bin: retain user installed plugins (Bug #622602)
Browse files Browse the repository at this point in the history
Closes: #5098
Package-Manager: Portage-2.3.7, Repoman-2.3.2
  • Loading branch information
hydrapolic authored and mgorny committed Aug 16, 2017
1 parent acd85b0 commit 15b28a3
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 2 deletions.
85 changes: 85 additions & 0 deletions app-admin/logstash-bin/files/logstash-plugin.eselect
@@ -0,0 +1,85 @@
# -*-eselect-*- vim: ft=eselect
# Copyright 2005-2017 Gentoo Foundation
# Distributed under the terms of the GNU GPL version 2 or later

DESCRIPTION="Manage user installed plugins of logstash"
MAINTAINER="hydrapolic@gmail.com"

PLUGINS="/var/lib/logstash/plugins-list.txt"
LS_INSTALL_DIR="/opt/logstash"

ls_plugin_wrapper() {
JARS_SKIP=true "${LS_INSTALL_DIR}/bin/logstash-plugin" "${1}" "${2}" || die
}

### install action
describe_install() {
echo "Install plugin"
}

describe_install_parameters() {
echo "<plugin>"
}

do_install() {
[[ ${#} -lt 1 ]] && die "Please specify at least one plugin"

local plugin
for plugin; do
ls_plugin_wrapper install "${plugin}"
echo "${plugin}" >> "${PLUGINS}" || die
done

sort -u "${PLUGINS}" > "${PLUGINS}.tmp" || die
mv "${PLUGINS}.tmp" "${PLUGINS}" || die
}

### list action
describe_list() {
echo "List user installed plugins"
}

do_list() {
if [[ -f "${PLUGINS}" ]]; then
write_list_start "Installed plugins:"

local plugin
while read -r plugin; do
write_kv_list_entry "${plugin}"
done < "${PLUGINS}"
fi
}

### reinstall action
describe_reinstall() {
echo "Reinstall plugins"
}

do_reinstall() {
if [[ -f "${PLUGINS}" ]]; then
local plugin
while read -r plugin; do
ls_plugin_wrapper install "${plugin}"
done < "${PLUGINS}"
fi
}

### uninstall action
describe_uninstall() {
echo "Uninstall plugin"
}

describe_uninstall_parameters() {
echo "<plugin>"
}

do_uninstall() {
if [[ -f "${PLUGINS}" ]]; then
local plugin
for plugin; do
grep "^${plugin}\$" "${PLUGINS}" || write_warning_msg "Plugin ${plugin} not recorded"
sed -i "/^${plugin}\$/d" "${PLUGINS}" || die
ls_plugin_wrapper remove "${plugin}"
done
fi
}
Expand Up @@ -31,6 +31,7 @@ pkg_setup() {

src_install() {
keepdir /etc/"${MY_PN}"/{conf.d,patterns,plugins}
keepdir "/var/lib/${MY_PN}"
keepdir "/var/log/${MY_PN}"

insinto "/usr/share/${MY_PN}"
Expand All @@ -45,15 +46,27 @@ src_install() {

newconfd "${FILESDIR}/${MY_PN}.confd" "${MY_PN}"
newinitd "${FILESDIR}/${MY_PN}.initd" "${MY_PN}"

insinto /usr/share/eselect/modules
doins "${FILESDIR}"/logstash-plugin.eselect
}

pkg_postinst() {
ewarn "The default user changed from root to ${MY_PN}. If you wish to run as root (for"
ewarn "example to read local logs), be sure to change LS_USER and LS_GROUP in"
ewarn "${EROOT%/}/etc/conf.d/${MY_PN}"
ewarn
ewarn "Self installed plugins are removed during Logstash upgrades (Bug #622602)"
ewarn "Install the plugins via eselect module that will automatically re-install"
ewarn "all self installed plugins after Logstash upgrades."
einfo
einfo "Installing plugins:"
einfo "eselect logstash-plugin install logstash-output-gelf"
einfo
einfo "Installing plugins: (bug #601294)"
einfo "DEBUG=1 JARS_SKIP='true' bin/logstash-plugin install logstash-output-gelf"

einfo "Reinstalling self installed plugins (installed via eselect module):"
eselect logstash-plugin reinstall

einfo
einfo "Sample configuration:"
einfo "${EROOT%/}/usr/share/${MY_PN}"
Expand Down

0 comments on commit 15b28a3

Please sign in to comment.