Updated cloner3 to support installing images from a disk partition with an ext4 LABEL=
[bootimage-initfs.git] / etc / cloner3 / installer.sh
index 7afc41d..26d83ef 100755 (executable)
@@ -57,6 +57,21 @@ then
        # revert back to our old directory
        cd - >> /tmp/stdout.log 2>>/tmp/stderr.log
 
+elif [ "${_srclabel}" != "" ]
+then
+       msg -n "Syncing data from ${ANSI_BLUE}LABEL=${_srclabel}${ANSI_DONE} image ${ANSI_BLUE}${_image}${ANSI_DONE}"
+
+       /usr/bin/rsync -avz --numeric-ids \
+               /mnt/media/${_image}/data/  /cloner/mnt/
+       if [ "$?" = "0" ]
+       then
+               ok_msg
+       else
+               fail_msg
+               clone_fatal_error "Failed to sync filesystem data from LABEL=${_srclabel}!"
+       fi
+
+
 # --------------
 #  A standard network RSYNC based install
 # --------------
@@ -131,6 +146,21 @@ then
                        fail_msg
                        fatal_error "Failed to sync node data from CD/DVD"
                fi
+       elif [ "${_srclabel}" != "" ]
+       then
+               header "Installing node specific data"
+               msg -n "Syning node ${ANSI_BLUE}${_node}${ANSI_DONE} data from LABEL=${_srclabel}"
+               rsync -avzc -I --numeric-ids --exclude /.valid \
+                       /cloner/setup/node/ /cloner/mnt \
+                       >> /tmp/stdout.log 2>> /tmp/stderr.log
+
+               if [ "$?" = "0" ]
+               then
+                       ok_msg
+               else
+                       fail_msg
+                       fatal_error "Failed to sync node data from LABEL=${_srclabel}"
+               fi
        else
                header "Installing node specific data"
                server_log "Syncing node ${_node} data from ${_server}" "${_node}"
@@ -154,6 +184,27 @@ then
        fi
 fi
 
+# mounting 
+header "Mounting proc & sys filesystem in deployed image"
+msg -n "Mounting /cloner/mnt/proc"
+mount -t proc none /cloner/mnt/proc
+if [ "$?" = "0" ]
+then
+       ok_msg
+else
+       fail_msg
+fi
+       
+msg -n "Mounting /cloner/mnt/sys"
+mount -t sysfs none /cloner/mnt/sys
+if [ "$?" = "0" ]
+then
+       ok_msg
+else
+       fail_msg
+fi
+       
+
 header "Installing bootloader"
 while read line
 do
@@ -232,8 +283,9 @@ do
                fi
        fi
 
+       GRUB2_CONFIG="/boot/grub2/grub.cfg"
        # if grub2 we generate a grub2 config file too
-       if [ "${GRUB2}" = "9" ]
+       if [ "${GRUB2}" = "1" ]
        then
                if [ -x /cloner/mnt/sbin/grub2-mkconfig ]
                 then
@@ -241,11 +293,15 @@ do
                 elif  [ -x /cloner/mnt/usr/sbin/grub2-mkconfig ]
                 then
                         GRUB_MKCONFIG="/usr/sbin/grub2-mkconfig "
+               elif [ -x /cloner/mnt/usr/sbin/grub-mkconfig ]
+               then
+                       GRUB_MKCONFIG="/usr/sbin/grub-mkconfig "
+                       GRUB2_CONFIG="/boot/grub/grub.cfg"
                fi
 
                msg -n "Creating grub2 config file"
                server_log "Creating grub2 config file" "${_node}"
-               chroot /cloner/mnt ${GRUB_MKCONFIG} -o /boot/grub2/grub.cfg >> /tmp/stdout.log 2>> /tmp/stderr.log
+               chroot /cloner/mnt ${GRUB_MKCONFIG} -o ${GRUB2_CONFIG} >> /tmp/stdout.log 2>> /tmp/stderr.log
                if [ "$?" = "0" ]
                then
                        ok_msg
@@ -278,6 +334,10 @@ sort -r -k2 /cloner/setup/filesystems \
 
 header "Unmounting filesystems"
 server_log "Unmounting filesystems" "${_node}"
+
+umount /cloner/mnt/proc
+umount /cloner/mnt/sys
+
 while read line
 do
        FS_DEVICE=`echo $line | awk '{print $1}'`