forked from gentoo/gentoo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
app-misc/elasticsearch: use openrc-run variables.
Package-Manager: Portage-2.3.12, Repoman-2.3.3 Closes: gentoo#6048
- Loading branch information
1 parent
270b12c
commit cc73e45
Showing
3 changed files
with
188 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Copyright 1999-2017 Gentoo Foundation | ||
# Distributed under the terms of the GNU General Public License v2 | ||
|
||
EAPI=6 | ||
|
||
inherit systemd user | ||
|
||
DESCRIPTION="Open Source, Distributed, RESTful, Search Engine" | ||
HOMEPAGE="https://www.elastic.co/products/elasticsearch" | ||
SRC_URI="https://artifacts.elastic.co/downloads/${PN}/${P}.tar.gz" | ||
LICENSE="Apache-2.0 BSD-2 LGPL-3 MIT public-domain" | ||
SLOT="0" | ||
KEYWORDS="~amd64" | ||
|
||
RDEPEND="virtual/jre:1.8" | ||
|
||
pkg_setup() { | ||
enewgroup ${PN} | ||
enewuser ${PN} -1 /bin/bash /usr/share/${PN} ${PN} | ||
} | ||
|
||
src_prepare() { | ||
rm -v bin/*.{bat,exe} LICENSE.txt || die | ||
|
||
default | ||
} | ||
|
||
src_install() { | ||
keepdir /etc/${PN} | ||
keepdir /etc/${PN}/scripts | ||
|
||
insinto /etc/${PN} | ||
doins config/* | ||
rm -rv config || die | ||
|
||
insinto /usr/share/${PN} | ||
doins -r ./* | ||
|
||
exeinto /usr/share/${PN}/bin | ||
doexe "${FILESDIR}/elasticsearch-systemd-pre-exec" | ||
|
||
chmod +x "${ED}"/usr/share/${PN}/bin/* || die | ||
|
||
keepdir /var/{lib,log}/${PN} | ||
fowners ${PN}:${PN} /var/{lib,log}/${PN} | ||
fperms 0750 /var/{lib,log}/${PN} | ||
dodir /usr/share/${PN}/plugins | ||
|
||
insinto /etc/sysctl.d | ||
newins "${FILESDIR}/${PN}.sysctl.d" ${PN}.conf | ||
|
||
newconfd "${FILESDIR}/${PN}.conf.2" ${PN} | ||
newinitd "${FILESDIR}/${PN}.init.2" ${PN} | ||
|
||
systemd_newtmpfilesd "${FILESDIR}/${PN}.tmpfiles.d" ${PN}.conf | ||
systemd_newunit "${FILESDIR}"/${PN}.service ${PN}.service | ||
} | ||
|
||
pkg_postinst() { | ||
elog | ||
elog "You may create multiple instances of ${PN} by" | ||
elog "symlinking the init script:" | ||
elog "ln -sf /etc/init.d/${PN} /etc/init.d/${PN}.instance" | ||
elog | ||
elog "Please make sure you put elasticsearch.yml, log4j2.properties and scripts" | ||
elog "from /etc/elasticsearch into the configuration directory of the instance:" | ||
elog "/etc/${PN}/instance" | ||
elog | ||
} |
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,59 @@ | ||
################################ | ||
# Elasticsearch | ||
################################ | ||
|
||
# Elasticsearch home directory | ||
#ES_HOME=/usr/share/elasticsearch | ||
|
||
# Elasticsearch Java path | ||
#JAVA_HOME= | ||
|
||
# Elasticsearch configuration directory | ||
#CONF_DIR=/etc/elasticsearch | ||
|
||
# Elasticsearch data directory | ||
#DATA_DIR=/var/lib/elasticsearch | ||
|
||
# Elasticsearch logs directory | ||
#LOG_DIR=/var/log/elasticsearch | ||
|
||
# Additional Java OPTS | ||
#ES_JAVA_OPTS= | ||
|
||
################################ | ||
# Elasticsearch service | ||
################################ | ||
|
||
# When executing the init script, this user will be used to run the elasticsearch service. | ||
# The default value is 'elasticsearch' and is declared in the init.d file. | ||
# Note that this setting is only used by the init script. If changed, make sure that | ||
# the configured user can read and write into the data, work, plugins and log directories. | ||
# For systemd service, the user is usually configured in file /usr/lib/systemd/system/elasticsearch.service | ||
#ES_USER=elasticsearch | ||
#ES_GROUP=elasticsearch | ||
|
||
# The number of seconds to wait before checking if Elasticsearch started successfully as a daemon process | ||
#ES_STARTUP_SLEEP_TIME=5 | ||
|
||
################################ | ||
# System properties | ||
################################ | ||
|
||
# Specifies the maximum file descriptor number that can be opened by this process | ||
# When using Systemd, this setting is ignored and the LimitNOFILE defined in | ||
# /usr/lib/systemd/system/elasticsearch.service takes precedence | ||
MAX_OPEN_FILES=65536 | ||
|
||
# The maximum number of bytes of memory that may be locked into RAM | ||
# Set to "unlimited" if you use the 'bootstrap.memory_lock: true' option | ||
# in elasticsearch.yml. | ||
# When using Systemd, the LimitMEMLOCK property must be set | ||
# in /usr/lib/systemd/system/elasticsearch.service | ||
MAX_LOCKED_MEMORY=unlimited | ||
|
||
# Maximum number of VMA (Virtual Memory Areas) a process can own | ||
# When using Systemd, this setting is ignored and the 'vm.max_map_count' | ||
# property is set at boot time in /usr/lib/sysctl.d/elasticsearch.conf | ||
#MAX_MAP_COUNT=262144 | ||
|
||
rc_ulimit="-l $MAX_LOCKED_MEMORY -n $MAX_OPEN_FILES" |
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,60 @@ | ||
#!/sbin/openrc-run | ||
|
||
name="Elasticsearch" | ||
description="Elasticsearch Server" | ||
|
||
ES_INSTANCE=${SVCNAME#*.} | ||
|
||
if [ -n "${ES_INSTANCE}" ] && [ ${SVCNAME} != "elasticsearch" ]; then | ||
ES_BASE_PATH="/var/lib/elasticsearch/${ES_INSTANCE}" | ||
CONF_DIR="/etc/elasticsearch/${ES_INSTANCE}" | ||
LOG_DIR="/var/log/elasticsearch/${ES_INSTANCE}" | ||
else | ||
ES_BASE_PATH="/var/lib/elasticsearch/_default" | ||
CONF_DIR="/etc/elasticsearch" | ||
LOG_DIR="/var/log/elasticsearch/_default" | ||
fi | ||
|
||
ES_HOME=${ES_HOME:="/usr/share/elasticsearch"} | ||
ES_USER=${ES_USER:="elasticsearch"} | ||
ES_GROUP=${ES_GROUP:="elasticsearch"} | ||
ES_STARTUP_SLEEP_TIME=${ES_STARTUP_TIME:=5} | ||
MAX_OPEN_FILES=${MAX_OPEN_FILES:=65536} | ||
MAX_MAP_COUNT=${MAX_MAP_COUNT:=262144} | ||
|
||
DATA_DIR=${DATA_DIR:="${ES_BASE_PATH}/data"} | ||
|
||
if [ -f "${CONF_DIR}/elasticsearch.in.sh" ]; then | ||
ES_INCLUDE="${CONF_DIR}/elasticsearch.in.sh" | ||
fi | ||
|
||
export ES_INCLUDE | ||
export JAVA_HOME | ||
export JAVA_OPTS | ||
export ES_JVM_OPTIONS | ||
export ES_JAVA_OPTS | ||
export ES_STARTUP_SLEEP_TIME | ||
|
||
pidfile="/run/elasticsearch/${RC_SVCNAME}.pid" | ||
|
||
command="/usr/share/elasticsearch/bin/elasticsearch" | ||
command_args="--daemonize --pidfile=${pidfile} -Edefault.path.logs=${LOG_DIR} -Edefault.path.data=${DATA_DIR} -Edefault.path.conf=${CONF_DIR}" | ||
command_user="${ES_USER}:${ES_GROUP}" | ||
required_files="${CONF_DIR}/elasticsearch.yml" | ||
retry="TERM/30/KILL/30" | ||
|
||
depend() { | ||
use net | ||
} | ||
|
||
start_pre() { | ||
if [ -n "${MAX_MAP_COUNT}" -a -f /proc/sys/vm/max_map_count ]; then | ||
sysctl -q -w vm.max_map_count=${MAX_MAP_COUNT} | ||
fi | ||
|
||
checkpath -d -o "${ES_USER}:${ES_GROUP}" -m750 "/var/lib/elasticsearch" | ||
checkpath -d -o "${ES_USER}:${ES_GROUP}" -m750 "/var/log/elasticsearch" | ||
checkpath -d -o "${ES_USER}:${ES_GROUP}" -m750 "/run/elasticsearch" | ||
checkpath -d -o "${ES_USER}:${ES_GROUP}" -m750 "${ES_BASE_PATH}" | ||
checkpath -d -o "${ES_USER}:${ES_GROUP}" -m750 "${LOG_DIR}" | ||
} |