[packages/elasticsearch] initscript, needs pldizing

glen glen at pld-linux.org
Tue Apr 2 23:10:09 CEST 2013


commit a1405fe53274a096e993ad6af6ae35cdf2e07c04
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Wed Apr 3 00:04:20 2013 +0300

    initscript, needs pldizing

 elasticsearch.init | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 elasticsearch.spec |  6 ++--
 2 files changed, 100 insertions(+), 2 deletions(-)
---
diff --git a/elasticsearch.spec b/elasticsearch.spec
index 4fcbb8f..71c30c3 100644
--- a/elasticsearch.spec
+++ b/elasticsearch.spec
@@ -1,9 +1,10 @@
 # TODO
 # - register user
+# - pldize initscript
 Summary:	A distributed, highly available, RESTful search engine
 Name:		elasticsearch
 Version:	0.19.9
-Release:	0.1
+Release:	0.2
 License:	Apache v2.0
 Group:		Daemons
 Source0:	https://github.com/downloads/elasticsearch/elasticsearch/%{name}-%{version}.tar.gz
@@ -14,7 +15,8 @@ Source3:	config-logging.yml
 Source4:	%{name}.sysconfig
 Source5:	%{name}.tmpfiles
 URL:		http://www.elasticsearch.com/
-Requires:	/sbin/chkconfig
+BuildRequires:	rpmbuild(macros) >= 1.228
+Requires(post,preun):	/sbin/chkconfig
 Requires:	java-jna >= 3.2.4
 Requires:	java-log4j >= 1.2.14
 Requires:	java-sigar >= 1.6.4
diff --git a/elasticsearch.init b/elasticsearch.init
new file mode 100755
index 0000000..ec65652
--- /dev/null
+++ b/elasticsearch.init
@@ -0,0 +1,96 @@
+#! /bin/bash
+### BEGIN INIT INFO
+# Provides:          elasticsearch
+# Required-Start:    $all
+# Required-Stop:     $all
+# Default-Start:
+# Default-Stop:      0 1 6
+# Short-Description: Starts elasticsearch
+# chkconfig: - 80 15
+# Description: Elasticsearch
+### END INIT INFO
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+# Pull in sysconfig settings
+[ -f /etc/sysconfig/elasticsearch ] && . /etc/sysconfig/elasticsearch
+
+ES_HOME=/usr/share/java/elasticsearch
+ES_USER=elasticsearch
+
+DAEMON=${ES_HOME}/bin/elasticsearch
+NAME=elasticsearch
+PID_FILE=${PIDFILE:-/var/run/${NAME}/${NAME}.pid}
+LOCK_FILE=${LOCKFILE:-/var/lock/subsys/${NAME}}
+NFILES=${NFILES:-32768}
+
+ES_PATH_LOG=${ES_PATH_LOG:-/var/log/${NAME}}
+ES_PATH_DATA=${ES_PATH_DATA:-/var/lib/${NAME}}
+ES_PATH_WORK=${ES_PATH_WORK:-/tmp/${NAME}}
+ES_PATH_CONF=${ES_PATH_CONF:-/etc/${NAME}}
+ES_PATH_PLUGINS=${ES_PATH_PLUGINS:-${ES_HOME}/plugins}
+ES_CONFIG=${ES_CONFIG:-${ES_PATH_CONF}/elasticsearch.yml}
+
+DAEMON_OPTS="-p ${PID_FILE} \
+    -Des.config=${ES_CONFIG} \
+    -Des.path.conf=${ES_PATH_CONF} \
+    -Des.path.home=${ES_HOME} \
+    -Des.path.logs=${ES_PATH_LOG} \
+    -Des.path.data=${ES_PATH_DATA} \
+    -Des.path.work=${ES_PATH_WORK} \
+    -Des.path.plugins=${ES_PATH_PLUGINS} 2>/dev/null"
+
+# These environment variables are passed over.
+ES_MIN_MEM=${ES_MIN_MEM:-256m}
+ES_MAX_MEM=${ES_MAX_MEM:-1g}
+ES_INCLUDE=${ES_INCLUDE:-${ES_HOME}/bin/elasticsearch.in.sh}
+
+start() {
+    echo -n $"Starting ${NAME}: "
+    mkdir -p $ES_PATH_WORK
+    ulimit -n $NFILES
+    daemon --pidfile=${PID_FILE} --user $ES_USER \
+        ES_HOME=$ES_HOME \
+        ES_INCLUDE=$ES_INCLUDE \
+        ES_MIN_MEM=$ES_MIN_MEM \
+        ES_MAX_MEM=$ES_MAX_MEM \
+        $DAEMON $DAEMON_OPTS
+    RETVAL=$?
+    echo
+    [ $RETVAL -eq 0 ] && touch $LOCK_FILE
+    return $RETVAL
+}
+
+stop() {
+    echo -n $"Stopping ${NAME}: "
+    killproc -p ${PID_FILE} -d 10 $DAEMON
+    RETVAL=$?
+    echo
+    [ $RETVAL = 0 ] && rm -f ${LOCK_FILE} ${PID_FILE}
+    return $RETVAL
+}
+
+case "$1" in
+    start)
+        start
+        ;;
+    stop)
+        stop
+        ;;
+    status)
+        status -p ${PID_FILE} $DAEMON
+        RETVAL=$?
+        ;;
+    restart|force-reload)
+        stop
+        start
+        ;;
+    *)
+        N=/etc/rc.d/init.d/${NAME}
+        echo "Usage: $N {start|stop|restart|force-reload}" >&2
+        RETVAL=2
+        ;;
+esac
+
+exit $RETVAL
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/elasticsearch.git/commitdiff/a1405fe53274a096e993ad6af6ae35cdf2e07c04



More information about the pld-cvs-commit mailing list