]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
upstart: add rbdmap script 965/head
authorLaurent Barbe <laurent@ksperis.com>
Wed, 18 Dec 2013 13:20:24 +0000 (14:20 +0100)
committerLaurent Barbe <laurent@ksperis.com>
Wed, 18 Dec 2013 13:20:24 +0000 (14:20 +0100)
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 <laurent@ksperis.com>
debian/rules
src/Makefile.am
src/upstart/rbdmap.conf [new file with mode: 0644]

index 88b2b3df5e82469c9066640cc9663df47f9c4d39..9b26a3cda833dc2a008313f320de99b56dcc1d79 100755 (executable)
@@ -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
index 7ee5e6a11207b777e67b5c944ef477c5eb571502..cc76dadc9db20bf67c81cc49e71a2d710d31098b 100644 (file)
@@ -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 (file)
index 0000000..a581c2a
--- /dev/null
@@ -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
+