Masaoyshi Kobayashi | e0698b2 | 2013-06-21 01:37:09 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Set paths |
| 3 | |
| 4 | ONOS_HOME=`dirname $0` |
| 5 | ZK_DIR=${HOME}/zookeeper-3.4.5 |
| 6 | ZK_CONF=${ONOS_HOME}/conf/zoo.cfg |
| 7 | |
| 8 | function start { |
| 9 | # Run Zookeeper with our configuration |
| 10 | echo "Starting Zookeeper" |
Masayoshi Kobayashi | cf909f9 | 2013-06-21 13:28:22 -0700 | [diff] [blame] | 11 | cp $ZK_CONF $ZKDIR/conf |
| 12 | $ZK_DIR/bin/zkServer.sh start |
Masaoyshi Kobayashi | e0698b2 | 2013-06-21 01:37:09 -0700 | [diff] [blame] | 13 | } |
| 14 | |
| 15 | function stop { |
| 16 | # Kill the existing processes |
| 17 | pids=`jps -l | grep org.apache.zookeeper.server | awk '{print $1}'` |
| 18 | for p in ${pids}; do |
| 19 | if [ x$p != "x" ]; then |
| 20 | kill -KILL $p |
| 21 | echo "Killed existing prosess (pid: $p)" |
| 22 | fi |
| 23 | done |
| 24 | } |
| 25 | function status { |
| 26 | $ZK_DIR/bin/zkServer.sh status $ZK_CONF |
| 27 | } |
| 28 | |
| 29 | case "$1" in |
| 30 | start) |
| 31 | start |
| 32 | ;; |
| 33 | stop) |
| 34 | stop |
| 35 | ;; |
| 36 | status) |
| 37 | status |
| 38 | ;; |
| 39 | restart) |
| 40 | stop |
| 41 | start |
| 42 | ;; |
| 43 | *) |
| 44 | echo "Usage: $0 {start|stop|restart|status}" |
| 45 | exit 1 |
| 46 | esac |