~upstart-devel/upstart/upstart-jobs

« back to all changes in this revision

Viewing changes to utopic/etc/init/rbdmap.conf

  • Committer: Dimitri John Ledkov
  • Date: 2014-05-06 18:45:46 UTC
  • Revision ID: dimitri.ledkov@canonical.com-20140506184546-5toyx56xxrue0f0v
auto update

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# rbdmap - Ceph RBD Mapping
 
2
#
 
3
# This script does not manage mount and unmount fs which depends on rbd device.
 
4
# You should use _netdev option in fstab to mount and umount in the correct order.
 
5
 
 
6
description "ceph rbd mapping"
 
7
 
 
8
start on (started networking
 
9
    and remote-filesystems)
 
10
stop on unmounted-remote-filesystems
 
11
 
 
12
env RBDMAPFILE="/etc/ceph/rbdmap"
 
13
 
 
14
pre-start script
 
15
    if [ ! -f "$RBDMAPFILE" ]; then
 
16
        exit 0
 
17
    fi
 
18
 
 
19
    while read DEV PARAMS; do
 
20
        case "$DEV" in
 
21
          ""|\#*)
 
22
            continue
 
23
            ;;
 
24
          */*)
 
25
            ;;
 
26
          *)
 
27
            DEV=rbd/$DEV
 
28
            ;;
 
29
        esac
 
30
        for PARAM in $(echo $PARAMS | tr ',' '\n'); do
 
31
            CMDPARAMS="$CMDPARAMS --$(echo $PARAM | tr '=' ' ')"
 
32
        done
 
33
        if [ ! -b /dev/rbd/$DEV ]; then
 
34
            echo "rbd map $DEV"
 
35
            rbd map $DEV $CMDPARAMS
 
36
        fi
 
37
    done < $RBDMAPFILE
 
38
end script
 
39
 
 
40
post-stop script
 
41
    if ls /dev/rbd[0-9]* >/dev/null 2>&1; then
 
42
        for DEV in /dev/rbd[0-9]*; do
 
43
            echo "rbd unmap $DEV"
 
44
            rbd unmap $DEV
 
45
        done
 
46
    fi
 
47
end script
 
48