Skip to content

Instantly share code, notes, and snippets.

@BugRoger
Created February 27, 2015 07:54
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 BugRoger/af71c9531e17bbc7f147 to your computer and use it in GitHub Desktop.
Save BugRoger/af71c9531e17bbc7f147 to your computer and use it in GitHub Desktop.
Ceph Mon Orchestration
#!/bin/bash
if [ ! -n "$MON_NAME" ]; then
echo "ERROR- MON_NAME must be defined as the name of the monitor"
exit 1
fi
if [ ! -n "$MON_IP" ]; then
echo "ERROR- MON_IP must be defined as the IP address of the monitor"
exit 1
fi
CLUSTER=${CLUSTER:-ceph}
CLUSTER_PATH=/ceph/$CLUSTER
if ! etcdctl get ${CLUSTER_PATH}/completed > /dev/null 2>%1 ; then
if etcdctl get ${CLUSTER_PATH}/monitor-lock > /dev/null 2>&1 ; then
while monitor=$(etcdctl get ${CLUSTER_PATH}/monitor-lock 2> /dev/null) ; do
echo "waiting for monitor ${monitor} to finish initialization"
sleep 1
done
else
echo "aquiring lock for ${MON_NAME}"
etcdctl mk ${CLUSTER_PATH}/monitor-lock ${MON_NAME} --ttl 15 > /dev/null 2>&1
sleep 10
echo "completed initialization for ${MON_NAME}"
etcdctl set ${CLUSTER_PATH}/completed true --ttl 10 > /dev/null 2>&1
etcdctl rm ${CLUSTER_PATH}/monitor-lock > /dev/null 2>&1
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment