Gentoo Archives: gentoo-commits

From: Tony Vroon <chainsaw@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-misc/elasticsearch/files/, app-misc/elasticsearch/
Date: Mon, 16 Jul 2018 13:45:02
Message-Id: 1531748686.4f3426c43a9f455b0dcd039da1c313a1d2af7779.chainsaw@gentoo
1 commit: 4f3426c43a9f455b0dcd039da1c313a1d2af7779
2 Author: Tomas Mozes <tmozes <AT> sygic <DOT> com>
3 AuthorDate: Fri Jul 13 15:43:58 2018 +0000
4 Commit: Tony Vroon <chainsaw <AT> gentoo <DOT> org>
5 CommitDate: Mon Jul 16 13:44:46 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4f3426c4
7
8 app-misc/elasticsearch: stop using /etc/conf.d for systemd
9
10 Closes: https://bugs.gentoo.org/646248
11 Package-Manager: Portage-2.3.42, Repoman-2.3.9
12 Closes: https://github.com/gentoo/gentoo/pull/9216
13 Closes: https://bugs.gentoo.org/646248
14
15 .../elasticsearch/elasticsearch-6.3.1-r1.ebuild | 77 ++++++++++++++++++++++
16 .../files/elasticsearch-systemd-pre-exec | 5 ++
17 .../elasticsearch/files/elasticsearch.service.3 | 51 ++++++++++++++
18 .../elasticsearch/files/elasticsearch.service.conf | 6 ++
19 4 files changed, 139 insertions(+)
20
21 diff --git a/app-misc/elasticsearch/elasticsearch-6.3.1-r1.ebuild b/app-misc/elasticsearch/elasticsearch-6.3.1-r1.ebuild
22 new file mode 100644
23 index 00000000000..1a6bec30a73
24 --- /dev/null
25 +++ b/app-misc/elasticsearch/elasticsearch-6.3.1-r1.ebuild
26 @@ -0,0 +1,77 @@
27 +# Copyright 1999-2018 Gentoo Foundation
28 +# Distributed under the terms of the GNU General Public License v2
29 +
30 +EAPI=6
31 +
32 +inherit systemd user
33 +
34 +DESCRIPTION="Open Source, Distributed, RESTful, Search Engine"
35 +HOMEPAGE="https://www.elastic.co/products/elasticsearch"
36 +SRC_URI="https://artifacts.elastic.co/downloads/${PN}/${PN}-oss-${PV}.tar.gz"
37 +LICENSE="Apache-2.0 BSD-2 LGPL-3 MIT public-domain"
38 +SLOT="0"
39 +KEYWORDS="~amd64"
40 +
41 +RDEPEND="virtual/jre:1.8"
42 +
43 +pkg_setup() {
44 + enewgroup ${PN}
45 + enewuser ${PN} -1 /bin/bash /usr/share/${PN} ${PN}
46 +}
47 +
48 +src_prepare() {
49 + default
50 +
51 + rm -v bin/*.{bat,exe} LICENSE.txt || die
52 +}
53 +
54 +src_install() {
55 + keepdir /etc/${PN}
56 + keepdir /etc/${PN}/scripts
57 +
58 + insinto /etc/${PN}
59 + doins -r config/.
60 + rm -rv config || die
61 +
62 + fowners root:${PN} /etc/${PN}
63 + fperms 2750 /etc/${PN}
64 +
65 + insinto /usr/share/${PN}
66 + doins -r .
67 +
68 + exeinto /usr/share/${PN}/bin
69 + doexe "${FILESDIR}/elasticsearch-systemd-pre-exec"
70 +
71 + chmod +x "${ED}"/usr/share/${PN}/bin/* || die
72 +
73 + keepdir /var/{lib,log}/${PN}
74 + fowners ${PN}:${PN} /var/{lib,log}/${PN}
75 + fperms 0750 /var/{lib,log}/${PN}
76 + dodir /usr/share/${PN}/plugins
77 +
78 + insinto /etc/sysctl.d
79 + newins "${FILESDIR}/${PN}.sysctl.d" ${PN}.conf
80 +
81 + newconfd "${FILESDIR}/${PN}.conf.3" ${PN}
82 + newinitd "${FILESDIR}/${PN}.init.4" ${PN}
83 +
84 + systemd_install_serviced "${FILESDIR}/${PN}.service.conf"
85 + systemd_newtmpfilesd "${FILESDIR}/${PN}.tmpfiles.d" ${PN}.conf
86 + systemd_newunit "${FILESDIR}"/${PN}.service.3 ${PN}.service
87 +}
88 +
89 +pkg_postinst() {
90 + elog
91 + elog "You may create multiple instances of ${PN} by"
92 + elog "symlinking the init script:"
93 + elog "ln -sf /etc/init.d/${PN} /etc/init.d/${PN}.instance"
94 + elog
95 + elog "Please make sure you put elasticsearch.yml, log4j2.properties and scripts"
96 + elog "from /etc/${PN} into the configuration directory of the instance:"
97 + elog "/etc/${PN}/instance"
98 + elog
99 + ewarn "Please make sure you have proper permissions on /etc/${PN}"
100 + ewarn "prior to keystore generation or you may experience startup fails."
101 + ewarn "chown root:${PN} /etc/${PN} && chmod 2750 /etc/${PN}"
102 + ewarn "chown root:${PN} /etc/${PN}/${PN}.keystore && chmod 0660 /etc/${PN}/${PN}.keystore"
103 +}
104
105 diff --git a/app-misc/elasticsearch/files/elasticsearch-systemd-pre-exec b/app-misc/elasticsearch/files/elasticsearch-systemd-pre-exec
106 index a51d639bf7d..30f773638d3 100755
107 --- a/app-misc/elasticsearch/files/elasticsearch-systemd-pre-exec
108 +++ b/app-misc/elasticsearch/files/elasticsearch-systemd-pre-exec
109 @@ -5,3 +5,8 @@ if [ ! -z "$CONF_FILE" ]; then
110 echo "CONF_FILE setting is no longer supported. elasticsearch.yml must be placed in the config directory and cannot be renamed."
111 exit 1
112 fi
113 +
114 +# fails to start without keystore
115 +if [ ! -f "${ES_PATH_CONF}/elasticsearch.keystore" ]; then
116 + "${ES_HOME}/bin/elasticsearch-keystore" create
117 +fi
118
119 diff --git a/app-misc/elasticsearch/files/elasticsearch.service.3 b/app-misc/elasticsearch/files/elasticsearch.service.3
120 new file mode 100644
121 index 00000000000..69d3550e7d9
122 --- /dev/null
123 +++ b/app-misc/elasticsearch/files/elasticsearch.service.3
124 @@ -0,0 +1,51 @@
125 +[Unit]
126 +Description=Elasticsearch
127 +Documentation=https://www.elastic.co
128 +Wants=network.target
129 +After=network.target
130 +
131 +[Service]
132 +Environment=ES_HOME=/usr/share/elasticsearch
133 +Environment=ES_PATH_CONF=/etc/elasticsearch
134 +Environment=DATA_DIR=/var/lib/elasticsearch
135 +Environment=LOG_DIR=/var/log/elasticsearch
136 +Environment=PID_DIR=/run/elasticsearch
137 +
138 +WorkingDirectory=/usr/share/elasticsearch
139 +
140 +User=elasticsearch
141 +Group=elasticsearch
142 +
143 +PermissionsStartOnly=true
144 +ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec
145 +
146 +ExecStart=/usr/share/elasticsearch/bin/elasticsearch \
147 + -p ${PID_DIR}/elasticsearch.pid \
148 + -Epath.logs=${LOG_DIR} \
149 + -Epath.data=${DATA_DIR}
150 +
151 +StandardOutput=journal
152 +StandardError=inherit
153 +
154 +# Specifies the maximum file descriptor number that can be opened by this process
155 +LimitNOFILE=65536
156 +
157 +# Specifies the maximum number of bytes of memory that may be locked into RAM
158 +# Set to "infinity" if you use the 'bootstrap.memory_lock: true' option
159 +# in elasticsearch.yml and 'MAX_LOCKED_MEMORY=unlimited' in /etc/conf.d/elasticsearch
160 +#LimitMEMLOCK=infinity
161 +
162 +# Disable timeout logic and wait until process is stopped
163 +TimeoutStopSec=0
164 +
165 +# SIGTERM signal is used to stop the Java process
166 +KillSignal=SIGTERM
167 +
168 +# Java process is never killed
169 +SendSIGKILL=no
170 +
171 +# When a JVM receives a SIGTERM signal it exits with code 143
172 +SuccessExitStatus=143
173 +
174 +[Install]
175 +WantedBy=multi-user.target
176
177 diff --git a/app-misc/elasticsearch/files/elasticsearch.service.conf b/app-misc/elasticsearch/files/elasticsearch.service.conf
178 new file mode 100644
179 index 00000000000..489f8c42c04
180 --- /dev/null
181 +++ b/app-misc/elasticsearch/files/elasticsearch.service.conf
182 @@ -0,0 +1,6 @@
183 +[Service]
184 +Environment="ES_HOME=/usr/share/elasticsearch"
185 +Environment="ES_PATH_CONF=/etc/elasticsearch"
186 +Environment="DATA_DIR=/var/lib/elasticsearch"
187 +Environment="LOG_DIR=/var/log/elasticsearch"
188 +Environment="PID_DIR=/run/elasticsearch"