-
Notifications
You must be signed in to change notification settings - Fork 1
/
dynamic_config.sh
18 lines (17 loc) · 1003 Bytes
/
dynamic_config.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/bash
ZOO_DIR="/opt/zookeeper"
ZOO_CFG="${ZOO_DIR}/conf/zoo.cfg"
if [ -n "$ZK_URL" ]; then
echo "`${ZOO_DIR}/bin/zkCli.sh -server $ZK_URL get /zookeeper/config|grep ^server`" >> ${ZOO_CFG}.dynamic
echo "server.$MYID=$MYSERVER_URL:observer;$MYCLIENT_PORT" >> ${ZOO_CFG}.dynamic
cp ${ZOO_CFG}.dynamic ${ZOO_CFG}.dynamic.org
echo "${MYID}" > /tmp/zookeeper/myid
ZOO_LOG_DIR=/var/log ZOO_LOG4J_PROP='INFO,CONSOLE,ROLLINGFILE' ${ZOO_DIR}/bin/zkServer.sh start
${ZOO_DIR}/bin/zkCli.sh -server $ZK_URL reconfig -add "server.$MYID=$MYSERVER_URL:participant;$MYCLIENT_PORT"
${ZOO_DIR}/bin/zkServer.sh stop
ZOO_LOG_DIR=/var/log ZOO_LOG4J_PROP='INFO,CONSOLE,ROLLINGFILE' ${ZOO_DIR}/bin/zkServer.sh start-foreground
else
echo "server.$MYID=$MYSERVER_URL:participant;$MYCLIENT_PORT" >> ${ZOO_CFG}.dynamic
echo "${MYID}" > /tmp/zookeeper/myid
ZOO_LOG_DIR=/var/log ZOO_LOG4J_PROP='INFO,CONSOLE,ROLLINGFILE' ${ZOO_DIR}/bin/zkServer.sh start-foreground
fi