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 | f2b0b02 | 2013-06-21 14:22:24 -0700 | [diff] [blame] | 11 | cp $ZK_CONF $ZK_DIR/conf |
| 12 | echo "cp $ZK_CONF $ZK_DIR/conf" |
Masayoshi Kobayashi | cf909f9 | 2013-06-21 13:28:22 -0700 | [diff] [blame] | 13 | $ZK_DIR/bin/zkServer.sh start |
Masaoyshi Kobayashi | e0698b2 | 2013-06-21 01:37:09 -0700 | [diff] [blame] | 14 | } |
| 15 | |
| 16 | function stop { |
| 17 | # Kill the existing processes |
| 18 | pids=`jps -l | grep org.apache.zookeeper.server | awk '{print $1}'` |
| 19 | for p in ${pids}; do |
| 20 | if [ x$p != "x" ]; then |
| 21 | kill -KILL $p |
| 22 | echo "Killed existing prosess (pid: $p)" |
| 23 | fi |
| 24 | done |
| 25 | } |
| 26 | function status { |
| 27 | $ZK_DIR/bin/zkServer.sh status $ZK_CONF |
| 28 | } |
| 29 | |
| 30 | case "$1" in |
| 31 | start) |
| 32 | start |
| 33 | ;; |
| 34 | stop) |
| 35 | stop |
| 36 | ;; |
| 37 | status) |
| 38 | status |
| 39 | ;; |
| 40 | restart) |
| 41 | stop |
| 42 | start |
| 43 | ;; |
| 44 | *) |
| 45 | echo "Usage: $0 {start|stop|restart|status}" |
| 46 | exit 1 |
| 47 | esac |