]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-osd-prestart.sh: ensure data dir is root or ceph before start
authorSage Weil <sage@redhat.com>
Fri, 24 Apr 2015 00:14:27 +0000 (17:14 -0700)
committerSage Weil <sage@redhat.com>
Thu, 27 Aug 2015 00:34:15 +0000 (20:34 -0400)
Signed-off-by: Sage Weil <sage@redhat.com>
src/ceph-osd-prestart.sh

index 79f2c132d9fc9da0287ede429f7ef6f386c6769b..a76747b232d5b4d8b99d7a22c37318f7a4b2c21c 100644 (file)
@@ -17,6 +17,9 @@ if [ -z "$id"  ]; then
     exit 1;
 fi
 
+data="/var/lib/ceph/osd/${cluster:-ceph}-$id"
+journal="$data/journal"
+
 update="$(ceph-conf --cluster=${cluster:-ceph} --name=osd.$id --lookup osd_crush_update_on_start || :)"
 
 if [ "${update:-1}" = "1" -o "${update:-1}" = "true" ]; then
@@ -27,11 +30,11 @@ if [ "${update:-1}" = "1" -o "${update:-1}" = "true" ]; then
     fi
     location="$($hook --cluster ${cluster:-ceph} --id $id --type osd)"
     weight="$(ceph-conf --cluster=${cluster:-ceph} --name=osd.$id --lookup osd_crush_initial_weight || :)"
-    defaultweight=`df -P -k /var/lib/ceph/osd/${cluster:-ceph}-$id/ | tail -1 | awk '{ d= $2/1073741824 ; r = sprintf("%.4f", d); print r }'`
+    defaultweight=`df -P -k $data/ | tail -1 | awk '{ d= $2/1073741824 ; r = sprintf("%.4f", d); print r }'`
     ceph \
         --cluster="${cluster:-ceph}" \
         --name="osd.$id" \
-        --keyring="/var/lib/ceph/osd/${cluster:-ceph}-$id/keyring" \
+        --keyring="$data/keyring" \
         osd crush create-or-move \
         -- \
         "$id" \
@@ -39,7 +42,6 @@ if [ "${update:-1}" = "1" -o "${update:-1}" = "true" ]; then
         $location
 fi
 
-journal="/var/lib/ceph/osd/${cluster:-ceph}-$id/journal"
 if [ -L "$journal" -a ! -e "$journal" ]; then
     udevadm settle --timeout=5 || :
     if [ -L "$journal" -a ! -e "$journal" ]; then
@@ -48,3 +50,14 @@ if [ -L "$journal" -a ! -e "$journal" ]; then
         exit 0
     fi
 fi
+
+
+# ensure ownership is correct
+owner=`stat -c %U $data/.`
+if [ $owner -ne 'ceph' -a $owner -ne 'root' ]; then
+    echo "ceph-osd data dir $data is not owned by 'ceph' or 'root'"
+    echo "you must 'ceph-disk chown ...' or similar to fix ownership"
+    exit 1
+fi
+
+exit 0