From b86d450ad4607073cb4621958245a2fa118d6541 Mon Sep 17 00:00:00 2001 From: Laurent Barbe Date: Wed, 18 Dec 2013 14:20:24 +0100 Subject: [PATCH] upstart: add rbdmap script Upstart script for mapping / unmapping rbd device based on /etc/ceph/rbdmap file. It does not mount or unmount filesystem, this part should be performed by _netdev option in fstab. Signed-off-by: Laurent Barbe --- debian/rules | 1 + src/Makefile.am | 1 + src/upstart/rbdmap.conf | 48 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 src/upstart/rbdmap.conf diff --git a/debian/rules b/debian/rules index 88b2b3df5e82..9b26a3cda833 100755 --- a/debian/rules +++ b/debian/rules @@ -119,6 +119,7 @@ binary-arch: build install # per package, so do this ourselves install -d -m0755 debian/ceph/etc/init install -m0644 src/upstart/ceph*.conf debian/ceph/etc/init + install -m0644 src/upstart/rbdmap.conf debian/ceph/etc/init install -d -m0755 debian/ceph-mds/etc/init mv debian/ceph/etc/init/ceph-mds* debian/ceph-mds/etc/init install -d -m0755 debian/radosgw/etc/init diff --git a/src/Makefile.am b/src/Makefile.am index 7ee5e6a11207..cc76dadc9db2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -173,6 +173,7 @@ EXTRA_DIST += \ $(srcdir)/upstart/radosgw.conf \ $(srcdir)/upstart/radosgw-all.conf \ $(srcdir)/upstart/radosgw-all-starter.conf \ + $(srcdir)/upstart/rbdmap.conf \ ceph.in \ ceph-disk \ ceph-disk-prepare \ diff --git a/src/upstart/rbdmap.conf b/src/upstart/rbdmap.conf new file mode 100644 index 000000000000..a581c2a3745e --- /dev/null +++ b/src/upstart/rbdmap.conf @@ -0,0 +1,48 @@ +# rbdmap - Ceph RBD Mapping +# +# This script does not manage mount and unmount fs which depends on rbd device. +# You should use _netdev option in fstab to mount and umount in the correct order. + +description "ceph rbd mapping" + +start on (started networking + and remote-filesystems) +stop on unmounted-remote-filesystems + +env RBDMAPFILE="/etc/ceph/rbdmap" + +pre-start script + if [ ! -f "$RBDMAPFILE" ]; then + exit 0 + fi + + while read DEV PARAMS; do + case "$DEV" in + ""|\#*) + continue + ;; + */*) + ;; + *) + DEV=rbd/$DEV + ;; + esac + for PARAM in $(echo $PARAM | tr ',' '\n'); do + CMDPARAMS="$CMDPARAMS --$(echo $PARAM | tr '=' ' ')" + done + if [ ! -b /dev/rbd/$DEV ]; then + echo "rbd map $DEV" + rbd map $DEV $CMDPARAMS + fi + done < $RBDMAPFILE +end script + +post-stop script + if ls /dev/rbd[0-9]* >/dev/null 2>&1; then + for DEV in /dev/rbd[0-9]*; do + echo "rbd unmap $DEV" + rbd unmap $DEV + done + fi +end script + -- 2.47.3