Updated cloner3 to support installing images from a disk partition with an ext4 LABEL=
Kyle Sheumaker [Fri, 22 Apr 2016 15:45:54 +0000 (10:45 -0500)]
etc/cloner3/detect_label.sh [new file with mode: 0755]
etc/cloner3/get_setup.sh
etc/cloner3/installer.sh
etc/cloner3/startup.sh

diff --git a/etc/cloner3/detect_label.sh b/etc/cloner3/detect_label.sh
new file mode 100755 (executable)
index 0000000..8cfcbd8
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/ash
+
+. /etc/library.sh
+. /etc/cloner3/include.sh
+. /tmp/cmdline.dat
+
+header "Trying to locate the srclabel '${_srclabel}' device"
+
+msg -n "Mounting ${ANSI_BLUE}${i}${ANSI_DONE} on /mnt/media"
+mount -t ext4 LABEL=${_srclabel} /mnt/media >> /tmp/stdout.log \ 
+       2>> /tmp/stderr.log
+
+if [ "$?" = "0" ]
+then
+       ok_msg
+       break
+else
+       fatal_error "Can't mount device LABEL=${_srclabel}"
+fi
index c8fe38a..d5c945c 100755 (executable)
@@ -24,6 +24,8 @@ write_client_conf () {
 if [ "${_srcpath}" != "" ]
 then
        header "Copying setup information from ${_srcpath}"
+elif [ "${_srclabel}" != ""]
+       header "Using setup from LABEL=${_srclabel}"
 else
        if [ "${_server}" = "" ]
        then
@@ -108,6 +110,35 @@ then
                fi
        fi
 
+elif [ "${_srclabel}" != "" ]
+then
+
+       msg -n "Copying setup data for image ${_image} from LABEL=${_srclabel}"
+       rsync -v /mnt/media/${_image}/* /cloner/setup \
+               >> /tmp/stdout.log 2>> /tmp/stderr.log
+       if [ "$?" = 0 ]
+       then
+               ok_msg
+       else
+               fail_msg
+       
+               clone_fatal_error "Can't get setup information from /mnt/media/${_image}"
+       fi
+
+       if [ "${_node}" != "" ]
+       then
+               msg -n "Copying node specific data for image=${_image} node=${_node}"
+               cp -av /mnt/media/${_image}/nodes/${_node}/* /cloner/setup/node \
+                       >> /tmp/stdout.log 2>> /tmp/stderr.log
+               if [ "$?" = 0 ]
+               then
+                       ok_msg
+               else
+                       fail_msg
+                       clone_fatal_error "Can't get node specific information from /mnt/media"
+               fi
+       fi
+
 # we are installing from the network
 else
        msg -n "Downloading setup data for image ${_image}"
index da31b5d..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}"
index f0f843c..5bbe539 100755 (executable)
@@ -11,6 +11,11 @@ then
        /etc/cloner3/detect_cd.sh
 fi
 
+if [ "${_srclabel}" != "" ]
+then
+       /etc/cloner3/detect_label.sh
+fi
+
 /etc/cloner3/get_setup.sh
 if [ $? != 0 ]; then
        exit 1