diff --git a/distribution/rpm/src/main/packaging/init.d/elasticsearch b/distribution/rpm/src/main/packaging/init.d/elasticsearch index c68a5b65f3f49..51aed5f6326d8 100644 --- a/distribution/rpm/src/main/packaging/init.d/elasticsearch +++ b/distribution/rpm/src/main/packaging/init.d/elasticsearch @@ -16,19 +16,20 @@ # 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 + SUSE=1 . /etc/rc.status rc_reset -fi -# # Source function library. -# -if [ -f /etc/rc.d/init.d/functions ]; then +elif [ -f /etc/rc.d/init.d/functions ]; then . /etc/rc.d/init.d/functions + +# Unknown distribution or service manager found, exit +else + echo "Unknown distribution or service manager" + exit 1 fi # Sets the default values for elasticsearch variables used in this script @@ -68,8 +69,6 @@ export ES_STARTUP_SLEEP_TIME export JAVA_HOME export ES_INCLUDE -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 @@ -116,22 +115,38 @@ start() { cd $ES_HOME 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 -Ees.default.path.home=$ES_HOME -Ees.default.path.logs=$LOG_DIR -Ees.default.path.data=$DATA_DIR -Ees.default.path.conf=$CONF_DIR - retval=$? - echo - [ $retval -eq 0 ] && touch $lockfile - return $retval + # if not running, start it up here. + + retval='' + if [ $SUSE ]; then + # SLES uses startproc + startproc -u $ES_USER $exec -p $pidfile -d -Ees.default.path.home=$ES_HOME -Ees.default.path.logs=$LOG_DIR -Ees.default.path.data=$DATA_DIR -Ees.default.path.conf=$CONF_DIR & + retval=$? + rc_status -v + else + # For non-SLES usually something like "daemon $exec" + daemon --user $ES_USER --pidfile $pidfile $exec -p $pidfile -d -Ees.default.path.home=$ES_HOME -Ees.default.path.logs=$LOG_DIR -Ees.default.path.data=$DATA_DIR -Ees.default.path.conf=$CONF_DIR + retval=$? + fi + } stop() { echo -n $"Stopping $prog: " # stop it here, often "killproc $prog" - killproc -p $pidfile -d ${stopping.timeout} $prog - retval=$? - echo - [ $retval -eq 0 ] && rm -f $lockfile - return $retval + + if [ $SUSE ]; then + checkJava + #SLES uses a differnt version of killproc + killproc -p $pidfile -HUP $JAVA + rc_status -v + else + # stop it here, often "killproc $prog" + killproc -p $pidfile -d ${stopping.timeout} $prog + retval=$? + echo + return $retval + fi } restart() { @@ -149,7 +164,13 @@ force_reload() { rh_status() { # run checks to determine if the service is running or use generic status - status -p $pidfile $prog + if [ $SUSE ]; then + checkJava + checkproc -p $pidfile $JAVA + rc_status -v + else + status -p $pidfile $prog + fi } rh_status_q() {