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 |
Masayoshi Kobayashi | 9973090 | 2013-06-27 23:23:20 -0700 | [diff] [blame] | 6 | #ZK_CONF=${ONOS_HOME}/conf/zoo.cfg |
Yuta HIGUCHI | a7ec073 | 2014-03-10 16:01:06 -0700 | [diff] [blame] | 7 | ZOO_LOG_DIR=${ONOS_HOME}/onos-logs |
Masaoyshi Kobayashi | e0698b2 | 2013-06-21 01:37:09 -0700 | [diff] [blame] | 8 | |
| 9 | function start { |
| 10 | # Run Zookeeper with our configuration |
| 11 | echo "Starting Zookeeper" |
Masayoshi Kobayashi | 9973090 | 2013-06-27 23:23:20 -0700 | [diff] [blame] | 12 | # echo "[31;48m[WARNING] This script copies conf/zoo.cfg to $ZK_DIR/conf/zoo.cfg (overwrites)[0m" |
| 13 | # echo "[31;48moriginal zoo.cfg was backed up as zoo.cfg.backup[0m" |
| 14 | # if [ $ZK_DIR/conf/zoo.cfg ]; then |
| 15 | # cp $ZK_DIR/conf/zoo.cfg $ZK_DIR/conf/zoo.cfg.backup |
| 16 | # fi |
| 17 | # hostid > /var/lib/zookeeper/myid |
| 18 | # cp $ZK_CONF $ZK_DIR/conf |
| 19 | # echo "cp $ZK_CONF $ZK_DIR/conf" |
Masayoshi Kobayashi | cf909f9 | 2013-06-21 13:28:22 -0700 | [diff] [blame] | 20 | $ZK_DIR/bin/zkServer.sh start |
Masaoyshi Kobayashi | e0698b2 | 2013-06-21 01:37:09 -0700 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | function stop { |
| 24 | # Kill the existing processes |
| 25 | pids=`jps -l | grep org.apache.zookeeper.server | awk '{print $1}'` |
| 26 | for p in ${pids}; do |
| 27 | if [ x$p != "x" ]; then |
| 28 | kill -KILL $p |
| 29 | echo "Killed existing prosess (pid: $p)" |
| 30 | fi |
| 31 | done |
| 32 | } |
| 33 | function status { |
Masayoshi Kobayashi | 9973090 | 2013-06-27 23:23:20 -0700 | [diff] [blame] | 34 | $ZK_DIR/bin/zkServer.sh status |
Masaoyshi Kobayashi | e0698b2 | 2013-06-21 01:37:09 -0700 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | case "$1" in |
| 38 | start) |
| 39 | start |
| 40 | ;; |
| 41 | stop) |
| 42 | stop |
| 43 | ;; |
| 44 | status) |
| 45 | status |
| 46 | ;; |
| 47 | restart) |
| 48 | stop |
| 49 | start |
| 50 | ;; |
| 51 | *) |
| 52 | echo "Usage: $0 {start|stop|restart|status}" |
| 53 | exit 1 |
| 54 | esac |