summaryrefslogtreecommitdiff
path: root/src/rpm
diff options
context:
space:
mode:
authorHilko Bengen <bengen@debian.org>2014-06-07 12:02:12 +0200
committerHilko Bengen <bengen@debian.org>2014-06-07 12:02:12 +0200
commitd5ed89b946297270ec28abf44bef2371a06f1f4f (patch)
treece2d945e4dde69af90bd9905a70d8d27f4936776 /src/rpm
downloadelasticsearch-d5ed89b946297270ec28abf44bef2371a06f1f4f.tar.gz
Imported Upstream version 1.0.3upstream/1.0.3
Diffstat (limited to 'src/rpm')
-rw-r--r--src/rpm/init.d/elasticsearch158
-rw-r--r--src/rpm/scripts/postinstall50
-rw-r--r--src/rpm/scripts/postremove15
-rw-r--r--src/rpm/scripts/preinstall4
-rw-r--r--src/rpm/scripts/preremove29
-rw-r--r--src/rpm/sysconfig/elasticsearch46
-rw-r--r--src/rpm/systemd/elasticsearch.conf1
-rw-r--r--src/rpm/systemd/elasticsearch.service20
-rw-r--r--src/rpm/systemd/sysctl.d/elasticsearch.conf1
9 files changed, 324 insertions, 0 deletions
diff --git a/src/rpm/init.d/elasticsearch b/src/rpm/init.d/elasticsearch
new file mode 100644
index 0000000..a5ba651
--- /dev/null
+++ b/src/rpm/init.d/elasticsearch
@@ -0,0 +1,158 @@
+#!/bin/sh
+#
+# elasticsearch <summary>
+#
+# chkconfig: 2345 80 20
+# description: Starts and stops a single elasticsearch instance on this system
+#
+
+### BEGIN INIT INFO
+# Provides: Elasticsearch
+# Required-Start: $network $named
+# Required-Stop: $network $named
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: This service manages the elasticsearch daemon
+# Description: Elasticsearch is a very scalable, schema-free and high-performance search solution supporting multi-tenancy and near realtime search.
+### END INIT INFO
+
+#
+# init.d / servicectl compatibility (openSUSE)
+#
+if [ -f /etc/rc.status ]; then
+ . /etc/rc.status
+ rc_reset
+fi
+
+#
+# Source function library.
+#
+if [ -f /etc/rc.d/init.d/functions ]; then
+ . /etc/rc.d/init.d/functions
+fi
+
+exec="/usr/share/elasticsearch/bin/elasticsearch"
+prog="elasticsearch"
+pidfile=/var/run/elasticsearch/${prog}.pid
+
+[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+export ES_HEAP_SIZE
+export ES_HEAP_NEWSIZE
+export ES_DIRECT_SIZE
+export ES_JAVA_OPTS
+
+lockfile=/var/lock/subsys/$prog
+
+# backwards compatibility for old config sysconfig files, pre 0.90.1
+if [ -n $USER ] && [ -z $ES_USER ] ; then
+ ES_USER=$USER
+fi
+
+checkJava() {
+ if [ -x "$JAVA_HOME/bin/java" ]; then
+ JAVA="$JAVA_HOME/bin/java"
+ else
+ JAVA=`which java`
+ fi
+
+ if [ ! -x "$JAVA" ]; then
+ echo "Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME"
+ exit 1
+ fi
+}
+
+start() {
+ checkJava
+ [ -x $exec ] || exit 5
+ [ -f $CONF_FILE ] || exit 6
+ if [ -n "$MAX_LOCKED_MEMORY" -a -z "$ES_HEAP_SIZE" ]; then
+ echo "MAX_LOCKED_MEMORY is set - ES_HEAP_SIZE must also be set"
+ return 7
+ fi
+ if [ -n "$MAX_OPEN_FILES" ]; then
+ ulimit -n $MAX_OPEN_FILES
+ fi
+ if [ -n "$MAX_LOCKED_MEMORY" ]; then
+ ulimit -l $MAX_LOCKED_MEMORY
+ fi
+ if [ -n "$MAX_MAP_COUNT" ]; then
+ sysctl -q -w vm.max_map_count=$MAX_MAP_COUNT
+ fi
+ if [ -n "$WORK_DIR" ]; then
+ mkdir -p "$WORK_DIR"
+ chown "$ES_USER":"$ES_GROUP" "$WORK_DIR"
+ fi
+ echo -n $"Starting $prog: "
+ # if not running, start it up here, usually something like "daemon $exec"
+ daemon --user $ES_USER --pidfile $pidfile $exec -p $pidfile -d -Des.default.path.home=$ES_HOME -Des.default.path.logs=$LOG_DIR -Des.default.path.data=$DATA_DIR -Des.default.path.work=$WORK_DIR -Des.default.path.conf=$CONF_DIR
+ retval=$?
+ echo
+ [ $retval -eq 0 ] && touch $lockfile
+ return $retval
+}
+
+stop() {
+ echo -n $"Stopping $prog: "
+ # stop it here, often "killproc $prog"
+ killproc -p $pidfile -d 20 $prog
+ retval=$?
+ echo
+ [ $retval -eq 0 ] && rm -f $lockfile
+ return $retval
+}
+
+restart() {
+ stop
+ start
+}
+
+reload() {
+ restart
+}
+
+force_reload() {
+ restart
+}
+
+rh_status() {
+ # run checks to determine if the service is running or use generic status
+ status -p $pidfile $prog
+}
+
+rh_status_q() {
+ rh_status >/dev/null 2>&1
+}
+
+
+case "$1" in
+ start)
+ rh_status_q && exit 0
+ $1
+ ;;
+ stop)
+ rh_status_q || exit 0
+ $1
+ ;;
+ restart)
+ $1
+ ;;
+ reload)
+ rh_status_q || exit 7
+ $1
+ ;;
+ force-reload)
+ force_reload
+ ;;
+ status)
+ rh_status
+ ;;
+ condrestart|try-restart)
+ rh_status_q || exit 0
+ restart
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
+ exit 2
+esac
+exit $?
diff --git a/src/rpm/scripts/postinstall b/src/rpm/scripts/postinstall
new file mode 100644
index 0000000..317f7fe
--- /dev/null
+++ b/src/rpm/scripts/postinstall
@@ -0,0 +1,50 @@
+
+[ -f /etc/sysconfig/elasticsearch ] && . /etc/sysconfig/elasticsearch
+
+startElasticsearch() {
+ if [ -x /bin/systemctl ] ; then
+ /bin/systemctl start elasticsearch.service
+ elif [ -x /etc/init.d/elasticsearch ] ; then
+ /etc/init.d/elasticsearch start
+ # older suse linux distributions do not ship with systemd
+ # but do not have an /etc/init.d/ directory
+ # this tries to start elasticsearch on these as well without failing this script
+ elif [ -x /etc/rc.d/init.d/elasticsearch ] ; then
+ /etc/rc.d/init.d/elasticsearch start
+ fi
+}
+
+stopElasticsearch() {
+ if [ -x /bin/systemctl ] ; then
+ /bin/systemctl stop elasticsearch.service > /dev/null 2>&1 || :
+ elif [ -x /etc/init.d/elasticsearch ] ; then
+ /etc/init.d/elasticsearch stop
+ elif [ -x /etc/rc.d/init.d/elasticsearch ] ; then
+ /etc/rc.d/init.d/elasticsearch stop
+ fi
+}
+
+# Initial installation: $1 == 1
+# Upgrade: $1 == 2, and configured to restart on upgrade
+if [ $1 -eq 1 ] ; then
+
+ if [ -x /bin/systemctl ] ; then
+ echo "### NOT starting on installation, please execute the following statements to configure elasticsearch to start automatically using systemd"
+ echo " sudo /bin/systemctl daemon-reload"
+ echo " sudo /bin/systemctl enable elasticsearch.service"
+ echo "### You can start elasticsearch by executing"
+ echo " sudo /bin/systemctl start elasticsearch.service"
+
+
+ elif [ -x /sbin/chkconfig ] ; then
+ echo "### NOT starting on installation, please execute the following statements to configure elasticsearch to start automatically using chkconfig"
+ echo " sudo /sbin/chkconfig --add elasticsearch"
+ echo "### You can start elasticsearch by executing"
+ echo " sudo service elasticsearch start"
+ fi
+
+elif [ $1 -ge 2 -a "$RESTART_ON_UPGRADE" == "true" ] ; then
+ stopElasticsearch
+ startElasticsearch
+fi
+
diff --git a/src/rpm/scripts/postremove b/src/rpm/scripts/postremove
new file mode 100644
index 0000000..6dedc29
--- /dev/null
+++ b/src/rpm/scripts/postremove
@@ -0,0 +1,15 @@
+# only execute in case of package removal, not on upgrade
+if [ $1 -eq 0 ] ; then
+
+ getent passwd elasticsearch > /dev/null
+ if [ "$?" == "0" ] ; then
+ userdel elasticsearch
+ fi
+
+ getent group elasticsearch >/dev/null
+ if [ "$?" == "0" ] ; then
+ groupdel elasticsearch
+ fi
+fi
+
+exit
diff --git a/src/rpm/scripts/preinstall b/src/rpm/scripts/preinstall
new file mode 100644
index 0000000..327c8d6
--- /dev/null
+++ b/src/rpm/scripts/preinstall
@@ -0,0 +1,4 @@
+getent group elasticsearch >/dev/null || groupadd -r elasticsearch
+getent passwd elasticsearch >/dev/null || \
+ useradd -r -g elasticsearch -d /usr/share/elasticsearch -s /sbin/nologin \
+ -c "elasticsearch user" elasticsearch
diff --git a/src/rpm/scripts/preremove b/src/rpm/scripts/preremove
new file mode 100644
index 0000000..1627c19
--- /dev/null
+++ b/src/rpm/scripts/preremove
@@ -0,0 +1,29 @@
+
+[ -f /etc/sysconfig/elasticsearch ] && . /etc/sysconfig/elasticsearch
+
+stopElasticsearch() {
+ if [ -x /bin/systemctl ] ; then
+ /bin/systemctl stop elasticsearch.service > /dev/null 2>&1 || :
+ elif [ -x /etc/init.d/elasticsearch ] ; then
+ /etc/init.d/elasticsearch stop
+ elif [ -x /etc/rc.d/init.d/elasticsearch ] ; then
+ /etc/rc.d/init.d/elasticsearch stop
+ fi
+}
+
+# Removal: $1 == 0
+# Dont do anything on upgrade, because the preun script in redhat gets executed after the postinst (madness!)
+if [ $1 -eq 0 ] ; then
+
+ if [ -x /bin/systemctl ] ; then
+ /bin/systemctl --no-reload disable elasticsearch.service > /dev/null 2>&1 || :
+ fi
+
+ if [ -x /sbin/chkconfig ] ; then
+ /sbin/chkconfig --del elasticsearch 2> /dev/null
+ fi
+
+ stopElasticsearch
+fi
+
+exit 0
diff --git a/src/rpm/sysconfig/elasticsearch b/src/rpm/sysconfig/elasticsearch
new file mode 100644
index 0000000..f27c497
--- /dev/null
+++ b/src/rpm/sysconfig/elasticsearch
@@ -0,0 +1,46 @@
+# Directory where the Elasticsearch binary distribution resides
+ES_HOME=/usr/share/elasticsearch
+
+# Heap Size (defaults to 256m min, 1g max)
+#ES_HEAP_SIZE=2g
+
+# Heap new generation
+#ES_HEAP_NEWSIZE=
+
+# max direct memory
+#ES_DIRECT_SIZE=
+
+# Additional Java OPTS
+#ES_JAVA_OPTS=
+
+# Maximum number of open files
+MAX_OPEN_FILES=65535
+
+# Maximum amount of locked memory
+#MAX_LOCKED_MEMORY=
+
+# Maximum number of VMA (Virtual Memory Areas) a process can own
+MAX_MAP_COUNT=262144
+
+# Elasticsearch log directory
+LOG_DIR=/var/log/elasticsearch
+
+# Elasticsearch data directory
+DATA_DIR=/var/lib/elasticsearch
+
+# Elasticsearch work directory
+WORK_DIR=/tmp/elasticsearch
+
+# Elasticsearch conf directory
+CONF_DIR=/etc/elasticsearch
+
+# Elasticsearch configuration file (elasticsearch.yml)
+CONF_FILE=/etc/elasticsearch/elasticsearch.yml
+
+# User to run as, change this to a specific elasticsearch user if possible
+# Also make sure, this user can write into the log directories in case you change them
+# This setting only works for the init script, but has to be configured separately for systemd startup
+ES_USER=elasticsearch
+
+# Configure restart on package upgrade (true, every other setting will lead to not restarting)
+#RESTART_ON_UPGRADE=true
diff --git a/src/rpm/systemd/elasticsearch.conf b/src/rpm/systemd/elasticsearch.conf
new file mode 100644
index 0000000..9db225e
--- /dev/null
+++ b/src/rpm/systemd/elasticsearch.conf
@@ -0,0 +1 @@
+d /run/elasticsearch 0755 elasticsearch elasticsearch - -
diff --git a/src/rpm/systemd/elasticsearch.service b/src/rpm/systemd/elasticsearch.service
new file mode 100644
index 0000000..5642018
--- /dev/null
+++ b/src/rpm/systemd/elasticsearch.service
@@ -0,0 +1,20 @@
+[Unit]
+Description=Starts and stops a single elasticsearch instance on this system
+Documentation=http://www.elasticsearch.org
+
+[Service]
+Type=forking
+EnvironmentFile=/etc/sysconfig/elasticsearch
+User=elasticsearch
+Group=elasticsearch
+PIDFile=/var/run/elasticsearch/elasticsearch.pid
+ExecStart=/usr/share/elasticsearch/bin/elasticsearch -d -p /var/run/elasticsearch/elasticsearch.pid -Des.default.config=$CONF_FILE -Des.default.path.home=$ES_HOME -Des.default.path.logs=$LOG_DIR -Des.default.path.data=$DATA_DIR -Des.default.path.work=$WORK_DIR -Des.default.path.conf=$CONF_DIR
+# See MAX_OPEN_FILES in sysconfig
+LimitNOFILE=65535
+# See MAX_LOCKED_MEMORY in sysconfig, use "infinity" when MAX_LOCKED_MEMORY=unlimited and using bootstrap.mlockall: true
+#LimitMEMLOCK=infinity
+# Shutdown delay in seconds, before process is tried to be killed with KILL (if configured)
+TimeoutStopSec=20
+
+[Install]
+WantedBy=multi-user.target
diff --git a/src/rpm/systemd/sysctl.d/elasticsearch.conf b/src/rpm/systemd/sysctl.d/elasticsearch.conf
new file mode 100644
index 0000000..62ea54d
--- /dev/null
+++ b/src/rpm/systemd/sysctl.d/elasticsearch.conf
@@ -0,0 +1 @@
+vm.max_map_count=262144