Created
April 3, 2014 11:28
-
-
Save uolter/9952706 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Elastic Serarch Start and Stop Script | |
ES_HOME="/opt/elsearch/elasticsearch" | |
ES_USER="esearch" | |
PID=$(ps ax | grep elasticsearch | grep $ES_HOME | grep -v grep | awk '{print $1}') | |
#echo $PID | |
#exit 0 | |
case "$1" in | |
start) | |
if [ -z "$PID" ]; then | |
echo "Starting Elasticsearch" | |
echo "Starting Elasticsearch" >> /var/tmp/elasticsearch | |
su -m $ES_USER -c "${ES_HOME}/bin/elasticsearch" | |
exit 0; | |
else | |
echo "Elasticsearch already running" | |
echo "Elasticsearch already running" >> /var/tmp/elasticsearch | |
exit 0; | |
fi | |
;; | |
stop) | |
if [ -n "$PID" ]; then | |
echo "Stopping Elasticsearch" | |
kill -15 ${PID} | |
echo "Stopped Elasticsearch" | |
exit 0; | |
else | |
echo "Elasticsearch is not running" | |
exit 0; | |
fi | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment