fix uuid detection to search through all devices that match the UUID
Kyle Sheumaker [Mon, 24 Sep 2018 22:47:46 +0000 (17:47 -0500)]
etc/cloner3/uuid_fix.sh

index cab39e6..847ec31 100755 (executable)
@@ -29,18 +29,24 @@ old_uuid_by_device() {
 }
 
 new_uuid_by_old_uuid() {
-       UUID=$1
-
-       # grep for the UUID and get the last one
-       RESULT=$(grep "UUID=\"${UUID}\"" ${ORG_UUID_FILE} | tail -1)
-       SRC_DEVICE=$(echo ${RESULT} | cut -d":" -f1)
-
-       NEW_UUID=$(new_uuid_by_device ${SRC_DEVICE})
-
-       echo ${NEW_UUID}
+        UUID=$1
+
+        # grep for the UUID and get the last one
+        grep "UUID=\"${UUID}\"" ${ORG_UUID_FILE} > /tmp/uuid_search.tmp
+
+        FOUND_UUID=""
+        while read line
+        do
+                SRC_DEVICE=$(echo ${line} | cut -d":" -f1)
+                NEW_UUID=$(new_uuid_by_device ${SRC_DEVICE})
+                if [ "${NEW_UUID}" != "" ]
+                then
+                        FOUND_UUID=${NEW_UUID}
+                fi
+        done < /tmp/uuid_search.tmp
+        echo ${FOUND_UUID}
 }
 
-
 convert_fstab() {
 
        SRC=$1