Created
October 27, 2014 14:47
-
-
Save iocanel/05ab0549b50f612058ed to your computer and use it in GitHub Desktop.
A bash script to create ensemble config out of environment variables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ ! -z "$SERVER_ID" ]; then | |
echo "$SERVER_ID" > /opt/zookeeper/data/myid | |
#Find the servers exposed in env. | |
for i in `echo {1..15}`;do | |
HOST=`envValue ZK_PEER_${i}_SERVICE_HOST` | |
PEER=`envValue ZK_PEER_${i}_SERVICE_PORT` | |
ELECTION=`envValue ZK_ELECTION_${i}_SERVICE_PORT` | |
if [ "$SERVER_ID" = "$i" ];then | |
echo "server.$i=0.0.0.0:2888:3888" >> conf/zoo.cfg | |
elif [ -z "$HOST" ] || [ -z "$PEER" ] || [ -z "$ELECTION" ] ; then | |
#if a server is not fully defined stop the loop here. | |
break | |
else | |
echo "server.$i=$HOST:$PEER:$ELECTION" >> conf/zoo.cfg | |
fi | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment