Skip to content

Instantly share code, notes, and snippets.

@iocanel
Created October 27, 2014 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iocanel/05ab0549b50f612058ed to your computer and use it in GitHub Desktop.
Save iocanel/05ab0549b50f612058ed to your computer and use it in GitHub Desktop.
A bash script to create ensemble config out of environment variables
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