]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
dracut-functions.sh: add expand_persistent_dev()
authorHarald Hoyer <harald@redhat.com>
Tue, 20 Aug 2013 14:01:10 +0000 (16:01 +0200)
committerHarald Hoyer <harald@redhat.com>
Tue, 20 Aug 2013 14:03:17 +0000 (16:03 +0200)
also fixes missing '{' for LABEL=... swaps

dracut-functions.sh
dracut.sh

index 1d70bd0051f8e6da9d86627743b44211ebb527b5..6c7e693d83c661168d6ac3c88bf3b021b1d788b0 100755 (executable)
@@ -323,19 +323,43 @@ get_persistent_dev() {
     done
 }
 
+expand_persistent_dev() {
+    local _dev=$1
+
+    case "$_dev" in
+        LABEL=*)
+            _dev="/dev/disk/by-label/${_dev#LABEL=}"
+            ;;
+        UUID=*)
+            _dev="${_dev#UUID=}"
+            _dev="$(tr "[:upper:]" "[:lower:]" <<< "$_dev" )"
+            _dev="/dev/disk/by-uuid/${_dev}"
+            ;;
+        PARTUUID=*)
+            _dev="${_dev#PARTUUID=}"
+            _dev="$(tr "[:upper:]" "[:lower:]"  <<< "$_dev" )"
+            _dev="/dev/disk/by-partuuid/${_dev}"
+            ;;
+        PARTLABEL=*)
+            _dev="/dev/disk/by-partlabel/${_dev#PARTLABEL=}"
+            ;;
+    esac
+    printf "%s" "$_dev"
+}
+
 shorten_persistent_dev() {
-    local dev="$1"
-    case "$dev" in
+    local _dev="$1"
+    case "$_dev" in
         /dev/disk/by-uuid/*)
-            printf "%s" "UUID=${dev##*/}";;
+            printf "%s" "UUID=${_dev##*/}";;
         /dev/disk/by-label/*)
-            printf "%s" "LABEL=${dev##*/}";;
+            printf "%s" "LABEL=${_dev##*/}";;
         /dev/disk/by-partuuid/*)
-            printf "%s" "PARTUUID=${dev##*/}";;
+            printf "%s" "PARTUUID=${_dev##*/}";;
         /dev/disk/by-partlabel/*)
-            printf "%s" "PARTLABEL=${dev##*/}";;
+            printf "%s" "PARTLABEL=${_dev##*/}";;
         *)
-            printf "%s" "$dev";;
+            printf "%s" "$_dev";;
     esac
 }
 
index 117f877cf9dfb361a5dc77aa9f27a3fbe9320136..0c42958b4ee410f24a55fe141dd0f0439ec07557 100755 (executable)
--- a/dracut.sh
+++ b/dracut.sh
@@ -913,8 +913,7 @@ if [[ $hostonly ]]; then
                 [[ $_t != "swap" ]] && continue
                 [[ $_m != "swap" ]] && [[ $_m != "none" ]] && continue
                 [[ "$_o" == *noauto* ]] && continue
-                [[ "$_d" == UUID\=* ]] && _d="/dev/disk/by-uuid/${_d#UUID=}"
-                [[ "$_d" == LABEL\=* ]] && _d="/dev/disk/by-label/$_d#LABEL=}"
+                _d=$(expand_persistent_dev "$_d")
                 [[ "$_d" -ef "$dev" ]] || continue
 
                 if [[ -f /etc/crypttab ]]; then