github.com/inflatablewoman/deis@v1.0.1-0.20141111034523-a4511c46a6ce/store/daemon/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 7 HOSTNAME=`hostname` 8 OSD_ID='' 9 10 until etcdctl --no-sync -C $ETCD get /deis/store/monSetupComplete >/dev/null 2>&1 ; do 11 echo "store-daemon: waiting for monitor setup to complete..." 12 sleep 5 13 done 14 15 until confd -onetime -node $ETCD -config-file /app/confd.toml >/dev/null 2>&1 ; do 16 echo "store-daemon: waiting for confd to write initial templates..." 17 sleep 5 18 done 19 20 if ! etcdctl --no-sync -C $ETCD get /deis/store/osds/$HOST >/dev/null 2>&1 ; then 21 echo "store-daemon: creating OSD..." 22 23 OSD_ID=`ceph osd create 2>/dev/null` 24 25 if ! [[ "${OSD_ID}" =~ ^-?[0-9]+$ ]] ; then 26 echo "store-daemon: FATAL - We have an OSD ID that isn't an integer" 27 echo "store-daemon: FATAL - This likely means the monitor we tried to connect to isn't up, but others may be." 28 echo "store-daemon: FATAL - We can't proceed because we don't know if an OSD was created or not." 29 exit 1 30 fi 31 32 echo "store-daemon: created OSD ${OSD_ID}" 33 etcdctl --no-sync -C $ETCD set /deis/store/osds/$HOST ${OSD_ID} >/dev/null 34 fi 35 36 if [ -z "${OSD_ID}" ]; then 37 OSD_ID=`etcdctl --no-sync -C $ETCD get /deis/store/osds/${HOST}` 38 fi 39 40 # Make sure osd directory exists 41 mkdir -p /var/lib/ceph/osd/ceph-${OSD_ID} 42 43 # Check to see if our OSD has been initialized 44 if [ ! -e /var/lib/ceph/osd/ceph-${OSD_ID}/keyring ]; then 45 echo "store-daemon: OSD not yet initialized. Initializing..." 46 ceph-osd -i $OSD_ID --mkfs --mkjournal --osd-journal /var/lib/ceph/osd/ceph-${OSD_ID}/journal 47 ceph auth get-or-create osd.${OSD_ID} osd 'allow *' mon 'allow profile osd' -o /var/lib/ceph/osd/ceph-${OSD_ID}/keyring 48 ceph osd crush add ${OSD_ID} 1.0 root=default host=${HOSTNAME} 49 fi 50 51 echo "store-daemon: starting daemon on ${HOSTNAME}..." 52 53 if [ $1 == 'ceph-osd' ]; then 54 exec ceph-osd -d -i ${OSD_ID} -k /var/lib/ceph/osd/ceph-${OSD_ID}/keyring 55 else 56 exec $@ 57 fi