Index: /branches/releng-9.0/nanobsd/tools/image
===================================================================
--- /branches/releng-9.0/nanobsd/tools/image	(revision 11049)
+++ /branches/releng-9.0/nanobsd/tools/image	(revision 11050)
@@ -40,36 +40,52 @@
 
   prompt_timeout=5
-  p_warn "Going to DEPLOY $img to $host: (8.X-RELEASE and 9.X-RELEASE) to 9.X RELEASE"
+  p_warn "Going to DEPLOY $img to $host: (8.X-RELEASE and 9.X-RELEASE) to 9.X-RELEASE"
+  p_warn "You will need to type the root password at least twice, consider using a key"
   $do_reboot && p_warn "AND will REBOOT the $host"
-  p_warn "Please do mind to use your ssh key else you be required to type the root"
-  p_warn "password AT MOST 5 times"
 
 
   p_warn "Press CTRL+C in $prompt_timeout seconds to CANCEL"
-  sleep $prompt_timeout
-
-  # Details and alive checkings
-  release=`ssh $host mount | grep 'ada0' && echo "9.0-RELEASE" || echo "PRE-9.0-RELEASE"` || exit 1
-  if [ $release = "9.0-RELEASE" ]; then
-    cat $img | ssh $host sh -x /tools/update || exit 1
+  # sleep $prompt_timeout
+
+  echo "# Trying to connect to $host"
+  release=`ssh $host 'uname -r'` || exit 1
+  echo "# Host has FreeBSD Release: $release, starting update"
+  if [ "$release" = "9.0-RELEASE" ]; then
+    cat $img | ssh $host /tools/update || exit 1
   else
     # Hack to make sure we update the fstab the right way when converting from
-    # 8.X-RELEASE to 9.X-RELEASE. ad0 naming changed to ada0.
-    P=`ssh $HOST df / | grep '1a ' && echo "p2" || echo "p1"` || exit 1
-    echo "# Updating partition $P"
-
-    cat $img | ssh $host sh -x /tools/update$P || exit 1
-
-    if [ "$P" = "p2" ]; then
-      cat <<EOF | ssh $HOST sh -x || exit 1
-mount -uwo noatime /dev/ad0s2a
-sed -i "" "s/ada0s1/ada0s2/" /mnt/conf/base/etc/fstab /mnt/etc/fstab
-umount 
+    # 8.X-RELEASE to 9.X-RELEASE. ad0 naming changed to ada0, secondly an
+    # specific update script had to be called.
+    command="/tmp/update$$"
+    cat > $command <<'EOF'
+# Write new image
+echo "FreeBSD Release : `uname -r`"
+echo "Active Partition: `df -H / | tail -1`"
+if [ "`uname -r`" = "9.0-RELEASE" ]; then 
+  echo "Error not valid update cycle!"
+  exit 1
+else
+  if df / | grep -q '1a ' ; then
+    echo  "New Partition   : /dev/ad0s2a"
+    echo /tools/updatep2
+
+    # Quirck to fix partitions
+    # mount -uwo noatime /dev/ad0s2a
+    # sed -i "" "s/ada0s1/ada0s2/" /mnt/conf/base/etc/fstab /mnt/etc/fstab
+    # umount 
+  else
+    echo  "New Partition   : /dev/ad0s1a"
+    echo /tools/updatep1
+  fi
+fi
 EOF
-    fi
+    cat $command | ssh $host "cat > $command" || exit 1
+    cat $img | ssh $host "sh $command" || exit 1
   fi
 
   if $do_reboot; then
-    ssh $host reboot
+    echo "# Reboot requested, press CTRL+C in $prompt_timeout seconds to cancel"
+    sleep $prompt_timeout
+    ssh $host reboot || exit 1
   fi
 }
