diff --git a/bin/service/elasticsearch b/bin/service/elasticsearch
new file mode 100755
index 00000000000..aaf86008784
--- /dev/null
+++ b/bin/service/elasticsearch
@@ -0,0 +1,1258 @@
+#! /bin/sh
+
+# RESOLVE and SET $ES_HOME
+
+SCRIPT="$0"
+
+# SCRIPT may be an arbitrarily deep series of symlinks. Loop until we have the concrete path.
+while [ -h "$SCRIPT" ] ; do
+ ls=`ls -ld "$SCRIPT"`
+ # Drop everything prior to ->
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ SCRIPT="$link"
+ else
+ SCRIPT=`dirname "$SCRIPT"`/"$link"
+ fi
+done
+
+# determine elasticsearch home
+ES_HOME=`dirname "$SCRIPT"`/../..
+
+# make ELASTICSEARCH_HOME absolute
+export ES_HOME=`cd $ES_HOME; pwd`
+
+
+# Application
+APP_NAME="elasticsearch"
+APP_LONG_NAME="ElasticSearch"
+
+# Wrapper
+WRAPPER_CMD="$ES_HOME/bin/service/exec/elasticsearch"
+WRAPPER_CONF="$ES_HOME/bin/service/elasticsearch.conf"
+
+# Priority at which to run the wrapper. See "man nice" for valid priorities.
+# nice is only used if a priority is specified.
+PRIORITY=
+
+# Location of the pid file.
+PIDDIR="."
+
+# If uncommented, causes the Wrapper to be shutdown using an anchor file.
+# When launched with the 'start' command, it will also ignore all INT and
+# TERM signals.
+#IGNORE_SIGNALS=true
+
+# Wrapper will start the JVM asynchronously. Your application may have some
+# initialization tasks and it may be desirable to wait a few seconds
+# before returning. For example, to delay the invocation of following
+# startup scripts. Setting WAIT_AFTER_STARTUP to a positive number will
+# cause the start command to delay for the indicated period of time
+# (in seconds).
+#
+WAIT_AFTER_STARTUP=0
+
+# If set, wait for the wrapper to report that the daemon has started
+WAIT_FOR_STARTED_STATUS=true
+WAIT_FOR_STARTED_TIMEOUT=120
+
+# If set, the status, start_msg and stop_msg commands will print out detailed
+# state information on the Wrapper and Java processes.
+#DETAIL_STATUS=true
+
+# If specified, the Wrapper will be run as the specified user.
+# IMPORTANT - Make sure that the user has the required privileges to write
+# the PID file and wrapper.log files. Failure to be able to write the log
+# file will cause the Wrapper to exit without any way to write out an error
+# message.
+# NOTE - This will set the user which is used to run the Wrapper as well as
+# the JVM and is not useful in situations where a privileged resource or
+# port needs to be allocated prior to the user being changed.
+#RUN_AS_USER=
+
+# The following two lines are used by the chkconfig command. Change as is
+# appropriate for your application. They should remain commented.
+# chkconfig: 2345 20 80
+# description: ElasticSearch
+
+# When installing on On Mac OSX platforms, the following domain will be used to
+# prefix the plist file name.
+PLIST_DOMAIN=org.elasticsearch
+
+# Initialization block for the install_initd and remove_initd scripts used by
+# SUSE linux distributions.
+### BEGIN INIT INFO
+# Provides: elasticsearch
+# Required-Start: $local_fs $network $syslog
+# Should-Start:
+# Required-Stop:
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: ElasticSearch
+# Description: Open Source, Distributed, RESTful, Search Engine
+### END INIT INFO
+
+# Do not modify anything beyond this point
+#-----------------------------------------------------------------------------
+
+# Required for HP-UX Startup
+if [ `uname -s` = "HP-UX" -o `uname -s` = "HP-UX64" ] ; then
+ PATH=$PATH:/usr/bin
+fi
+
+# Get the fully qualified path to the script
+case $0 in
+ /*)
+ SCRIPT="$0"
+ ;;
+ *)
+ PWD=`pwd`
+ SCRIPT="$PWD/$0"
+ ;;
+esac
+
+# Resolve the true real path without any sym links.
+CHANGED=true
+while [ "X$CHANGED" != "X" ]
+do
+ # Change spaces to ":" so the tokens can be parsed.
+ SAFESCRIPT=`echo $SCRIPT | sed -e 's; ;:;g'`
+ # Get the real path to this script, resolving any symbolic links
+ TOKENS=`echo $SAFESCRIPT | sed -e 's;/; ;g'`
+ REALPATH=
+ for C in $TOKENS; do
+ # Change any ":" in the token back to a space.
+ C=`echo $C | sed -e 's;:; ;g'`
+ REALPATH="$REALPATH/$C"
+ # If REALPATH is a sym link, resolve it. Loop for nested links.
+ while [ -h "$REALPATH" ] ; do
+ LS="`ls -ld "$REALPATH"`"
+ LINK="`expr "$LS" : '.*-> \(.*\)$'`"
+ if expr "$LINK" : '/.*' > /dev/null; then
+ # LINK is absolute.
+ REALPATH="$LINK"
+ else
+ # LINK is relative.
+ REALPATH="`dirname "$REALPATH"`""/$LINK"
+ fi
+ done
+ done
+
+ if [ "$REALPATH" = "$SCRIPT" ]
+ then
+ CHANGED=""
+ else
+ SCRIPT="$REALPATH"
+ fi
+done
+
+# Change the current directory to the location of the script
+cd "`dirname "$REALPATH"`"
+REALDIR=`pwd`
+
+# If the PIDDIR is relative, set its value relative to the full REALPATH to avoid problems if
+# the working directory is later changed.
+FIRST_CHAR=`echo $PIDDIR | cut -c1,1`
+if [ "$FIRST_CHAR" != "/" ]
+then
+ PIDDIR=$REALDIR/$PIDDIR
+fi
+# Same test for WRAPPER_CMD
+FIRST_CHAR=`echo $WRAPPER_CMD | cut -c1,1`
+if [ "$FIRST_CHAR" != "/" ]
+then
+ WRAPPER_CMD=$REALDIR/$WRAPPER_CMD
+fi
+# Same test for WRAPPER_CONF
+FIRST_CHAR=`echo $WRAPPER_CONF | cut -c1,1`
+if [ "$FIRST_CHAR" != "/" ]
+then
+ WRAPPER_CONF=$REALDIR/$WRAPPER_CONF
+fi
+
+# Process ID
+ANCHORFILE="$PIDDIR/$APP_NAME.anchor"
+STATUSFILE="$PIDDIR/$APP_NAME.status"
+JAVASTATUSFILE="$PIDDIR/$APP_NAME.java.status"
+PIDFILE="$PIDDIR/$APP_NAME.pid"
+LOCKDIR="/var/lock/subsys"
+LOCKFILE="$LOCKDIR/$APP_NAME"
+pid=""
+
+# Resolve the location of the 'ps' command
+PSEXE="/usr/ucb/ps"
+ if [ ! -x "$PSEXE" ]
+ then
+ PSEXE="/usr/bin/ps"
+ if [ ! -x "$PSEXE" ]
+ then
+ PSEXE="/bin/ps"
+ if [ ! -x "$PSEXE" ]
+ then
+ echo "Unable to locate 'ps'."
+ echo "Please report this message along with the location of the command on your system."
+ exit 1
+ fi
+ fi
+ fi
+
+# Resolve the os
+DIST_OS=`uname -s | tr [A-Z] [a-z] | tr -d ' '`
+case "$DIST_OS" in
+ 'sunos')
+ DIST_OS="solaris"
+ ;;
+ 'hp-ux' | 'hp-ux64')
+ # HP-UX needs the XPG4 version of ps (for -o args)
+ DIST_OS="hpux"
+ UNIX95=""
+ export UNIX95
+ ;;
+ 'darwin')
+ DIST_OS="macosx"
+ ;;
+ 'unix_sv')
+ DIST_OS="unixware"
+ ;;
+ 'os/390')
+ DIST_OS="zos"
+ ;;
+esac
+
+# Resolve the architecture
+if [ "$DIST_OS" = "macosx" ]
+then
+ DIST_ARCH="universal"
+ APP_PLIST_BASE=${PLIST_DOMAIN}.${APP_NAME}
+ APP_PLIST=${APP_PLIST_BASE}.plist
+else
+ DIST_ARCH=
+ DIST_ARCH=`uname -p 2>/dev/null | tr [A-Z] [a-z] | tr -d ' '`
+ if [ "X$DIST_ARCH" = "X" ]
+ then
+ DIST_ARCH="unknown"
+ fi
+ if [ "$DIST_ARCH" = "unknown" ]
+ then
+ DIST_ARCH=`uname -m 2>/dev/null | tr [A-Z] [a-z] | tr -d ' '`
+ fi
+ case "$DIST_ARCH" in
+ 'athlon' | 'i386' | 'i486' | 'i586' | 'i686')
+ DIST_ARCH="x86"
+ if [ "${DIST_OS}" = "solaris" ] ; then
+ DIST_BITS=`isainfo -b`
+ else
+ DIST_BITS="32"
+ fi
+ ;;
+ 'amd64' | 'x86_64')
+ DIST_ARCH="x86"
+ DIST_BITS="64"
+ ;;
+ 'ia32')
+ DIST_ARCH="ia"
+ DIST_BITS="32"
+ ;;
+ 'ia64' | 'ia64n' | 'ia64w')
+ DIST_ARCH="ia"
+ DIST_BITS="64"
+ ;;
+ 'ip27')
+ DIST_ARCH="mips"
+ DIST_BITS="32"
+ ;;
+ 'power' | 'powerpc' | 'power_pc' | 'ppc64')
+ if [ "${DIST_ARCH}" = "ppc64" ] ; then
+ DIST_BITS="64"
+ else
+ DIST_BITS="32"
+ fi
+ DIST_ARCH="ppc"
+ if [ "${DIST_OS}" = "aix" ] ; then
+ if [ `getconf KERNEL_BITMODE` -eq 64 ]; then
+ DIST_BITS="64"
+ else
+ DIST_BITS="32"
+ fi
+ fi
+ ;;
+ 'pa_risc' | 'pa-risc')
+ DIST_ARCH="parisc"
+ if [ `getconf KERNEL_BITS` -eq 64 ]; then
+ DIST_BITS="64"
+ else
+ DIST_BITS="32"
+ fi
+ ;;
+ 'sun4u' | 'sparcv9' | 'sparc')
+ DIST_ARCH="sparc"
+ DIST_BITS=`isainfo -b`
+ if [ ! -f /usr/lib/libm.so.2 -a "${DIST_BITS}" = "32" ]; then
+ ln -s /usr/lib/libm.so.1 /usr/lib/libm.so.2
+ elif [ ! -f /usr/lib/sparcv9/libm.so.2 -a "${DIST_BITS}" = "64" ]; then
+ ln -s /usr/lib/sparcv9/libm.so.1 /usr/lib/sparcv9/libm.so.2
+ fi
+ ;;
+ '9000/800' | '9000/785')
+ DIST_ARCH="parisc"
+ if [ `getconf KERNEL_BITS` -eq 64 ]; then
+ DIST_BITS="64"
+ else
+ DIST_BITS="32"
+ fi
+ ;;
+ '2097')
+ DIST_ARCH="390"
+ DIST_BITS="32"
+ ;;
+ esac
+fi
+
+# OSX always places Java in the same location so we can reliably set JAVA_HOME
+if [ "$DIST_OS" = "macosx" ]
+then
+ if [ -z "$JAVA_HOME" ]; then
+ JAVA_HOME="/Library/Java/Home"; export JAVA_HOME
+ fi
+fi
+
+# Test Echo
+ECHOTEST=`echo -n "x"`
+if [ "$ECHOTEST" = "x" ]
+then
+ ECHOOPT="-n "
+else
+ ECHOOPT=""
+fi
+
+outputFile() {
+ if [ -f "$1" ]
+ then
+ echo " $1 (Found but not executable.)";
+ else
+ echo " $1"
+ fi
+}
+
+# Decide on the wrapper binary to use.
+# If the bits of the OS could be detected, we will try to look for the
+# binary with the correct bits value. If it doesn't exist, fall back
+# and look for the 32-bit binary. If that doesn't exist either then
+# look for the default.
+WRAPPER_TEST_CMD="$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-$DIST_BITS"
+if [ -x "$WRAPPER_TEST_CMD" ]
+then
+ WRAPPER_CMD="$WRAPPER_TEST_CMD"
+else
+ WRAPPER_TEST_CMD="$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-32"
+ if [ -x "$WRAPPER_TEST_CMD" ]
+ then
+ WRAPPER_CMD="$WRAPPER_TEST_CMD"
+ else
+ if [ ! -x "$WRAPPER_CMD" ]
+ then
+ echo "Unable to locate any of the following binaries:"
+ outputFile "$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-$DIST_BITS"
+ if [ ! "$DIST_BITS" = "32" ]
+ then
+ outputFile "$WRAPPER_CMD-$DIST_OS-$DIST_ARCH-32"
+ fi
+ outputFile "$WRAPPER_CMD"
+ exit 1
+ fi
+ fi
+fi
+
+# Build the nice clause
+if [ "X$PRIORITY" = "X" ]
+then
+ CMDNICE=""
+else
+ CMDNICE="nice -$PRIORITY"
+fi
+
+# Build the anchor file clause.
+if [ "X$IGNORE_SIGNALS" = "X" ]
+then
+ ANCHORPROP=
+ IGNOREPROP=
+else
+ ANCHORPROP=wrapper.anchorfile=\"$ANCHORFILE\"
+ IGNOREPROP=wrapper.ignore_signals=TRUE
+fi
+
+# Build the status file clause.
+if [ "X$DETAIL_STATUS$WAIT_FOR_STARTED_STATUS" = "X" ]
+then
+ STATUSPROP=
+else
+ STATUSPROP="wrapper.statusfile=\"$STATUSFILE\" wrapper.java.statusfile=\"$JAVASTATUSFILE\""
+fi
+
+if [ ! -n "$WAIT_FOR_STARTED_STATUS" ]
+then
+ WAIT_FOR_STARTED_STATUS=true
+fi
+
+if [ $WAIT_FOR_STARTED_STATUS = true ] ; then
+ DETAIL_STATUS=true
+fi
+
+
+# Build the lock file clause. Only create a lock file if the lock directory exists on this platform.
+LOCKPROP=
+if [ -d $LOCKDIR ]
+then
+ if [ -w $LOCKDIR ]
+ then
+ LOCKPROP=wrapper.lockfile=\"$LOCKFILE\"
+ fi
+fi
+
+checkUser() {
+ # $1 touchLock flag
+ # $2 command
+
+ # Check the configured user. If necessary rerun this script as the desired user.
+ if [ "X$RUN_AS_USER" != "X" ]
+ then
+ # Resolve the location of the 'id' command
+ IDEXE="/usr/xpg4/bin/id"
+ if [ ! -x "$IDEXE" ]
+ then
+ IDEXE="/usr/bin/id"
+ if [ ! -x "$IDEXE" ]
+ then
+ echo "Unable to locate 'id'."
+ echo "Please report this message along with the location of the command on your system."
+ exit 1
+ fi
+ fi
+
+ if [ "`$IDEXE -u -n`" = "$RUN_AS_USER" ]
+ then
+ # Already running as the configured user. Avoid password prompts by not calling su.
+ RUN_AS_USER=""
+ fi
+ fi
+ if [ "X$RUN_AS_USER" != "X" ]
+ then
+ # If LOCKPROP and $RUN_AS_USER are defined then the new user will most likely not be
+ # able to create the lock file. The Wrapper will be able to update this file once it
+ # is created but will not be able to delete it on shutdown. If $2 is defined then
+ # the lock file should be created for the current command
+ if [ "X$LOCKPROP" != "X" ]
+ then
+ if [ "X$1" != "X" ]
+ then
+ # Resolve the primary group
+ RUN_AS_GROUP=`groups $RUN_AS_USER | awk '{print $3}' | tail -1`
+ if [ "X$RUN_AS_GROUP" = "X" ]
+ then
+ RUN_AS_GROUP=$RUN_AS_USER
+ fi
+ touch $LOCKFILE
+ chown $RUN_AS_USER:$RUN_AS_GROUP $LOCKFILE
+ fi
+ fi
+
+ # Still want to change users, recurse. This means that the user will only be
+ # prompted for a password once. Variables shifted by 1
+ #
+ # Use "runuser" if this exists. runuser should be used on RedHat in preference to su.
+ #
+ if test -f "/sbin/runuser"
+ then
+ /sbin/runuser - $RUN_AS_USER -c "\"$REALPATH\" $2"
+ else
+ su - $RUN_AS_USER -c "\"$REALPATH\" $2"
+ fi
+
+ # Now that we are the original user again, we may need to clean up the lock file.
+ if [ "X$LOCKPROP" != "X" ]
+ then
+ getpid
+ if [ "X$pid" = "X" ]
+ then
+ # Wrapper is not running so make sure the lock file is deleted.
+ if [ -f "$LOCKFILE" ]
+ then
+ rm "$LOCKFILE"
+ fi
+ fi
+ fi
+
+ exit 0
+ fi
+}
+
+getpid() {
+ pid=""
+ if [ -f "$PIDFILE" ]
+ then
+ if [ -r "$PIDFILE" ]
+ then
+ pid=`cat "$PIDFILE"`
+ if [ "X$pid" != "X" ]
+ then
+ # It is possible that 'a' process with the pid exists but that it is not the
+ # correct process. This can happen in a number of cases, but the most
+ # common is during system startup after an unclean shutdown.
+ # The ps statement below looks for the specific wrapper command running as
+ # the pid. If it is not found then the pid file is considered to be stale.
+ case "$DIST_OS" in
+ 'freebsd')
+ pidtest=`$PSEXE -p $pid -o args | tail -1`
+ if [ "X$pidtest" = "XCOMMAND" ]
+ then
+ pidtest=""
+ fi
+ ;;
+ 'macosx')
+ pidtest=`$PSEXE -ww -p $pid -o command | grep "$WRAPPER_CMD" | tail -1`
+ ;;
+ 'solaris')
+ pidtest=`$PSEXE -auxww $pid | grep "$WRAPPER_CMD" | tail -1`
+ ;;
+ 'hpux')
+ pidtest=`$PSEXE -p $pid -x -o args | grep "$WRAPPER_CMD" | tail -1`
+ ;;
+ *)
+ pidtest=`$PSEXE -p $pid -o args | grep "$WRAPPER_CMD" | tail -1`
+ ;;
+ esac
+
+ if [ "X$pidtest" = "X" ]
+ then
+ # This is a stale pid file.
+ rm -f "$PIDFILE"
+ echo "Removed stale pid file: $PIDFILE"
+ pid=""
+ fi
+ fi
+ else
+ echo "Cannot read $PIDFILE."
+ exit 1
+ fi
+ fi
+}
+
+getstatus() {
+ STATUS=
+ if [ -f "$STATUSFILE" ]
+ then
+ if [ -r "$STATUSFILE" ]
+ then
+ STATUS=`cat "$STATUSFILE"`
+ fi
+ fi
+ if [ "X$STATUS" = "X" ]
+ then
+ STATUS="Unknown"
+ fi
+
+ JAVASTATUS=
+ if [ -f "$JAVASTATUSFILE" ]
+ then
+ if [ -r "$JAVASTATUSFILE" ]
+ then
+ JAVASTATUS=`cat "$JAVASTATUSFILE"`
+ fi
+ fi
+ if [ "X$JAVASTATUS" = "X" ]
+ then
+ JAVASTATUS="Unknown"
+ fi
+}
+
+testpid() {
+ case "$DIST_OS" in
+ 'solaris')
+ pid=`$PSEXE $pid | grep $pid | grep -v grep | awk '{print $1}' | tail -1` 2>/dev/null
+ ;;
+ *)
+ pid=`$PSEXE -p $pid | grep $pid | grep -v grep | awk '{print $1}' | tail -1` 2>/dev/null
+ ;;
+ esac
+ if [ "X$pid" = "X" ]
+ then
+ # Process is gone so remove the pid file.
+ rm -f "$PIDFILE"
+ pid=""
+ fi
+}
+
+launchdtrap() {
+ stopit
+ exit
+}
+
+waitforwrapperstop() {
+ getpid
+ while [ "X$pid" != "X" ] ; do
+ sleep 1
+ getpid
+ done
+}
+
+launchdinternal() {
+ getpid
+ trap launchdtrap TERM
+ if [ "X$pid" = "X" ]
+ then
+ # The string passed to eval must handles spaces in paths correctly.
+ COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.app.parameter.1=$1 wrapper.syslog.ident=\"$APP_NAME\" wrapper.pidfile=\"$PIDFILE\" wrapper.name=\"$APP_NAME\" wrapper.displayname=\"$APP_LONG_NAME\" wrapper.daemonize=TRUE $ANCHORPROP $IGNOREPROP $STATUSPROP $LOCKPROP"
+ eval $COMMAND_LINE
+ else
+ echo "$APP_LONG_NAME is already running."
+ exit 1
+ fi
+ # launchd expects that this script stay up and running so we need to do our own monitoring of the Wrapper process.
+ if [ $WAIT_FOR_STARTED_STATUS = true ]
+ then
+ waitforwrapperstop
+ fi
+}
+
+console() {
+ echo "Running $APP_LONG_NAME..."
+ getpid
+ if [ "X$pid" = "X" ]
+ then
+ trap '' 3
+ # The string passed to eval must handles spaces in paths correctly.
+ COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"$APP_NAME\" wrapper.pidfile=\"$PIDFILE\" wrapper.name=\"$APP_NAME\" wrapper.displayname=\"$APP_LONG_NAME\" $ANCHORPROP $STATUSPROP $LOCKPROP"
+ eval $COMMAND_LINE
+ else
+ echo "$APP_LONG_NAME is already running."
+ exit 1
+ fi
+}
+
+waitforjavastartup() {
+ getstatus
+ echo $ECHOOPT"Waiting for $APP_LONG_NAME..."
+
+ # Wait until the timeout or we have something besides Unknown.
+ counter=15
+ while [ "$JAVASTATUS" = "Unknown" -a $counter -gt 0 -a -n "$JAVASTATUS" ] ; do
+ echo $ECHOOPT"."
+ sleep 1
+ getstatus
+ counter=`expr $counter - 1`
+ done
+
+ if [ -n "$WAIT_FOR_STARTED_TIMEOUT" ] ; then
+ counter=$WAIT_FOR_STARTED_TIMEOUT
+ else
+ counter=120
+ fi
+ while [ "$JAVASTATUS" != "STARTED" -a "$JAVASTATUS" != "Unknown" -a $counter -gt 0 -a -n "$JAVASTATUS" ] ; do
+ echo $ECHOOPT"."
+ sleep 1
+ getstatus
+ counter=`expr $counter - 1`
+ done
+ if [ "X$ECHOOPT" != "X" ] ; then
+ echo ""
+ fi
+ echo "$APP_LONG_NAME started."
+}
+
+startwait() {
+ if [ $WAIT_FOR_STARTED_STATUS = true ]
+ then
+ waitforjavastartup
+ fi
+ # Sleep for a few seconds to allow for intialization if required
+ # then test to make sure we're still running.
+ #
+ i=0
+ while [ $i -lt $WAIT_AFTER_STARTUP ]
+ do
+ sleep 1
+ echo $ECHOOPT"."
+ i=`expr $i + 1`
+ done
+ if [ $WAIT_AFTER_STARTUP -gt 0 ]
+ then
+ getpid
+ if [ "X$pid" = "X" ]
+ then
+ echo " WARNING: $APP_LONG_NAME may have failed to start."
+ exit 1
+ else
+ echo " running ($pid)."
+ fi
+ else
+ echo ""
+ fi
+}
+
+macosxstart() {
+ # The daemon has been installed.
+ echo "Starting $APP_LONG_NAME. Detected Mac OSX and installed launchd daemon."
+ if [ `id | sed 's/^uid=//;s/(.*$//'` != "0" ] ; then
+ echo "Must be root to perform this action."
+ exit 1
+ fi
+
+ getpid
+ if [ "X$pid" != "X" ] ; then
+ echo "$APP_LONG_NAME is already running."
+ exit 1
+ fi
+
+ # If the daemon was just installed, it may not be loaded.
+ LOADED_PLIST=`launchctl list | grep ${APP_PLIST_BASE}`
+ if [ "X${LOADED_PLIST}" = "X" ] ; then
+ launchctl load /Library/LaunchDaemons/${APP_PLIST}
+ fi
+ # If launchd is set to run the daemon already at Load, we don't need to call start
+ getpid
+ if [ "X$pid" == "X" ] ; then
+ launchctl start ${APP_PLIST_BASE}
+ fi
+
+ startwait
+}
+
+start() {
+ echo $ECHOOPT"Starting $APP_LONG_NAME..."
+ getpid
+ if [ "X$pid" = "X" ]
+ then
+ # The string passed to eval must handles spaces in paths correctly.
+ COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" wrapper.syslog.ident=\"$APP_NAME\" wrapper.pidfile=\"$PIDFILE\" wrapper.name=\"$APP_NAME\" wrapper.displayname=\"$APP_LONG_NAME\" wrapper.daemonize=TRUE $ANCHORPROP $IGNOREPROP $STATUSPROP $LOCKPROP"
+ eval $COMMAND_LINE
+ else
+ echo "$APP_LONG_NAME is already running."
+ exit 1
+ fi
+
+ startwait
+}
+
+stopit() {
+ # $1 exit if down flag
+
+ echo "Stopping $APP_LONG_NAME..."
+ getpid
+ if [ "X$pid" = "X" ]
+ then
+ echo "$APP_LONG_NAME was not running."
+ if [ "X$1" = "X1" ]
+ then
+ exit 1
+ fi
+ else
+ if [ "X$IGNORE_SIGNALS" = "X" ]
+ then
+ # Running so try to stop it.
+ kill $pid
+ if [ $? -ne 0 ]
+ then
+ # An explanation for the failure should have been given
+ echo "Unable to stop $APP_LONG_NAME."
+ exit 1
+ fi
+ else
+ rm -f "$ANCHORFILE"
+ if [ -f "$ANCHORFILE" ]
+ then
+ # An explanation for the failure should have been given
+ echo "Unable to stop $APP_LONG_NAME."
+ exit 1
+ fi
+ fi
+
+ # We can not predict how long it will take for the wrapper to
+ # actually stop as it depends on settings in wrapper.conf.
+ # Loop until it does.
+ savepid=$pid
+ CNT=0
+ TOTCNT=0
+ while [ "X$pid" != "X" ]
+ do
+ # Show a waiting message every 5 seconds.
+ if [ "$CNT" -lt "5" ]
+ then
+ CNT=`expr $CNT + 1`
+ else
+ echo "Waiting for $APP_LONG_NAME to exit..."
+ CNT=0
+ fi
+ TOTCNT=`expr $TOTCNT + 1`
+
+ sleep 1
+
+ testpid
+ done
+
+ pid=$savepid
+ testpid
+ if [ "X$pid" != "X" ]
+ then
+ echo "Failed to stop $APP_LONG_NAME."
+ exit 1
+ else
+ echo "Stopped $APP_LONG_NAME."
+ fi
+ fi
+}
+
+status() {
+ getpid
+ if [ "X$pid" = "X" ]
+ then
+ echo "$APP_LONG_NAME is not running."
+ exit 1
+ else
+ if [ "X$DETAIL_STATUS" = "X" ]
+ then
+ echo "$APP_LONG_NAME is running (PID:$pid)."
+ else
+ getstatus
+ echo "$APP_LONG_NAME is running (PID:$pid, Wrapper:$STATUS, Java:$JAVASTATUS)"
+ fi
+ exit 0
+ fi
+}
+
+installdaemon() {
+ if [ `id | sed 's/^uid=//;s/(.*$//'` != "0" ] ; then
+ echo "Must be root to perform this action."
+ exit 1
+ else
+ if [ "$DIST_OS" = "solaris" ] ; then
+ echo "Detected Solaris:"
+ if [ -f /etc/init.d/$APP_NAME ] ; then
+ echo " The $APP_LONG_NAME daemon is already installed."
+ exit 1
+ else
+ echo " Installing the $APP_LONG_NAME daemon.."
+ ln -s $REALPATH /etc/init.d/$APP_NAME
+ ln -s /etc/init.d/$APP_NAME /etc/rc3.d/K20$APP_NAME
+ ln -s /etc/init.d/$APP_NAME /etc/rc3.d/S20$APP_NAME
+ fi
+ elif [ "$DIST_OS" = "linux" ] ; then
+ if [ -f /etc/redhat-release -o -f /etc/redhat_version -o -f /etc/fedora-release ] ; then
+ echo "Detected RHEL or Fedora:"
+ if [ -f /etc/init.d/$APP_NAME ] ; then
+ echo " The $APP_LONG_NAME daemon is already installed."
+ exit 1
+ else
+ echo " Installing the $APP_LONG_NAME daemon.."
+ ln -s $REALPATH /etc/init.d/$APP_NAME
+ /sbin/chkconfig --add $APP_NAME
+ /sbin/chkconfig $APP_NAME on
+ fi
+ elif [ -f /etc/SuSE-release ] ; then
+ echo "Detected SuSE or SLES:"
+ if [ -f /etc/init.d/$APP_NAME ] ; then
+ echo " The $APP_LONG_NAME daemon is already installed."
+ exit 1
+ else
+ echo " Installing the $APP_LONG_NAME daemon.."
+ ln -s $REALPATH /etc/init.d/$APP_NAME
+ insserv /etc/init.d/$APP_NAME
+ fi
+ elif [ -f /etc/lsb-release ] ; then
+ echo "Detected Ubuntu:"
+ if [ -f /etc/init.d/$APP_NAME ] ; then
+ echo " The $APP_LONG_NAME daemon is already installed."
+ exit 1
+ else
+ echo " Installing the $APP_LONG_NAME daemon.."
+ ln -s $REALPATH /etc/init.d/$APP_NAME
+ update-rc.d $APP_NAME defaults
+ fi
+ else
+ echo "Detected Linux:"
+ if [ -f /etc/init.d/$APP_NAME ] ; then
+ echo " The $APP_LONG_NAME daemon is already installed."
+ exit 1
+ else
+ echo " Installing the $APP_LONG_NAME daemon.."
+ ln -s $REALPATH /etc/init.d/$APP_NAME
+ ln -s /etc/init.d/$APP_NAME /etc/rc3.d/K20$APP_NAME
+ ln -s /etc/init.d/$APP_NAME /etc/rc3.d/S20$APP_NAME
+ ln -s /etc/init.d/$APP_NAME /etc/rc5.d/S20$APP_NAME
+ ln -s /etc/init.d/$APP_NAME /etc/rc5.d/K20$APP_NAME
+ fi
+ fi
+ elif [ "$DIST_OS" = "hpux" ] ; then
+ echo "Detected HP-UX:"
+ if [ -f /sbin/init.d/$APP_NAME ] ; then
+ echo " The $APP_LONG_NAME daemon is already installed."
+ exit 1
+ else
+ echo " Installing the $APP_LONG_NAME daemon.."
+ ln -s $REALPATH /sbin/init.d/$APP_NAME
+ ln -s /sbin/init.d/$APP_NAME /sbin/rc3.d/K20$APP_NAME
+ ln -s /sbin/init.d/$APP_NAME /sbin/rc3.d/S20$APP_NAME
+ fi
+ elif [ "$DIST_OS" = "aix" ] ; then
+ echo "Detected AIX:"
+ if [ -f /etc/rc.d/init.d/$APP_NAME ] ; then
+ echo " The $APP_LONG_NAME daemon is already installed."
+ exit 1
+ else
+ echo " Installing the $APP_LONG_NAME daemon.."
+ ln -s $REALPATH /etc/rc.d/init.d/$APP_NAME
+ ln -s /etc/rc.d/init.d/$APP_NAME /etc/rc.d/rc2.d/S20$APP_NAME
+ ln -s /etc/rc.d/init.d/$APP_NAME /etc/rc.d/rc2.d/K20$APP_NAME
+ fi
+ elif [ "$DIST_OS" = "freebsd" ] ; then
+ echo "Detected FreeBSD:"
+ if [ -f /etc/rc.d/$APP_NAME ] ; then
+ echo " The $APP_LONG_NAME daemon is already installed."
+ exit 1
+ else
+ echo " Installing the $APP_LONG_NAME daemon.."
+ sed -i .bak "/${APP_NAME}_enable=\"YES\"/d" /etc/rc.conf
+ if [ -f ${REALDIR}/${APP_NAME}.install ] ; then
+ ln -s ${REALDIR}/${APP_NAME}.install /etc/rc.d/$APP_NAME
+ else
+ echo '#!/bin/sh' > /etc/rc.d/$APP_NAME
+ echo "#" >> /etc/rc.d/$APP_NAME
+ echo "# PROVIDE: $APP_NAME" >> /etc/rc.d/$APP_NAME
+ echo "# REQUIRE: NETWORKING" >> /etc/rc.d/$APP_NAME
+ echo "# KEYWORD: shutdown" >> /etc/rc.d/$APP_NAME
+ echo ". /etc/rc.subr" >> /etc/rc.d/$APP_NAME
+ echo "name=\"$APP_NAME\"" >> /etc/rc.d/$APP_NAME
+ echo "rcvar=\`set_rcvar\`" >> /etc/rc.d/$APP_NAME
+ echo "command=\"${REALDIR}/${APP_NAME}\"" >> /etc/rc.d/$APP_NAME
+ echo 'start_cmd="${name}_start"' >> /etc/rc.d/$APP_NAME
+ echo 'load_rc_config $name' >> /etc/rc.d/$APP_NAME
+ echo 'status_cmd="${name}_status"' >> /etc/rc.d/$APP_NAME
+ echo 'stop_cmd="${name}_stop"' >> /etc/rc.d/$APP_NAME
+ echo "${APP_NAME}_status() {" >> /etc/rc.d/$APP_NAME
+ echo '${command} status' >> /etc/rc.d/$APP_NAME
+ echo '}' >> /etc/rc.d/$APP_NAME
+ echo "${APP_NAME}_stop() {" >> /etc/rc.d/$APP_NAME
+ echo '${command} stop' >> /etc/rc.d/$APP_NAME
+ echo '}' >> /etc/rc.d/$APP_NAME
+ echo "${APP_NAME}_start() {" >> /etc/rc.d/$APP_NAME
+ echo '${command} start' >> /etc/rc.d/$APP_NAME
+ echo '}' >> /etc/rc.d/$APP_NAME
+ echo 'run_rc_command "$1"' >> /etc/rc.d/$APP_NAME
+ fi
+ echo "${APP_NAME}_enable=\"YES\"" >> /etc/rc.conf
+ chmod 555 /etc/rc.d/$APP_NAME
+ fi
+ elif [ "$DIST_OS" = "macosx" ] ; then
+ echo "Detected Mac OSX:"
+ if [ -f /Library/LaunchDaemons/${APP_PLIST} ] ; then
+ echo " The $APP_LONG_NAME daemon is already installed."
+ exit 1
+ else
+ echo " Installing the $APP_LONG_NAME daemon.."
+ if [ -f ${REALDIR}/${APP_PLIST} ] ; then
+ ln -s ${REALDIR}/${APP_PLIST} /Library/LaunchDaemons/${APP_PLIST}
+ else
+ echo "" > /Library/LaunchDaemons/${APP_PLIST}
+ echo "> /Library/LaunchDaemons/${APP_PLIST}
+ echo "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">" >> /Library/LaunchDaemons/${APP_PLIST}
+ echo "" >> /Library/LaunchDaemons/${APP_PLIST}
+ echo " " >> /Library/LaunchDaemons/${APP_PLIST}
+ echo " Label" >> /Library/LaunchDaemons/${APP_PLIST}
+ echo " ${APP_PLIST_BASE}" >> /Library/LaunchDaemons/${APP_PLIST}
+ echo " ProgramArguments" >> /Library/LaunchDaemons/${APP_PLIST}
+ echo " " >> /Library/LaunchDaemons/${APP_PLIST}
+ echo " ${REALDIR}/${APP_NAME}" >> /Library/LaunchDaemons/${APP_PLIST}
+ echo " launchdinternal" >> /Library/LaunchDaemons/${APP_PLIST}
+ echo " " >> /Library/LaunchDaemons/${APP_PLIST}
+ echo " OnDemand" >> /Library/LaunchDaemons/${APP_PLIST}
+ echo " " >> /Library/LaunchDaemons/${APP_PLIST}
+ echo " RunAtLoad" >> /Library/LaunchDaemons/${APP_PLIST}
+ echo " " >> /Library/LaunchDaemons/${APP_PLIST}
+ if [ "X$RUN_AS_USER" != "X" ] ; then
+ echo " UserName" >> /Library/LaunchDaemons/${APP_PLIST}
+ echo " ${RUN_AS_USER}" >> /Library/LaunchDaemons/${APP_PLIST}
+ fi
+ echo " " >> /Library/LaunchDaemons/${APP_PLIST}
+ echo "" >> /Library/LaunchDaemons/${APP_PLIST}
+ fi
+ chmod 555 /Library/LaunchDaemons/${APP_PLIST}
+ fi
+ elif [ "$DIST_OS" = "zos" ] ; then
+ echo "Detected z/OS:"
+ if [ -f /etc/rc.bak ] ; then
+ echo " The $APP_LONG_NAME daemon is already installed."
+ exit 1
+ else
+ echo " Installing the $APP_LONG_NAME daemon.."
+ cp /etc/rc /etc/rc.bak
+ sed "s:echo /etc/rc script executed, \`date\`::g" /etc/rc.bak > /etc/rc
+ echo "_BPX_JOBNAME='${APP_NAME}' ${REALDIR}/${APP_NAME} start" >>/etc/rc
+ echo '/etc/rc script executed, `date`' >>/etc/rc
+ fi
+ else
+ echo "Install not currently supported for $DIST_OS"
+ exit 1
+ fi
+ fi
+}
+
+removedaemon() {
+ if [ `id | sed 's/^uid=//;s/(.*$//'` != "0" ] ; then
+ echo "Must be root to perform this action."
+ exit 1
+ else
+ stopit "0"
+ if [ "$DIST_OS" = "solaris" ] ; then
+ echo "Detected Solaris:"
+ if [ -f /etc/init.d/$APP_NAME ] ; then
+ echo " Removing $APP_LONG_NAME daemon..."
+ for i in /etc/rc3.d/S20$APP_NAME /etc/rc3.d/K20$APP_NAME /etc/init.d/$APP_NAME
+ do
+ rm -f $i
+ done
+ else
+ echo " The $APP_LONG_NAME daemon is not currently installed."
+ exit 1
+ fi
+ elif [ "$DIST_OS" = "linux" ] ; then
+ if [ -f /etc/redhat-release -o -f /etc/redhat_version -o -f /etc/fedora-release ] ; then
+ echo "Detected RHEL or Fedora:"
+ if [ -f /etc/init.d/$APP_NAME ] ; then
+ echo " Removing $APP_LONG_NAME daemon..."
+ /sbin/chkconfig $APP_NAME off
+ /sbin/chkconfig --del $APP_NAME
+ rm -f /etc/init.d/$APP_NAME
+ else
+ echo " The $APP_LONG_NAME daemon is not currently installed."
+ exit 1
+ fi
+ elif [ -f /etc/SuSE-release ] ; then
+ echo "Detected SuSE or SLES:"
+ if [ -f /etc/init.d/$APP_NAME ] ; then
+ echo " Removing $APP_LONG_NAME daemon..."
+ insserv -r /etc/init.d/$APP_NAME
+ rm -f /etc/init.d/$APP_NAME
+ else
+ echo " The $APP_LONG_NAME daemon is not currently installed."
+ exit 1
+ fi
+ elif [ -f /etc/lsb-release ] ; then
+ echo "Detected Ubuntu:"
+ if [ -f /etc/init.d/$APP_NAME ] ; then
+ echo " Removing $APP_LONG_NAME daemon..."
+ update-rc.d -f $APP_NAME remove
+ rm -f /etc/init.d/$APP_NAME
+ else
+ echo " The $APP_LONG_NAME daemon is not currently installed."
+ exit 1
+ fi
+ else
+ echo "Detected Linux:"
+ if [ -f /etc/init.d/$APP_NAME ] ; then
+ echo " Removing $APP_LONG_NAME daemon..."
+ for i in /etc/rc3.d/K20$APP_NAME /etc/rc5.d/K20$APP_NAME /etc/rc3.d/S20$APP_NAME /etc/init.d/$APP_NAME /etc/rc5.d/S20$APP_NAME
+ do
+ rm -f $i
+ done
+ else
+ echo " The $APP_LONG_NAME daemon is not currently installed."
+ exit 1
+ fi
+ fi
+ elif [ "$DIST_OS" = "hpux" ] ; then
+ echo "Detected HP-UX:"
+ if [ -f /sbin/init.d/$APP_NAME ] ; then
+ echo " Removing $APP_LONG_NAME daemon..."
+ for i in /sbin/rc3.d/K20$APP_NAME /sbin/rc3.d/S20$APP_NAME /sbin/init.d/$APP_NAME
+ do
+ rm -f $i
+ done
+ else
+ echo " The $APP_LONG_NAME daemon is not currently installed."
+ exit 1
+ fi
+ elif [ "$DIST_OS" = "aix" ] ; then
+ echo "Detected AIX:"
+ if [ -f /etc/rc.d/init.d/$APP_NAME ] ; then
+ echo " Removing $APP_LONG_NAME daemon..."
+ for i in /etc/rc.d/rc2.d/S20$APP_NAME /etc/rc.d/rc2.d/K20$APP_NAME /etc/rc.d/init.d/$APP_NAME
+ do
+ rm -f $i
+ done
+ else
+ echo " The $APP_LONG_NAME daemon is not currently installed."
+ exit 1
+ fi
+ elif [ "$DIST_OS" = "freebsd" ] ; then
+ echo "Detected FreeBSD:"
+ if [ -f /etc/rc.d/$APP_NAME ] ; then
+ echo " Removing $APP_LONG_NAME daemon..."
+ for i in /etc/rc.d/$APP_NAME
+ do
+ rm -f $i
+ done
+ sed -i .bak "/${APP_NAME}_enable=\"YES\"/d" /etc/rc.conf
+ else
+ echo " The $APP_LONG_NAME daemon is not currently installed."
+ exit 1
+ fi
+ elif [ "$DIST_OS" = "macosx" ] ; then
+ echo "Detected Mac OSX:"
+ if [ -f "/Library/LaunchDaemons/${APP_PLIST}" ] ; then
+ echo " Removing $APP_LONG_NAME daemon..."
+ # Make sure the plist is installed
+ LOADED_PLIST=`launchctl list | grep ${APP_PLIST_BASE}`
+ if [ "X${LOADED_PLIST}" != "X" ] ; then
+ launchctl unload /Library/LaunchDaemons/${APP_PLIST}
+ fi
+ rm -f /Library/LaunchDaemons/${APP_PLIST}
+ else
+ echo " The $APP_LONG_NAME daemon is not currently installed."
+ exit 1
+ fi
+ elif [ "$DIST_OS" = "zos" ] ; then
+ echo "Detected z/OS:"
+ if [ -f /etc/rc.bak ] ; then
+ echo " Removing $APP_LONG_NAME daemon..."
+ cp /etc/rc /etc/rc.bak
+ sed "s/_BPX_JOBNAME=\'APP_NAME\'.*//g" /etc/rc.bak > /etc/rc
+ rm /etc/rc.bak
+ else
+ echo " The $APP_LONG_NAME daemon is not currently installed."
+ exit 1
+ fi
+ else
+ echo "Remove not currently supported for $DIST_OS"
+ exit 1
+ fi
+ fi
+}
+
+dump() {
+ echo "Dumping $APP_LONG_NAME..."
+ getpid
+ if [ "X$pid" = "X" ]
+ then
+ echo "$APP_LONG_NAME was not running."
+ else
+ kill -3 $pid
+
+ if [ $? -ne 0 ]
+ then
+ echo "Failed to dump $APP_LONG_NAME."
+ exit 1
+ else
+ echo "Dumped $APP_LONG_NAME."
+ fi
+ fi
+}
+
+# Used by HP-UX init scripts.
+startmsg() {
+ getpid
+ if [ "X$pid" = "X" ]
+ then
+ echo "Starting $APP_LONG_NAME... (Wrapper:Stopped)"
+ else
+ if [ "X$DETAIL_STATUS" = "X" ]
+ then
+ echo "Starting $APP_LONG_NAME... (Wrapper:Running)"
+ else
+ getstatus
+ echo "Starting $APP_LONG_NAME... (Wrapper:$STATUS, Java:$JAVASTATUS)"
+ fi
+ fi
+}
+
+# Used by HP-UX init scripts.
+stopmsg() {
+ getpid
+ if [ "X$pid" = "X" ]
+ then
+ echo "Stopping $APP_LONG_NAME... (Wrapper:Stopped)"
+ else
+ if [ "X$DETAIL_STATUS" = "X" ]
+ then
+ echo "Stopping $APP_LONG_NAME... (Wrapper:Running)"
+ else
+ getstatus
+ echo "Stopping $APP_LONG_NAME... (Wrapper:$STATUS, Java:$JAVASTATUS)"
+ fi
+ fi
+}
+
+case "$1" in
+
+ 'console')
+ checkUser touchlock $1
+ console
+ ;;
+
+ 'start')
+ if [ "$DIST_OS" = "macosx" -a -f "/Library/LaunchDaemons/${APP_PLIST}" ] ; then
+ macosxstart
+ else
+ checkUser touchlock $1
+ start
+ fi
+ ;;
+
+ 'stop')
+ checkUser "" $1
+ stopit "0"
+ ;;
+
+ 'restart')
+ checkUser touchlock $1
+ stopit "0"
+ start
+ ;;
+
+ 'condrestart')
+ checkUser touchlock $1
+ stopit "1"
+ start
+ ;;
+
+ 'status')
+ checkUser "" $1
+ status
+ ;;
+
+ 'install')
+ installdaemon
+ ;;
+
+ 'remove')
+ removedaemon
+ ;;
+
+ 'dump')
+ checkUser "" $1
+ dump
+ ;;
+
+ 'start_msg')
+ # Internal command called by launchd on HP-UX.
+ checkUser "" $1
+ startmsg
+ ;;
+
+ 'stop_msg')
+ # Internal command called by launchd on HP-UX.
+ checkUser "" $1
+ stopmsg
+ ;;
+
+ 'launchdinternal')
+ # Internal command called by launchd on Max OSX.
+ # We do not want to call checkUser here as it is handled in the launchd plist file. Doing it here would confuse launchd.
+ launchdinternal
+ ;;
+
+ *)
+ echo "Usage: $0 { console | start | stop | restart | condrestart | status | install | remove | dump }"
+ exit 1
+ ;;
+esac
+
+exit 0
diff --git a/bin/service/elasticsearch.bat b/bin/service/elasticsearch.bat
new file mode 100644
index 00000000000..cec9ef99b99
--- /dev/null
+++ b/bin/service/elasticsearch.bat
@@ -0,0 +1,118 @@
+@echo off
+setlocal
+
+rem Java Service Wrapper command based script.
+
+rem -----------------------------------------------------------------------------
+rem These settings can be modified to fit the needs of your application
+rem Optimized for use with version 3.4.0 of the Wrapper.
+
+rem SET ES_HOME
+set ES_HOME=%~dp0\..\..
+
+rem The base name for the Wrapper binary.
+set _WRAPPER_BASE=\exec\elasticsearch
+
+rem The name and location of the Wrapper configuration file.
+rem (Do not remove quotes.)
+set _WRAPPER_CONF="..\elasticsearch.conf"
+
+rem Do not modify anything beyond this point
+rem -----------------------------------------------------------------------------
+
+if "%OS%"=="Windows_NT" goto nt
+echo This script only works with NT-based versions of Windows.
+goto :eof
+
+:nt
+rem Find the application home.
+rem %~dp0 is location of current script under NT
+set _REALPATH=%~dp0
+
+rem
+rem Decide on the specific Wrapper binary to use (See delta-pack)
+rem
+if "%PROCESSOR_ARCHITECTURE%"=="AMD64" goto amd64
+if "%PROCESSOR_ARCHITECTURE%"=="IA64" goto ia64
+set _WRAPPER_L_EXE=%_REALPATH%%_WRAPPER_BASE%-windows-x86-32.exe
+goto search
+:amd64
+set _WRAPPER_L_EXE=%_REALPATH%%_WRAPPER_BASE%-windows-x86-64.exe
+goto search
+:ia64
+set _WRAPPER_L_EXE=%_REALPATH%%_WRAPPER_BASE%-windows-ia-64.exe
+goto search
+:search
+set _WRAPPER_EXE=%_WRAPPER_L_EXE%
+if exist "%_WRAPPER_EXE%" goto validate
+set _WRAPPER_EXE=%_REALPATH%%_WRAPPER_BASE%.exe
+if exist "%_WRAPPER_EXE%" goto validate
+echo Unable to locate a Wrapper executable using any of the following names:
+echo %_WRAPPER_L_EXE%
+echo %_WRAPPER_EXE%
+pause
+goto :eof
+
+:validate
+rem
+rem Find the requested command.
+rem
+for /F %%v in ('echo %1^|findstr "^console$ ^start$ ^pause$ ^resume$ ^stop$ ^restart$ ^install$ ^remove$"') do call :exec set COMMAND=%%v
+
+if "%COMMAND%" == "" (
+ echo Usage: %0 { console : start : pause : resume : stop : restart : install : remove }
+ pause
+ goto :eof
+) else (
+ shift
+)
+
+rem
+rem Run the application.
+rem At runtime, the current directory will be that of wrapper.exe
+rem
+call :%COMMAND%
+if errorlevel 1 goto callerror
+goto :eof
+
+:callerror
+echo An error occurred in the process.
+pause
+goto :eof
+
+:console
+"%_WRAPPER_EXE%" -c %_WRAPPER_CONF%
+goto :eof
+
+:start
+"%_WRAPPER_EXE%" -t %_WRAPPER_CONF%
+goto :eof
+
+:pause
+"%_WRAPPER_EXE%" -a %_WRAPPER_CONF%
+goto :eof
+
+:resume
+"%_WRAPPER_EXE%" -e %_WRAPPER_CONF%
+goto :eof
+
+:stop
+"%_WRAPPER_EXE%" -p %_WRAPPER_CONF%
+goto :eof
+
+:install
+"%_WRAPPER_EXE%" -i %_WRAPPER_CONF%
+goto :eof
+
+:remove
+"%_WRAPPER_EXE%" -r %_WRAPPER_CONF%
+goto :eof
+
+:restart
+call :stop
+call :start
+goto :eof
+
+:exec
+%*
+goto :eof
diff --git a/bin/service/elasticsearch.conf b/bin/service/elasticsearch.conf
new file mode 100644
index 00000000000..19b9b7723ac
--- /dev/null
+++ b/bin/service/elasticsearch.conf
@@ -0,0 +1,125 @@
+set.default.ES_HOME=
+
+#********************************************************************
+# Wrapper Timeout Properties
+#********************************************************************
+# How long to wait for the JVM to start (in seconds)
+wrapper.startup.timeout=300
+# How long to wait for the JVM to stop (in seconds)
+wrapper.shutdown.timeout=300
+# When a ping will timeout to consider the JVM hung (in seconds)
+wrapper.ping.timeout=300
+
+#********************************************************************
+# Wrapper Java Properties
+#********************************************************************
+# Java Application
+wrapper.java.command=java
+
+# Tell the Wrapper to log the full generated Java command line.
+#wrapper.java.command.loglevel=INFO
+
+wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp
+
+wrapper.working.dir=%ES_HOME%
+
+# Java Classpath (include wrapper.jar) Add class path elements as
+# needed starting from 1
+wrapper.java.classpath.1=%ES_HOME%/bin/service/lib/wrapper.jar
+wrapper.java.classpath.2=%ES_HOME%/lib/*.jar
+
+# Java Library Path (location of Wrapper.DLL or libwrapper.so)
+wrapper.java.library.path.1=%ES_HOME%/bin/service/lib
+
+# Java Bits. On applicable platforms, tells the JVM to run in 32 or 64-bit mode.
+wrapper.java.additional.auto_bits=TRUE
+
+# Java Additional Parameters
+wrapper.java.additional.1=-Delasticsearch-service
+wrapper.java.additional.2=-Des-foreground=yes
+wrapper.java.additional.3=-Des.path.home=%ES_HOME%
+wrapper.java.additional.4=-Djline.enabled=true
+wrapper.java.additional.5=-XX:+AggressiveOpts
+wrapper.java.additional.6=-XX:+UseParNewGC
+wrapper.java.additional.7=-XX:+UseConcMarkSweepGC
+wrapper.java.additional.8=-XX:+CMSParallelRemarkEnabled
+wrapper.java.additional.9=-XX:+HeapDumpOnOutOfMemoryError
+
+# Initial Java Heap Size (in MB)
+wrapper.java.initmemory=128
+
+# Maximum Java Heap Size (in MB)
+wrapper.java.maxmemory=1024
+
+# Application parameters. Add parameters as needed starting from 1
+wrapper.app.parameter.1=org.elasticsearch.bootstrap.Bootstrap
+
+#********************************************************************
+# Wrapper Logging Properties
+#********************************************************************
+# Enables Debug output from the Wrapper.
+# wrapper.debug=TRUE
+
+# Format of output for the console. (See docs for formats)
+wrapper.console.format=PM
+
+# Log Level for console output. (See docs for log levels)
+wrapper.console.loglevel=INFO
+
+# Log file to use for wrapper output logging.
+wrapper.logfile=%ES_HOME%/work/logs/service.log
+
+# Format of output for the log file. (See docs for formats)
+wrapper.logfile.format=LPTM
+
+# Log Level for log file output. (See docs for log levels)
+wrapper.logfile.loglevel=INFO
+
+# Maximum size that the log file will be allowed to grow to before
+# the log is rolled. Size is specified in bytes. The default value
+# of 0, disables log rolling. May abbreviate with the 'k' (kb) or
+# 'm' (mb) suffix. For example: 10m = 10 megabytes.
+wrapper.logfile.maxsize=0
+
+# Maximum number of rolled log files which will be allowed before old
+# files are deleted. The default value of 0 implies no limit.
+wrapper.logfile.maxfiles=0
+
+# Log Level for sys/event log output. (See docs for log levels)
+wrapper.syslog.loglevel=NONE
+
+#********************************************************************
+# Wrapper General Properties
+#********************************************************************
+# Allow for the use of non-contiguous numbered properties
+wrapper.ignore_sequence_gaps=TRUE
+
+# Title to use when running as a console
+wrapper.console.title=ElasticSearch
+
+#********************************************************************
+# Wrapper Windows NT/2000/XP Service Properties
+#********************************************************************
+# WARNING - Do not modify any of these properties when an application
+# using this configuration file has been installed as a service.
+# Please uninstall the service before modifying this section. The
+# service can then be reinstalled.
+
+# Name of the service
+wrapper.name=ElasticSearch
+
+# Display name of the service
+wrapper.displayname=ElasticSearch
+
+# Description of the service
+wrapper.description=Open Source, Distributed, RESTful Search Engine
+
+# Service dependencies. Add dependencies as needed starting from 1
+wrapper.ntservice.dependency.1=
+
+# Mode in which the service is installed. AUTO_START, DELAY_START or DEMAND_START
+wrapper.ntservice.starttype=AUTO_START
+
+# Allow the service to interact with the desktop.
+wrapper.ntservice.interactive=false
+
diff --git a/bin/service/elasticsearch32 b/bin/service/elasticsearch32
new file mode 100644
index 00000000000..1d40af87781
--- /dev/null
+++ b/bin/service/elasticsearch32
@@ -0,0 +1,4 @@
+#! /bin/sh
+
+export DIST_BITS="32"
+`dirname $0`/elasticsearch $1
diff --git a/bin/service/elasticsearch64 b/bin/service/elasticsearch64
new file mode 100644
index 00000000000..838eb8499c3
--- /dev/null
+++ b/bin/service/elasticsearch64
@@ -0,0 +1,4 @@
+#! /bin/sh
+
+export DIST_BITS="64"
+`dirname $0`/elasticsearch $1
diff --git a/bin/service/exec/elasticsearch-freebsd-x86-32 b/bin/service/exec/elasticsearch-freebsd-x86-32
new file mode 100755
index 00000000000..a47338b1673
Binary files /dev/null and b/bin/service/exec/elasticsearch-freebsd-x86-32 differ
diff --git a/bin/service/exec/elasticsearch-freebsd-x86-64 b/bin/service/exec/elasticsearch-freebsd-x86-64
new file mode 100755
index 00000000000..fc0e1abd0fa
Binary files /dev/null and b/bin/service/exec/elasticsearch-freebsd-x86-64 differ
diff --git a/bin/service/exec/elasticsearch-linux-ia-64 b/bin/service/exec/elasticsearch-linux-ia-64
new file mode 100755
index 00000000000..a57d2030730
Binary files /dev/null and b/bin/service/exec/elasticsearch-linux-ia-64 differ
diff --git a/bin/service/exec/elasticsearch-linux-ppc-32 b/bin/service/exec/elasticsearch-linux-ppc-32
new file mode 100755
index 00000000000..81e725a2347
Binary files /dev/null and b/bin/service/exec/elasticsearch-linux-ppc-32 differ
diff --git a/bin/service/exec/elasticsearch-linux-ppc-64 b/bin/service/exec/elasticsearch-linux-ppc-64
new file mode 100755
index 00000000000..b3e4479d388
Binary files /dev/null and b/bin/service/exec/elasticsearch-linux-ppc-64 differ
diff --git a/bin/service/exec/elasticsearch-linux-x86-32 b/bin/service/exec/elasticsearch-linux-x86-32
new file mode 100755
index 00000000000..bc23a7433be
Binary files /dev/null and b/bin/service/exec/elasticsearch-linux-x86-32 differ
diff --git a/bin/service/exec/elasticsearch-linux-x86-64 b/bin/service/exec/elasticsearch-linux-x86-64
new file mode 100755
index 00000000000..2c0c546cf69
Binary files /dev/null and b/bin/service/exec/elasticsearch-linux-x86-64 differ
diff --git a/bin/service/exec/elasticsearch-macosx-universal-32 b/bin/service/exec/elasticsearch-macosx-universal-32
new file mode 100755
index 00000000000..e270f266f99
Binary files /dev/null and b/bin/service/exec/elasticsearch-macosx-universal-32 differ
diff --git a/bin/service/exec/elasticsearch-macosx-universal-64 b/bin/service/exec/elasticsearch-macosx-universal-64
new file mode 100755
index 00000000000..a87b1a267f2
Binary files /dev/null and b/bin/service/exec/elasticsearch-macosx-universal-64 differ
diff --git a/bin/service/exec/elasticsearch-solaris-sparc-32 b/bin/service/exec/elasticsearch-solaris-sparc-32
new file mode 100755
index 00000000000..cefc08dcabd
Binary files /dev/null and b/bin/service/exec/elasticsearch-solaris-sparc-32 differ
diff --git a/bin/service/exec/elasticsearch-solaris-sparc-64 b/bin/service/exec/elasticsearch-solaris-sparc-64
new file mode 100755
index 00000000000..a461c708c4d
Binary files /dev/null and b/bin/service/exec/elasticsearch-solaris-sparc-64 differ
diff --git a/bin/service/exec/elasticsearch-solaris-x86-32 b/bin/service/exec/elasticsearch-solaris-x86-32
new file mode 100755
index 00000000000..1ddfbe5878a
Binary files /dev/null and b/bin/service/exec/elasticsearch-solaris-x86-32 differ
diff --git a/bin/service/exec/elasticsearch-solaris-x86-64 b/bin/service/exec/elasticsearch-solaris-x86-64
new file mode 100755
index 00000000000..bc8c7673d7d
Binary files /dev/null and b/bin/service/exec/elasticsearch-solaris-x86-64 differ
diff --git a/bin/service/exec/elasticsearch-windows-x86-32.exe b/bin/service/exec/elasticsearch-windows-x86-32.exe
new file mode 100755
index 00000000000..60d450d78df
Binary files /dev/null and b/bin/service/exec/elasticsearch-windows-x86-32.exe differ
diff --git a/bin/service/lib/libwrapper-freebsd-x86-32.so b/bin/service/lib/libwrapper-freebsd-x86-32.so
new file mode 100644
index 00000000000..76477b4fc62
Binary files /dev/null and b/bin/service/lib/libwrapper-freebsd-x86-32.so differ
diff --git a/bin/service/lib/libwrapper-freebsd-x86-64.so b/bin/service/lib/libwrapper-freebsd-x86-64.so
new file mode 100644
index 00000000000..19019933548
Binary files /dev/null and b/bin/service/lib/libwrapper-freebsd-x86-64.so differ
diff --git a/bin/service/lib/libwrapper-linux-ia-64.so b/bin/service/lib/libwrapper-linux-ia-64.so
new file mode 100644
index 00000000000..a1617617807
Binary files /dev/null and b/bin/service/lib/libwrapper-linux-ia-64.so differ
diff --git a/bin/service/lib/libwrapper-linux-ppc-32.so b/bin/service/lib/libwrapper-linux-ppc-32.so
new file mode 100644
index 00000000000..6e7d35ba045
Binary files /dev/null and b/bin/service/lib/libwrapper-linux-ppc-32.so differ
diff --git a/bin/service/lib/libwrapper-linux-ppc-64.so b/bin/service/lib/libwrapper-linux-ppc-64.so
new file mode 100644
index 00000000000..e7a32be57be
Binary files /dev/null and b/bin/service/lib/libwrapper-linux-ppc-64.so differ
diff --git a/bin/service/lib/libwrapper-linux-x86-32.so b/bin/service/lib/libwrapper-linux-x86-32.so
new file mode 100644
index 00000000000..481d24cda91
Binary files /dev/null and b/bin/service/lib/libwrapper-linux-x86-32.so differ
diff --git a/bin/service/lib/libwrapper-linux-x86-64.so b/bin/service/lib/libwrapper-linux-x86-64.so
new file mode 100644
index 00000000000..8afbf7394dd
Binary files /dev/null and b/bin/service/lib/libwrapper-linux-x86-64.so differ
diff --git a/bin/service/lib/libwrapper-macosx-universal-32.jnilib b/bin/service/lib/libwrapper-macosx-universal-32.jnilib
new file mode 100644
index 00000000000..d1f77849283
Binary files /dev/null and b/bin/service/lib/libwrapper-macosx-universal-32.jnilib differ
diff --git a/bin/service/lib/libwrapper-macosx-universal-64.jnilib b/bin/service/lib/libwrapper-macosx-universal-64.jnilib
new file mode 100644
index 00000000000..2422f362d42
Binary files /dev/null and b/bin/service/lib/libwrapper-macosx-universal-64.jnilib differ
diff --git a/bin/service/lib/libwrapper-solaris-sparc-32.so b/bin/service/lib/libwrapper-solaris-sparc-32.so
new file mode 100644
index 00000000000..3eacbc814ed
Binary files /dev/null and b/bin/service/lib/libwrapper-solaris-sparc-32.so differ
diff --git a/bin/service/lib/libwrapper-solaris-sparc-64.so b/bin/service/lib/libwrapper-solaris-sparc-64.so
new file mode 100644
index 00000000000..4e8d7d94e4b
Binary files /dev/null and b/bin/service/lib/libwrapper-solaris-sparc-64.so differ
diff --git a/bin/service/lib/libwrapper-solaris-x86-32.so b/bin/service/lib/libwrapper-solaris-x86-32.so
new file mode 100644
index 00000000000..eb583d3e32f
Binary files /dev/null and b/bin/service/lib/libwrapper-solaris-x86-32.so differ
diff --git a/bin/service/lib/libwrapper-solaris-x86-64.so b/bin/service/lib/libwrapper-solaris-x86-64.so
new file mode 100644
index 00000000000..d3c9eea8240
Binary files /dev/null and b/bin/service/lib/libwrapper-solaris-x86-64.so differ
diff --git a/bin/service/lib/wrapper-windows-x86-32.dll b/bin/service/lib/wrapper-windows-x86-32.dll
new file mode 100644
index 00000000000..8d0e0b3ac90
Binary files /dev/null and b/bin/service/lib/wrapper-windows-x86-32.dll differ
diff --git a/bin/service/lib/wrapper.jar b/bin/service/lib/wrapper.jar
new file mode 100644
index 00000000000..724a8f8087b
Binary files /dev/null and b/bin/service/lib/wrapper.jar differ
diff --git a/build.gradle b/build.gradle
index 271436f314b..16a84c0b76c 100644
--- a/build.gradle
+++ b/build.gradle
@@ -87,10 +87,18 @@ task zip(type: Zip, dependsOn: ['explodedDist']) {
from(explodedDistDir) {
into zipRootFolder
exclude 'bin/elasticsearch'
+ exclude 'bin/service/elasticsearch'
+ exclude 'bin/service/elasticsearch32'
+ exclude 'bin/service/elasticsearch64'
+ exclude 'bin/service/exec/**'
}
from(explodedDistDir) {
into zipRootFolder
include 'bin/elasticsearch'
+ include 'bin/service/elasticsearch'
+ include 'bin/service/elasticsearch32'
+ include 'bin/service/elasticsearch64'
+ include 'bin/service/exec/**'
fileMode = 0755
}
}
diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/cluster/node/shutdown/TransportNodesShutdown.java b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/cluster/node/shutdown/TransportNodesShutdown.java
index fca906a90a6..a11c1f3d88d 100644
--- a/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/cluster/node/shutdown/TransportNodesShutdown.java
+++ b/modules/elasticsearch/src/main/java/org/elasticsearch/action/admin/cluster/node/shutdown/TransportNodesShutdown.java
@@ -102,7 +102,21 @@ public class TransportNodesShutdown extends TransportNodesOperationAction tuple = null;
try {