Browse Source

debian/aoetools.init:

- Change Provides: in the LSB header from 'mountaoe' to 'aoe'.
- Add a comment about the loading of the aoe module.
- Rearranged logic a bit, in order to postpone module load until we have a
  valid interface list.  This has the added value of resolving (again) the
  installation in a new system.
- Sleep 1 second before checking for /dev/etherd/discover, to give udev a
  chance to create the files.
- Merged most of the modifications to the init script, kindly contributed
  by Glen W. Mabey.  I added robustness and fixed some old errors while at
  it.  This closes: #408044, #387552 (finally).

debian/aoetools.default: Added support for LVMGROUPS and AOEMOUNTS.
David Martínez Moreno 16 years ago
parent
commit
ca65173fba
2 changed files with 101 additions and 39 deletions
  1. 9 1
      debian/aoetools.default
  2. 92 38
      debian/aoetools.init

+ 9 - 1
debian/aoetools.default

@@ -1,9 +1,17 @@
 # Configuration file for aoetools.
 
 # Enter the list of network interfaces to restrict the AoE discovery to, separated by spaces.
-# It can be blank, i.e., "".
+# It can be blank, i.e. "".
 # If you do not want AoE discovery at all, enter "none" as the list of interfaces.
 #
 # If neither the aoe_iflist module load option nor this list of interfaces are used, the aoe driver
 # will use any network interface for AoE traffic.
 INTERFACES="none"
+
+# Enter a list of LVM2 volume groups to be activated after AoE volumes are ready, separated by spaces.
+# It can be blank, i.e., "".
+LVMGROUPS=""
+
+# Enter a list of file systems to be mounted over AoE.  Note that those entries listed in /etc/fstab
+# that contain "/dev/etherd/" will be automatically added to this list.
+AOEMOUNTS=""

+ 92 - 38
debian/aoetools.init

@@ -7,6 +7,9 @@
 #       Also based on init script mountnfs.sh from initscripts package.
 #
 #       Modified for aoetools by David Martínez 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
@@ -34,34 +37,9 @@ fi
 
 set -e
 
-do_start() {
-    # We exit if the user do 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.
-    # Also, if udev is being used, the /dev/etherd devices
-    # are not created until aoe module insertion.
-    modprobe aoe >/dev/null 2>&1 || true
-
-    if [ ! -c /dev/etherd/discover ]
-    then
-        echo "Missing devices under /dev/etherd/.  Please run" >&2
-        echo "  aoe-mkdevs /dev/etherd" >&2
-        echo "and try again."
-        exit 1
-    fi
-
-    # Try to set up interfaces for discovery, if any.
-    if [ ! -z "$INTERFACES" ]
-    then
-        aoe-interfaces $INTERFACES
-    fi
-
-    aoe-discover
+create_fs_list() {
+    # We start with a list from /etc/default/aoetools.
+    waitaoe="$AOEMOUNTS"
 
     [ -f /etc/fstab ] || return
     #
@@ -71,7 +49,6 @@ do_start() {
 
     exec 9<&0 </etc/fstab
 
-    waitaoe=
     while read DEV MTPT FSTYPE OPTS REST
     do
         case "$OPTS" in
@@ -89,17 +66,93 @@ do_start() {
     done
 
     exec 0<&9 9<&-
+}
 
-    if [ ! -z "$waitaoe" ]
+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
 
-    for mountpt in $waitaoe; do
-        echo "Mounting $mountpt..."
-        mount $mountpt
-        #log_action_begin_msg "Waiting for $mountpt"
-    done
+    # 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
@@ -108,11 +161,12 @@ case "$1" in
 
     do_start
     
-	#echo "$NAME."
 	;;
   stop)
-	#echo -n "Stopping $DESC: "
-	#echo "$NAME."
+	echo -n "Stopping $DESC: "
+
+    do_stop
+
 	;;
   *)
 	N=/etc/init.d/$NAME