---
 rc.shutdown |   52 +++++++++++++++++++++++-----------------------------
 1 files changed, 23 insertions(+), 29 deletions(-)

diff --git a/rc.shutdown b/rc.shutdown
index b2278b6..b7b7d45 100755
--- a/rc.shutdown
+++ b/rc.shutdown
@@ -65,7 +65,7 @@ stat_busy "Unmounting Filesystems"
 stat_done
 
 # Kill non-root encrypted partition mappings
-if [ -f /etc/crypttab -a -n "$(/bin/grep -v ^# /etc/crypttab | /bin/grep -v 
^$)" ]; then
+if [[ -f /etc/crypttab ]]; then
        stat_busy "Deactivating encrypted volumes:"
        # Arch cryptsetup packages traditionally contained the binaries
        #  /usr/sbin/cryptsetup
@@ -73,38 +73,32 @@ if [ -f /etc/crypttab -a -n "$(/bin/grep -v ^# 
/etc/crypttab | /bin/grep -v ^$)"
        # By default, initscripts used the /sbin/cryptsetup.static.
        # Newer packages will only have /sbin/cryptsetup and no static binary
        # This ensures maximal compatibility with the old and new layout
-       if [ -x /sbin/cryptsetup ]; then
-               CS=/sbin/cryptsetup
-       elif [ -x /usr/sbin/cryptsetup ]; then
-               CS=/usr/sbin/cryptsetup
+        for CS in /sbin/cryptsetup /usr/sbin/cryptsetup \
+            /sbin/cryptsetup.static ''; do
+            [[ -x $CS ]] && break
+        done
+        if [[ ! $CS ]]; then
+            stat_append " Failed, unable to find cryptsetup."
+            stat_fail
        else
-               CS=/sbin/cryptsetup.static
-       fi
-       do_uncrypt() {
-               if [ $# -ge 3 ]; then
-                       if [ -b /dev/mapper/$1 ] ;then
-                               stat_append "${1}.."
-                               $CS remove $1 >/dev/null 2>&1
-                               if [ $? -ne 0 ]; then
-                                       stat_append "failed "
-                               else
-                                       stat_append "ok "
-                               fi
-                       fi
+            while read name src passwd opts; do
+                [[ ! $name || ${name:0:1} = '#']] && continue
+                [[ -b /dev/mapper/$name ]] || continue
+               stat_append "${1}.."
+               if "$CS" remove "$name" >/dev/null 2>&1; then
+                   stat_append "ok "
+                else
+                   stat_append "failed "
                fi
-       }
-       while read line; do
-               eval do_uncrypt "$line"
-       done </etc/crypttab
-       stat_done
+           done </etc/crypttab
+        fi
+        stat_done
 fi
 
-if [ "$USELVM" = "yes" -o "$USELVM" = "YES" ]; then
-       if [ -x /sbin/lvm -a -d /sys/block ]; then
-               stat_busy "Deactivating LVM2 groups"
-               /sbin/lvm vgchange --ignorelockingfailure -an >/dev/null 2>&1
-               stat_done
-       fi
+if [[ $USELVM =~ yes|YES && -x /sbin/lvm && -d /sys/block ]]; then
+    stat_busy "Deactivating LVM2 groups"
+    /sbin/lvm vgchange --ignorelockingfailure -an >/dev/null 2>&1
+    stat_done
 fi
 
 stat_busy "Remounting Root Filesystem Read-only"
-- 
1.7.1

Reply via email to