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