File: aoetools.init

package info (click to toggle)
aoetools 26-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 224 kB
  • ctags: 140
  • sloc: ansic: 773; sh: 477; makefile: 64
file content (178 lines) | stat: -rw-r--r-- 4,138 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#! /bin/sh
#
#       Based on a example file to build /etc/init.d/ scripts,
#		written by Miquel van Smoorenburg <miquels@cistron.nl>
#		and later modified by Ian Murdock <imurdock@gnu.ai.mit.edu>.
#
#       Also based on init script mountnfs.sh from initscripts package.
#
#       Modified for aoetools by David Martnez Moreno <ender@debian.org>.
#       Copyright 2006-2007.  Under GPLv2.
#
#       Support for LVM and other mount points contributed by Glen W. Mabey.
#
### BEGIN INIT INFO
# Provides:          aoe
# Required-Start:    $local_fs $network
# Required-Stop:     $local_fs $network
# Should-Start:      
# Default-Start:     S
# Default-Stop:      0 6
# Short-Description: Begin AoE discovery and mount related filesystems.
# Description:       Begin AoE discovery and mount filesystems residing
#                    on AoE volumes.
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=aoetools
DESC="AoE devices discovery and mounting AoE filesystems"

[ -f /etc/default/rcS ] && . /etc/default/rcS
. /lib/lsb/init-functions

# Include aoetools defaults if available
if [ -f /etc/default/aoetools ] ; then
	. /etc/default/aoetools
fi

set -e

create_fs_list() {
    # We start with a list from /etc/default/aoetools.
    waitaoe="$AOEMOUNTS"

    [ -f /etc/fstab ] || return
    #
    # Read through fstab line by line. If it contains /dev/etherd, set the flag
    # for mounting file systems over AoE. 
    #

    exec 9<&0 </etc/fstab

    while read DEV MTPT FSTYPE OPTS REST
    do
        case "$OPTS" in
          noauto|*,noauto|noauto,*|*,noauto,*)
            continue
            ;;
        esac
        case "$DEV" in
          ""|\#*)
            continue
            ;;
          /dev/etherd/*)
            waitaoe="$waitaoe $MTPT"
        esac
    done

    exec 0<&9 9<&-
}

do_start() {
    # We exit if the user does not want us to try this.
    if [ "$INTERFACES" = "none" ]
    then
        echo "not started."
        exit 0
    fi

    # Usually aoe is a module, so we will try to load it.
    modprobe aoe >/dev/null 2>&1 || true

    # Also, if udev is being used, the /dev/etherd devices
    # are not created until aoe module insertion, so...
    sleep 1  # ...we give udev a chance to populate /dev/etherd/.

    if [ ! -c /dev/etherd/discover ]
    then
        echo
        echo "Missing devices under /dev/etherd/.  Please run" >&2
        echo "  aoe-mkdevs /dev/etherd" >&2
        echo "and try again." >&2
        exit 1
    fi

    # Try to set up interfaces for discovery, if any.
    if [ -n "$INTERFACES" ]
    then
        aoe-interfaces $INTERFACES
    fi

    aoe-discover

    create_fs_list

    if [ -n "$waitaoe" ]
    then
        echo
    fi

    if [ ! -x "/sbin/vgchange" -a -n "$LVMGROUPS" ]
    then
        echo
        echo "The LVM2 tools are not present.  Please install lvm2 package and try again." >&2
        echo "We will not honour LVMGROUPS." >&2
        LMVGROUPS=""
    fi

    if [ -n "$LVMGROUPS" ]
    then
        for vg in "$LVMGROUPS"; do
            vgchange --available=y $vg
        done
    fi

    if [ -n "$waitaoe" ]
    then
        for mountpt in $waitaoe; do
            echo "Mounting $mountpt..."
            mount $mountpt
            #log_action_begin_msg "Waiting for $mountpt."
        done
    fi
}

do_stop() {
    create_fs_list

    if [ -n "$waitaoe" ]
    then
        for mountpt in $waitaoe; do
            echo "Unmounting $mountpt..."
            umount $mountpt
        done
    fi

    if [ -n "$LVMGROUPS" ]
    then
        for vg in "$LVMGROUPS"; do
            vgchange --available=n $vg
        done
    fi

    # Removing the module prevents LVM's "Shutting down LVM Volume Groups..."
    # from hanging when an LVM has been setup on a device in /dev/etherd/.
    modprobe --remove aoe >/dev/null 2>&1 || true
}

case "$1" in
  start|restart|reload|force-reload)
	echo -n "Starting $DESC: "

    do_start
    
	;;
  stop)
	echo -n "Stopping $DESC: "

    do_stop

	;;
  *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
	exit 1
	;;
esac

exit 0