ELK的启动和停止脚本

#!/bin/sh

path_base=`pwd`
path_elastic="$path_base/elasticsearch-5.5.1/bin/elasticsearch"
path_kibana="$path_base/kibana-5.5.1/bin/kibana"
path_logstash="$path_base/logstash-5.5.1/bin/logstash"

mode=$1

kibana_process=`ps -ef | grep "kibana"| grep -v grep`
elastic_process=`ps -ef | grep "elasticsearch"| grep -v grep|grep -v controller`

case "$mode" in
   'start')
	echo "it's ready to start op...."
	if test -n "$elastic_process"; then
		echo "---the elasticsearch had already started.."
	else
		`$path_elastic -d`
	fi

	if test -n "$kibana_process"; then
		echo "---the kibana had already started.."
	else
		`nohup $path_kibana > /dev/null 2>&1 &`
	fi
	echo 'success to start.'
	echo '---1--you can test logstash by way bellow----'
	echo 'cd logstash-5.5.1 && bin/logstash -f ./config/test.conf && cd ..'
	echo 'or cd logstash-5.5.1 && bin/logstash -f ./config/h5.api.vip.com.conf && cd ..'
	;;
   'stop')
	echo "it's ready to check process..."
	if test -n "$kibana_process"; then
		echo "had find kibana process.."
		`echo $kibana_process | awk '{print ($2)}' | xargs kill -9`
	fi
	if test -n "$elastic_process"; then
		echo "had find elasticsearch process.."
		`echo $elastic_process | awk '{print ($2)}' | xargs kill -9`
	fi
	echo 'success to kill.'
	;;
    *)
	basename=`basename "$0"`
	echo "Usage: $basename  {start|stop}  [ ELK server options ]"
	exit 1
	;;
esac
exit 1