]> git.proxmox.com Git - ceph.git/blame - ceph/src/ceph-osd-prestart.sh
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / ceph-osd-prestart.sh
CommitLineData
7c673cae
FG
1#!/bin/sh
2
3if [ `uname` = FreeBSD ]; then
4 GETOPT=/usr/local/bin/getopt
5else
6 GETOPT=getopt
7fi
8
9eval set -- "$(${GETOPT} -o i: --long id:,cluster: -- $@)"
10
11while true ; do
12 case "$1" in
13 -i|--id) id=$2; shift 2 ;;
14 --cluster) cluster=$2; shift 2 ;;
15 --) shift ; break ;;
16 esac
17done
18
19if [ -z "$id" ]; then
20 echo "Usage: $0 [OPTIONS]"
21 echo "--id/-i ID set ID portion of my name"
22 echo "--cluster NAME set cluster name (default: ceph)"
23 exit 1;
24fi
25
26data="/var/lib/ceph/osd/${cluster:-ceph}-$id"
27
28# assert data directory exists - see http://tracker.ceph.com/issues/17091
29if [ ! -d "$data" ]; then
30 echo "OSD data directory $data does not exist; bailing out." 1>&2
31 exit 1
32fi
33
34journal="$data/journal"
35
36if [ -L "$journal" -a ! -e "$journal" ]; then
37 udevadm settle --timeout=5 || :
38 if [ -L "$journal" -a ! -e "$journal" ]; then
39 echo "ceph-osd(${cluster:-ceph}-$id): journal not present, not starting yet." 1>&2
40 exit 0
41 fi
42fi
43
44# ensure ownership is correct
45owner=`stat -c %U $data/.`
46if [ $owner != 'ceph' -a $owner != 'root' ]; then
47 echo "ceph-osd data dir $data is not owned by 'ceph' or 'root'"
48 echo "you must 'chown -R ceph:ceph ...' or similar to fix ownership"
49 exit 1
50fi
51
52exit 0