Updated uuid fix for bug fixes
Kyle Sheumaker [Fri, 21 Sep 2018 19:54:25 +0000 (14:54 -0500)]
etc/cloner3/uuid_fix.sh

index b484356..9145cc3 100755 (executable)
@@ -56,7 +56,7 @@ convert_fstab() {
                then
                        OLD_UUID=$(echo ${DEVICE} | sed 's/UUID=//' | sed 's/\"//g')
 
-                       msg -n "Looking for replacement for ${ANSI_BLUE}${OLD_UUID}${ANSI_DONE}"
+                       msg -n "Looking for replacement for ${ANSI_BLUE}${OLD_UUID}${ANSI_DONE} "
                        NEW_UUID=$(new_uuid_by_old_uuid ${OLD_UUID})
                        if [ "${NEW_UUID}" = "" ]
                        then
@@ -74,13 +74,30 @@ convert_fstab() {
        done < ${SRC}
 }
 
+if [ -e ${ORIG_UUID_FILE} ]
+then
+
+       header "Updating UUIDs in /etc/fstab"
+       convert_fstab /cloner/mnt/etc/fstab /tmp/fstab.converted
+
+       if [ "$?" != "0" ]
+       then
+               clone_fatal_error "Can't convert UUIDs from old fstab to new."
+       fi
+
+       if [ -e /tmp/fstab.converted ]
+       then
+               mv /tmp/fstab.converted /cloner/mnt/etc/fstab
+       fi
+fi
+
 header "Updating mdadm.conf with new UUIDs"
 if [ -e "/cloner/mnt/etc/mdadm.conf" ]
 then
        
        msg -n "Updating configuration file ${ANSI_BLUE}/etc/mdadm.conf${ANSI_DONE}"
        server_log "Updating /etc/mdadm.conf configuration" "${_node}"
-       grep -v "^ARRAY" /cloner/mnt/etc/mdadm.conf" > /tmp/new-mdadm.conf
+       grep -v "^ARRAY" /cloner/mnt/etc/mdadm.conf > /tmp/new-mdadm.conf
        echo "### AUTOGENERATED BY CLONER ON `date`" >> /tmp/new-mdadm.conf
        mdadm --detail --scan >> /tmp/new-mdadm.conf
        mv /tmp/new-mdadm.conf /cloner/mnt/etc/mdadm.conf
@@ -90,7 +107,7 @@ then
        then
                for kver in `ls -1 /cloner/mnt/lib/modules`
                do
-                       msg -n "Updating dracut for kernel ${ANSI_BLUE}${kver}${ANSI_DONE}
+                       msg -n "Updating dracut for kernel ${ANSI_BLUE}${kver}${ANSI_DONE}"
                        chroot /cloner/mnt /usr/sbin/dracut -f --kver=${kver} \
                                >> /tmp/stdout.log 2> /tmp/stderr.log
 
@@ -105,19 +122,3 @@ then
 
 fi
 
-if [ ! -e ${ORIG_UUID_FILE} ]
-then
-       exit 0
-fi
-
-header_msg "Updating UUIDs in /etc/fstab"
-convert_fstab /cloner/mnt/etc/fstab /tmp/fstab.converted
-if [ "$?" != "0" ]
-then
-       clone_fatal_error "Can't convert UUIDs from old fstab to new."
-fi
-if [ -e /tmp/fstab.converted ]
-       mv /tmp/fstab.converted /cloner/mnt/etc/fstab
-fi
-
-return 0