#!/bin/bash

file=config/server.properties

while read line; do
	if [ -z "$line" ] || [ ${line::1} == "#" ]; then
		continue
	fi
	set -- $(echo $line | tr '=' ' ')
	key=$1
	if [ "$key"=="broker.id" ]; then
		value=$2
		if [ "$value" != "0" ]; then
			echo "$value" > /tmp/zookeeper/myid
		fi
		break
	fi
done < $file
	
bin/zookeeper-server-start.sh -daemon config/zookeeper.properties

while [ "$(echo ruok | nc localhost 2181)" != "imok" ]; do
	sleep 1
done

export JMX_PORT=9999

bin/kafka-server-start.sh config/server.properties

