ungleich-tools/ceph/ceph-osd-create-start

40 lines
1.2 KiB
Text
Raw Normal View History

2018-02-15 22:21:42 +00:00
#!/bin/sh
# 17:19, 2018-02-09
# Nico Schottelius
2018-02-18 18:51:48 +00:00
if [ $# -lt 2 ]; then
2021-04-19 14:51:45 +00:00
echo "$0 disk class [nostart]"
2018-02-15 22:21:42 +00:00
echo "class = hdd or ssd"
2021-04-19 14:51:45 +00:00
echo "If specifying anything after the class, monit will not be created"
2018-02-15 22:21:42 +00:00
exit 1
fi
export DEV=$1;shift
export CLASS=$1; shift
2018-02-18 18:51:48 +00:00
set -e
2021-04-19 14:51:45 +00:00
# Ensure ceph-volume has all pre-requisites
if [ ! -f /var/lib/ceph/bootstrap-osd/ceph.keyring ]; then
mkdir -p /var/lib/ceph/bootstrap-osd
ceph auth get client.bootstrap-osd > /var/lib/ceph/bootstrap-osd/ceph.keyring
fi
if [ ! -f /etc/ceph/ceph.client.bootstrap-osd.keyring ]; then
ceph auth get client.bootstrap-osd > /etc/ceph/ceph.client.bootstrap-osd.keyring
fi
2018-02-15 22:21:42 +00:00
# We are redirecting to a tempfile so that the output is visible for debugging,
# but we can still easily filter for the osd id
tmp=$(mktemp)
ceph-volume lvm prepare --data $DEV --crush-device-class $CLASS 2>&1 | tee ${tmp}
osd_id=$(grep /var/lib/ceph/osd/ceph- ${tmp} | sed -e 's/.*ceph-//' -e 's,/.*,,' | head -n1)
rm -f ${tmp}
2020-10-01 21:20:49 +00:00
2018-02-18 18:51:48 +00:00
if [ $# -eq 1 ]; then
2021-04-19 14:51:45 +00:00
echo "Not executing: /opt/ungleich-tools/monit-ceph-create-start osd.${osd_id}"
2018-02-18 18:51:48 +00:00
else
2021-04-19 14:51:45 +00:00
# Start it
/opt/ungleich-tools/monit-ceph-create-start osd.${osd_id}
2018-02-18 18:51:48 +00:00
fi