blob: 0853a96011b2de5b768dedb9b0f586163ceb43ec [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
Masayoshi Kobayashi99730902013-06-27 23:23:20 -07006#ZK_CONF=${ONOS_HOME}/conf/zoo.cfg
Masaoyshi Kobayashie0698b22013-06-21 01:37:09 -07007
8function start {
9 # Run Zookeeper with our configuration
10 echo "Starting Zookeeper"
Masayoshi Kobayashi99730902013-06-27 23:23:20 -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"
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 Kobayashicf909f92013-06-21 13:28:22 -070019 $ZK_DIR/bin/zkServer.sh start
Masaoyshi Kobayashie0698b22013-06-21 01:37:09 -070020}
21
22function 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}
32function status {
Masayoshi Kobayashi99730902013-06-27 23:23:20 -070033 $ZK_DIR/bin/zkServer.sh status
Masaoyshi Kobayashie0698b22013-06-21 01:37:09 -070034}
35
36case "$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
53esac