github.com/spg/deis@v1.7.3/store/metadata/bin/boot (about) 1 #!/bin/bash 2 # Borrows heavily from Seán C. McCord's https://github.com/Ulexus/docker-ceph repository 3 4 ETCD_PORT=${ETCD_PORT:-4001} 5 ETCD="$HOST:$ETCD_PORT" 6 ETCD_PATH=${ETCD_PATH:-/deis/store} 7 8 HOSTNAME=`hostname` 9 MDS_NAME=$HOSTNAME 10 11 until confd -onetime -node $ETCD --confdir /app --log-level error; do 12 echo "store-metadata: waiting for confd to write initial templates..." 13 sleep 5 14 done 15 16 if ! etcdctl --no-sync -C $ETCD get ${ETCD_PATH}/filesystemSetupComplete >/dev/null 2>&1 ; then 17 echo "store-metadata: The Ceph filesystem hasn't been created. Trying to obtain the lock to set up..." 18 # let's rock and roll. we need to obtain a lock so we can ensure only one machine is trying to deploy the cluster 19 if etcdctl --no-sync -C $ETCD mk ${ETCD_PATH}/filesystemSetupLock $HOSTNAME >/dev/null 2>&1 \ 20 || [[ `etcdctl --no-sync -C $ETCD get ${ETCD_PATH}/filesystemSetupLock` == "$HOSTNAME" ]] ; then 21 echo "store-metadata: obtained the lock to proceed with setting up." 22 23 PG_NUM=`etcdctl --no-sync -C $ETCD get /deis/store/pgNum` 24 25 # even though we know setup hasn't completed, we could be upgrading an older cluster which 26 # has the pools but not the filesystemSetupComplete key 27 if ! ceph osd lspools | grep " data," ; then 28 ceph osd pool create data ${PG_NUM} 29 fi 30 31 if ! ceph osd lspools | grep metadata ; then 32 ceph osd pool create metadata ${PG_NUM} 33 fi 34 35 if ceph fs ls | grep "No filesystems enabled" ; then 36 ceph fs new deis metadata data 37 fi 38 39 # mark setup as complete 40 echo "store-metadata: filesystem setup complete." 41 etcdctl --no-sync -C $ETCD set ${ETCD_PATH}/filesystemSetupComplete youBetcha >/dev/null 42 else 43 until etcdctl --no-sync -C $ETCD get ${ETCD_PATH}/filesystemSetupComplete >/dev/null 2>&1 ; do 44 echo "store-metadata: waiting for another metadata to complete setup..." 45 sleep 5 46 done 47 fi 48 fi 49 50 # Check to see if we are a new MDS 51 if [ ! -e /var/lib/ceph/mds/ceph-$MDS_NAME/keyring ]; then 52 mkdir -p /var/lib/ceph/mds/ceph-${MDS_NAME} 53 54 # See if we need to generate a key for the MDS 55 if [ -e /etc/ceph/ceph.mds.keyring ]; then 56 cp /etc/ceph/ceph.mds.keyring /var/lib/ceph/mds/ceph-${MDS_NAME}/keyring 57 else 58 # Generate the new MDS key 59 ceph auth get-or-create mds.$MDS_NAME mds 'allow' osd 'allow *' mon 'allow profile mds' > /var/lib/ceph/mds/ceph-${MDS_NAME}/keyring 60 fi 61 fi 62 63 echo "store-metadata: running..." 64 exec /usr/bin/ceph-mds -d -i ${MDS_NAME}