Browse Source

aoetools.init: Added 'status' action, fixed a bug with LVMGROUPS
and clarified the case when we don't mount anything because of
/etc/default/aoetools.

David Martínez Moreno 9 years ago
parent
commit
02938993fe
2 changed files with 40 additions and 21 deletions
  1. 38 21
      debian/aoetools.init
  2. 2 0
      debian/changelog

+ 38 - 21
debian/aoetools.init

@@ -15,7 +15,7 @@
 # Provides:          aoe aoetools
 # Required-Start:    $local_fs $network
 # Required-Stop:     $local_fs $network
-# Should-Start:      
+# Should-Start:
 # Default-Start:     S
 # Default-Stop:      0 6
 # Short-Description: Begin AoE discovery and mount related filesystems.
@@ -43,7 +43,7 @@ create_fs_list() {
     [ -f /etc/fstab ] || return
     #
     # Read through fstab line by line. If it contains /dev/etherd, set the flag
-    # for mounting file systems over AoE. 
+    # for mounting file systems over AoE.
     #
 
     exec 9<&0 </etc/fstab
@@ -71,7 +71,7 @@ do_start() {
     # We exit if the user does not want us to try this.
     if [ "$INTERFACES" = "none" ]
     then
-        echo "not started."
+        echo "INTERFACES='none' in /etc/default/aoetools, not started."
         exit 0
     fi
 
@@ -116,7 +116,7 @@ do_start() {
         echo
         echo "The LVM2 tools are not present.  Please install lvm2 package and try again." >&2
         echo "We will not honour LVMGROUPS." >&2
-        LMVGROUPS=''
+        LVMGROUPS=''
     fi
 
     if [ -n "$LVMGROUPS" ]
@@ -166,24 +166,41 @@ do_stop() {
     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
+
+}
+
 case "$1" in
-  start|restart|reload|force-reload)
-	echo -n "Starting $DESC: "
-
-    do_start
-    
-	;;
-  stop)
-	echo "Stopping $DESC: "
-
-    do_stop
-
-	;;
-  *)
-	N=/etc/init.d/$NAME
-	echo "Usage: $N {start|stop|restart|reload|force-reload}" >&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

+ 2 - 0
debian/changelog

@@ -28,6 +28,8 @@ aoetools (36-1) UNRELEASED; urgency=low
     - 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.
 
  -- David Martínez Moreno <ender@debian.org>  Sun, 12 Jan 2014 15:05:34 -0800