#! /bin/sh ### BEGIN INIT INFO # Provides: elasticsearch # Required-Start: $remote_fs $network # Required-Stop: $remote_fs $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start elasticsearch ### END INIT INFO set -e PIDFILE='<%= node.elasticsearch[:pid_file] %>' ES_INCLUDE='<%= node.elasticsearch[:path][:conf] %>/elasticsearch-env.sh' APP=elasticsearch OPTS="-p $PIDFILE" BINARY=/usr/local/bin/elasticsearch . /lib/lsb/init-functions case "$1" in start) log_daemon_msg "Starting $APP" "$APP" if ES_INCLUDE=$ES_INCLUDE start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --user <%= node[:elasticsearch][:user] %> --exec $BINARY -- $OPTS; then log_end_msg 0 else log_end_msg 1 fi ;; stop) log_daemon_msg "Stopping $APP" "$APP" if start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE; then log_end_msg 0 else log_end_msg 1 fi ;; restart) log_daemon_msg "Restarting $APP" "$APP" start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile $PIDFILE if ES_INCLUDE=$ES_INCLUDE start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --user <%= node[:elasticsearch][:user] %> --exec $BINARY -- $OPTS; then log_end_msg 0 else log_end_msg 1 fi ;; status) status_of_proc -p $PIDFILE $BINARY $APP && exit 0 || exit $? ;; *) log_action_msg "Usage: $0 {start|stop|restart|status}" exit 1 esac exit $?