blob: 206370fb6a1ebbc545f608fb23ede663f532ea64 [file] [log] [blame]
Masaoyshi Kobayashie0698b22013-06-21 01:37:09 -07001#!/bin/bash
2# Set paths
3
4ONOS_HOME=`dirname $0`
5ZK_DIR=${HOME}/zookeeper-3.4.5
6ZK_CONF=${ONOS_HOME}/conf/zoo.cfg
7
8function start {
9 # Run Zookeeper with our configuration
10 echo "Starting Zookeeper"
Masayoshi Kobayashiabcc2372013-06-24 13:57:55 -070011 echo "[WARNING] This script copies conf/zoo.cfg to $ZK_DIR/conf/zoo.cfg (overwrites)"
12 echo "original zoo.cfg was backed up as zoo.cfg.backup"
Masayoshi Kobayashi60ff4502013-06-24 14:15:28 -070013 if [ $ZK_DIR/conf/zoo.cfg ]; then
14 cp $ZK_DIR/conf/zoo.cfg $ZK_DIR/conf/zoo.cfg.backup
15 fi
Masayoshi Kobayashif2b0b022013-06-21 14:22:24 -070016 cp $ZK_CONF $ZK_DIR/conf
17 echo "cp $ZK_CONF $ZK_DIR/conf"
Masayoshi Kobayashicf909f92013-06-21 13:28:22 -070018 $ZK_DIR/bin/zkServer.sh start
Masaoyshi Kobayashie0698b22013-06-21 01:37:09 -070019}
20
21function 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}
31function status {
32 $ZK_DIR/bin/zkServer.sh status $ZK_CONF
33}
34
35case "$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
52esac