blob: 30de5fbbfe74e593f96c95d16ea75b2231e70792 [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
Yuta HIGUCHIa7ec0732014-03-10 16:01:06 -07007ZOO_LOG_DIR=${ONOS_HOME}/onos-logs
Masaoyshi Kobayashie0698b22013-06-21 01:37:09 -07008
9function start {
10 # Run Zookeeper with our configuration
11 echo "Starting Zookeeper"
Masayoshi Kobayashi99730902013-06-27 23:23:20 -070012# echo "[WARNING] This script copies conf/zoo.cfg to $ZK_DIR/conf/zoo.cfg (overwrites)"
13# echo "original zoo.cfg was backed up as zoo.cfg.backup"
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 Kobayashicf909f92013-06-21 13:28:22 -070020 $ZK_DIR/bin/zkServer.sh start
Masaoyshi Kobayashie0698b22013-06-21 01:37:09 -070021}
22
23function 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}
33function status {
Masayoshi Kobayashi99730902013-06-27 23:23:20 -070034 $ZK_DIR/bin/zkServer.sh status
Masaoyshi Kobayashie0698b22013-06-21 01:37:09 -070035}
36
37case "$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
54esac