summaryrefslogtreecommitdiffstats
path: root/src/ceph-osd-prestart.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
commit19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch)
tree42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/ceph-osd-prestart.sh
parentInitial commit. (diff)
downloadceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.tar.xz
ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.zip
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/ceph-osd-prestart.sh')
-rw-r--r--src/ceph-osd-prestart.sh52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/ceph-osd-prestart.sh b/src/ceph-osd-prestart.sh
new file mode 100644
index 000000000..f946bf43b
--- /dev/null
+++ b/src/ceph-osd-prestart.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+if [ `uname` = FreeBSD ]; then
+ GETOPT=/usr/local/bin/getopt
+else
+ GETOPT=getopt
+fi
+
+eval set -- "$(${GETOPT} -o i: --long id:,cluster: -- $@)"
+
+while true ; do
+ case "$1" in
+ -i|--id) id=$2; shift 2 ;;
+ --cluster) cluster=$2; shift 2 ;;
+ --) shift ; break ;;
+ esac
+done
+
+if [ -z "$id" ]; then
+ echo "Usage: $0 [OPTIONS]"
+ echo "--id/-i ID set ID portion of my name"
+ echo "--cluster NAME set cluster name (default: ceph)"
+ exit 1;
+fi
+
+data="/var/lib/ceph/osd/${cluster:-ceph}-$id"
+
+# assert data directory exists - see http://tracker.ceph.com/issues/17091
+if [ ! -d "$data" ]; then
+ echo "OSD data directory $data does not exist; bailing out." 1>&2
+ exit 1
+fi
+
+journal="$data/journal"
+
+if [ -L "$journal" -a ! -e "$journal" ]; then
+ udevadm settle --timeout=5 || :
+ if [ -L "$journal" -a ! -e "$journal" ]; then
+ echo "ceph-osd(${cluster:-ceph}-$id): journal not present, not starting yet." 1>&2
+ exit 0
+ fi
+fi
+
+# ensure ownership is correct
+owner=`stat -c %U $data/.`
+if [ $owner != 'ceph' -a $owner != 'root' ]; then
+ echo "ceph-osd data dir $data is not owned by 'ceph' or 'root'"
+ echo "you must 'chown -R ceph:ceph ...' or similar to fix ownership"
+ exit 1
+fi
+
+exit 0