diff --git a/clone/clone b/clone/clone index 1fa991f..3d77d28 100755 --- a/clone/clone +++ b/clone/clone @@ -51,7 +51,7 @@ step1(){ mounted_partitions=$( cat /proc/mounts | awk '{print $1}' | grep "$DEV" ); # if nothing found -> next step - ls ${DEV}2 > /dev/null 2>&1 || $( echo "<<< done" && step2 ); + ls ${DEV}2 > /dev/null 2>&1 || (echo "<<< done"; step2); for mounted in $mounted_partitions; do @@ -111,12 +111,12 @@ step3(){ echo " - using gunzip"; ( dd if=$IMAGE_FILE | pv -s $(du -bs $IMAGE_FILE | gunzip | awk '{print $1}') | sudo dd of=$DEV bs=4M ) \ - || $( echo "<<< error: dd command failed" && exit ); + || (echo "<<< error: dd command failed"; exit); else ( dd if=$IMAGE_FILE | pv -s $(du -bs $IMAGE_FILE | awk '{print $1}') | sudo dd of=$DEV bs=4M ) \ - || $( echo "<<< error: dd command failed" && exit ); + || (echo "<<< error: dd command failed"; exit); fi; @@ -137,10 +137,18 @@ step3(){ step4(){ echo -e "\n>>> [4] Mounting partition ${DEV}2"; - test ! -f ${DEV}2 && ( echo "<<< error: device ${DEV}2 does not exist" && exit ); + count=0; + + while [ $count -lt 5 ] && [ ! -e ${DEV}2 ]; do + echo " * Waiting for ${DEV}2 to be ready (remaining `expr 5 - $count`s)"; + count=`expr $count + 1`; + sleep 1; + done; + + test $count -eq 5 && (echo "<<< error: can't find device ${DEV}2"; exit 1); # [1] Mount device partition - sudo mount ${DEV}2 /mnt || $( echo "<<< error: can't mount" && exit ); + sudo mount ${DEV}2 /mnt || (echo "<<< error: can't mount"; exit 1); echo "<<< done";