Browse Source

* debian/aoetools.init:
- Unified the style for loops and whitespace.
- Added support for assembling RAID devices during start-up. Based on a
patch by Gabor Kiss (closes: #606307). Thanks, Gabor!
* debian/aoetools.default: Added support for RAID_ARRAYS and switched to
single quotes.

David Martínez Moreno 10 years ago
parent
commit
3d61de74c8
3 changed files with 201 additions and 158 deletions
  1. 10 4
      debian/aoetools.default
  2. 185 153
      debian/aoetools.init
  3. 6 1
      debian/changelog

+ 10 - 4
debian/aoetools.default

@@ -6,12 +6,18 @@
 #
 # 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"
+INTERFACES='none'
+
+# Enter a list of RAID arrays to be activated after AoE volumes are ready, separated by spaces,
+# without the /dev/ prefix and quoted.  It may be blank.
+# Example:
+#RAID_ARRAYS='md0 md1'
+RAID_ARRAYS=''
 
 # 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=""
+# 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=""
+AOEMOUNTS=''

+ 185 - 153
debian/aoetools.init

@@ -1,8 +1,8 @@
 #! /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>.
+#        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.
 #
@@ -10,6 +10,7 @@
 #       Copyright 2006-2014.  Under GPLv2.
 #
 #       Support for LVM and other mount points contributed by Glen W. Mabey.
+#       Support for RAID contributed by Gabor Kiss.
 #
 ### BEGIN INIT INFO
 # Provides:          aoe aoetools
@@ -30,177 +31,208 @@ DESC="AoE devices discovery and mounting AoE filesystems"
 . /lib/lsb/init-functions
 
 # Include aoetools defaults if available
-if [ -f /etc/default/aoetools ] ; then
-	. /etc/default/aoetools
+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.
-    #
+  # 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 9<&0 </etc/fstab
+  exec 0<&9 9<&-
+}
 
-    while read DEV MTPT FSTYPE OPTS REST
+do_start() {
+  # We exit if the user does not want us to try this.
+  if [ "$INTERFACES" = "none" ]
+  then
+    echo "INTERFACES='none' in /etc/default/aoetools, not started."
+    exit 0
+  fi
+
+  # Usually aoe is a module, so we will try to load it.
+  if [ -n "$INTERFACES" ]
+  then
+    modprobe aoe aoe_iflist="$INTERFACES" >/dev/null 2>&1 || true
+  else
+    modprobe aoe >/dev/null 2>&1 || true
+  fi
+
+  # 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/mdadm' -a -n "$RAID_ARRAYS" ]
+  then
+    echo
+    echo "/sbin/mdadm is not present. Please install mdadm package and try again." >&2
+    echo "RAID_ARRAYS option is ignored." >&2
+    RAID_ARRAYS=''
+  fi
+
+  if [ -n "$RAID_ARRAYS" ]
+  then
+    echo "Assembling RAID arrays..."
+    for md in $RAID_ARRAYS
     do
-        case "$OPTS" in
-          noauto|*,noauto|noauto,*|*,noauto,*)
-            continue
-            ;;
-        esac
-        case "$DEV" in
-          ""|\#*)
-            continue
-            ;;
-          /dev/etherd/*)
-            waitaoe="$waitaoe $MTPT"
-        esac
+      /sbin/mdadm --assemble $md --scan
     done
+  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
+    LVMGROUPS=''
+  fi
+
+  if [ -n "$LVMGROUPS" ]
+  then
+    echo "Assembling LVM2 groups..."
+    for vg in "$LVMGROUPS"
+    do
+      vgchange --available=y $vg
+    done
+  fi
 
-    exec 0<&9 9<&-
-}
-
-do_start() {
-    # We exit if the user does not want us to try this.
-    if [ "$INTERFACES" = "none" ]
-    then
-        echo "INTERFACES='none' in /etc/default/aoetools, not started."
-        exit 0
-    fi
-
-    # Usually aoe is a module, so we will try to load it.
-    if [ -n "$INTERFACES" ]
-    then
-        modprobe aoe aoe_iflist="$INTERFACES" >/dev/null 2>&1 || true
-    else
-        modprobe aoe >/dev/null 2>&1 || true
-    fi
-
-    # 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
-        LVMGROUPS=''
-    fi
-
-    if [ -n "$LVMGROUPS" ]
-    then
-	echo "Assembling LVM2 groups..."
-        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
-    else
-    	echo "Nothing to mount."
-    fi
+  if [ -n "$waitaoe" ]
+  then
+    for mountpt in $waitaoe
+    do
+      echo "Mounting $mountpt..."
+      mount $mountpt
+      #log_action_begin_msg "Waiting for $mountpt."
+    done
+  else
+    echo "Nothing to mount."
+  fi
 }
 
 do_stop() {
-    create_fs_list
-
-    if [ -n "$waitaoe" ]
-    then
-        for mountpt in $waitaoe; do
-	    if [ -z "`awk '{print $2}' < /proc/mounts | grep -w $mountpt$`" ];then
-	        # It's already been unmounted.
-	    	continue
-	    fi
-            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
+  create_fs_list
+
+  if [ -n "$waitaoe" ]
+  then
+    for mountpt in $waitaoe; do
+      if [ -z "`awk '{print $2}' < /proc/mounts | grep -w $mountpt$`" ]
+      then
+        # It's already been unmounted.
+        continue
+      fi
+      echo "Unmounting $mountpt..."
+      umount $mountpt
+    done
+  fi
+
+  if [ -n "$LVMGROUPS" ]
+  then
+    for vg in "$LVMGROUPS"
+    do
+      vgchange --available=n $vg
+    done
+  fi
+
+  if [ -x /sbin/mdadm -a -n "$RAID_ARRAYS" ]
+  then
+    echo "Stopping RAID arrays..."
+    for md in $RAID_ARRAYS
+    do
+      /sbin/mdadm --stop /dev/$md
+    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
 }
 
 do_status() {
-    if $(lsmod |grep -qw '^aoe\s')
-    then
-        echo 'The aoe module is loaded.'
-    fi
-    # FIXME: Make something smarter like detect udev or a monolithic kernel.
-
-    AOE_MOUNTS="$(grep '/dev/etherd/' /proc/mounts)"
-    if [ -n "$AOE_MOUNTS" ]
-    then
-        echo 'The following AoE file systems are mounted:'
-        echo "$AOE_MOUNTS" | awk '{print $2}'
-    else
-        echo 'No AoE file systems mounted.'
-    fi
+  if $(lsmod |grep -qw '^aoe\s')
+  then
+    echo 'The aoe module is loaded.'
+  fi
+  # FIXME: Make something smarter like detect udev or a monolithic kernel.
+
+  AOE_MOUNTS="$(grep '/dev/etherd/' /proc/mounts || true)"
+  if [ -n "$AOE_MOUNTS" ]
+  then
+    echo 'The following AoE file systems are mounted:'
+    echo "$AOE_MOUNTS" | awk '{print $2}'
+  else
+    echo 'No AoE file systems mounted.'
+  fi
 
 }
 
 case "$1" in
-    start|restart|reload|force-reload)
-	    echo -n "Starting $DESC: "
-        do_start
-	    ;;
-    stop)
-	    echo "Stopping $DESC: "
-        do_stop
-	    ;;
-    status)
-        do_status
-        ;;
-    *)
-	    N=/etc/init.d/$NAME
-	    echo "Usage: $N {start|stop|restart|reload|force-reload|status}" >&2
-	    exit 1
-	    ;;
+  start|restart|reload|force-reload)
+    echo -n "Starting $DESC: "
+    do_start
+    ;;
+  stop)
+    echo "Stopping $DESC: "
+    do_stop
+    ;;
+  status)
+    do_status
+    ;;
+  *)
+    N=/etc/init.d/$NAME
+    echo "Usage: $N {start|stop|restart|reload|force-reload|status}" >&2
+    exit 1
+    ;;
 esac
 
 exit 0

+ 6 - 1
debian/changelog

@@ -22,7 +22,7 @@ aoetools (36-1) UNRELEASED; urgency=low
     - Stop restarting aoetools on upgrades.  This is the wrong thing, as we
       don't have a daemon or anything like that, because everything happends
       inside the kernel once the devices are mounted.  We caused unnecesary
-      grief with it (closes: #568554).
+      grief with it (closes: #568554).  I'm very sorry.
   * debian/watch: Added.
   * debian/patches:
     - 02_no_hyphen_in_manpages: Refreshed, and fixed a typo in aoeping.8.
@@ -31,11 +31,16 @@ aoetools (36-1) UNRELEASED; urgency=low
     - 04_support_slash_run_slash_udev: New, adding /run/udev to the udev
       checks.  Thanks, Roger Leigh (closes: #644308).
   * debian/aoetools.init:
+    - Unified the style for loops and whitespace.
     - Removed PATH with /usr elements to avoid lintian tripping on the wrong
       check.
     - Added aoetools to Provides.
     - Added 'status' action, fixed a bug with LVMGROUPS and clarified the case
       when we don't mount anything because of /etc/default/aoetools.
+    - Added support for assembling RAID devices during start-up.  Based on a
+      patch by Gabor Kiss (closes: #606307).  Thanks, Gabor!
+  * debian/aoetools.default: Added support for RAID_ARRAYS and switched to
+    single quotes.
   * Added hooks for initramfs-tools in order to be able to support booting
     from an AoE root device.  Thanks, wolfle (closes: #591026).