This repository has been archived by the owner on Nov 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 799
/
boot
executable file
·57 lines (44 loc) · 1.93 KB
/
boot
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env bash
# Borrows heavily from Seán C. McCord's https://github.com/Ulexus/docker-ceph repository
ETCD_PORT=${ETCD_PORT:-4001}
ETCD="$HOST:$ETCD_PORT"
HOSTNAME=`hostname`
OSD_ID=''
until etcdctl --no-sync -C $ETCD get /deis/store/monSetupComplete >/dev/null 2>&1 ; do
echo "store-daemon: waiting for monitor setup to complete..."
sleep 5
done
until confd -onetime -node $ETCD --confdir /app --log-level error; do
echo "store-daemon: waiting for confd to write initial templates..."
sleep 5
done
if ! etcdctl --no-sync -C $ETCD get /deis/store/osds/$HOST >/dev/null 2>&1 ; then
echo "store-daemon: creating OSD..."
OSD_ID=`ceph osd create 2>/dev/null`
if ! [[ "${OSD_ID}" =~ ^-?[0-9]+$ ]] ; then
echo "store-daemon: FATAL - We have an OSD ID that isn't an integer"
echo "store-daemon: FATAL - This likely means the monitor we tried to connect to isn't up, but others may be."
echo "store-daemon: FATAL - We can't proceed because we don't know if an OSD was created or not."
exit 1
fi
echo "store-daemon: created OSD ${OSD_ID}"
etcdctl --no-sync -C $ETCD set /deis/store/osds/$HOST ${OSD_ID} >/dev/null
fi
if [ -z "${OSD_ID}" ]; then
OSD_ID=`etcdctl --no-sync -C $ETCD get /deis/store/osds/${HOST}`
fi
# Make sure osd directory exists
mkdir -p /var/lib/ceph/osd/ceph-${OSD_ID}
# Check to see if our OSD has been initialized
if [ ! -e /var/lib/ceph/osd/ceph-${OSD_ID}/keyring ]; then
echo "store-daemon: OSD not yet initialized. Initializing..."
ceph-osd -i $OSD_ID --mkfs --mkjournal --osd-journal /var/lib/ceph/osd/ceph-${OSD_ID}/journal
ceph auth get-or-create osd.${OSD_ID} osd 'allow *' mon 'allow profile osd' -o /var/lib/ceph/osd/ceph-${OSD_ID}/keyring
ceph osd crush add ${OSD_ID} 1.0 root=default host=${HOSTNAME}
fi
echo "store-daemon: starting daemon on ${HOSTNAME}..."
if [ $1 == 'ceph-osd' ]; then
exec ceph-osd -d -i ${OSD_ID} -k /var/lib/ceph/osd/ceph-${OSD_ID}/keyring
else
exec $@
fi