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