From: Sage Weil Date: Fri, 24 Apr 2015 00:14:27 +0000 (-0700) Subject: ceph-osd-prestart.sh: ensure data dir is root or ceph before start X-Git-Tag: v9.1.0~294^2~15 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bbedc8e57e74f7c336e5e547ddf5166d8f65cdb0;p=ceph.git ceph-osd-prestart.sh: ensure data dir is root or ceph before start Signed-off-by: Sage Weil --- diff --git a/src/ceph-osd-prestart.sh b/src/ceph-osd-prestart.sh index 79f2c132d9fc..a76747b232d5 100644 --- a/src/ceph-osd-prestart.sh +++ b/src/ceph-osd-prestart.sh @@ -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