Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 41 additions & 20 deletions distribution/rpm/src/main/packaging/init.d/elasticsearch
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand All @@ -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() {
Expand Down