Index: anches/releng-9.0/nanobsd/tools/edit-image.sh
===================================================================
--- /branches/releng-9.0/nanobsd/tools/edit-image.sh	(revision 10865)
+++ 	(revision )
@@ -1,58 +1,0 @@
-#!/bin/sh
-# Chroot into image to edit bits and pieces
-#
-# XXX: Error handing
-. $(dirname $0)/package-build.inc.sh
-
-BASEDIR=`dirname $0`
-if [ -n "$1" ]; then
-  IMG=$1
-else
-  CFG="${BASEDIR}/../cfg/nanobsd.wleiden"
-  
-  # Find object directory 
-  eval `grep '^NANO_NAME=' ${CFG}`
-  OBJDIR="/usr/obj/nanobsd.${NANO_NAME}"
-  IMG=${OBJDIR}/_.disk.full
-fi
-
-if [ ! -r "${IMG}" ]; then
-  p_err Source ${IMG} does not exists
-fi
-
-# Make sure we are root from this point on
-f_check_root
-
-
-MNT=`mktemp -d -t $(basename $0)`
-
-# If target nfs image is mounted somehow, bail out
-if mdconfig -l -v | grep -q "${IMG}"; then
-	MD=`mdconfig -l -v | grep "${IMG}" | cut -c -4`
-	p_err "'${IMG}' already mounted at '$MD'"
-	exit 1
-fi
-
-
-MD=`mdconfig -a -t vnode -f ${IMG}`
-mount /dev/${MD}s1a ${MNT}
-
-# Config files lives at /cfg  location
-mount /dev/${MD}s3 ${MNT}/cfg
-
-# Devfs for some special foo
-mount -t devfs devfs ${MNT}/dev
-
-# Try to fetch and store config
-p_info "Type exit when done"
-chroot ${MNT}
-p_info "Any changes are made permanent on image ${IMG}"
-
-# Clean up
-umount ${MNT}/cfg
-umount ${MNT}/dev
-umount ${MNT}
-mdconfig -d -u ${MD}
-rm -d ${MNT}
-
-
Index: /branches/releng-9.0/nanobsd/tools/image
===================================================================
--- /branches/releng-9.0/nanobsd/tools/image	(revision 10865)
+++ /branches/releng-9.0/nanobsd/tools/image	(revision 10871)
@@ -20,4 +20,5 @@
 # build force kernel            - Build NanoBSD and force rebuilding the kernel
 # build force world             - Build NanoBSD and force rebuilding world
+# edit				- Manually edit the image
 # config [for <node>]           - Configure image to be used for <node>
 # rebuild                       - Rebuild NanoBSD (aka force rebuilding all)
@@ -77,4 +78,35 @@
   # Try to fetch and store config
   chroot $mnt /tools/wl-config -d -n -m startup $node_name || exit 1
+}
+
+edit_image() {
+  img=$OBJDIR/_.disk.full
+
+  mnt=`mktemp -d -t $(basename $0)`
+  md=`mdconfig -a -t vnode -f $img`
+  
+  # Clean up when done
+  trap "umount $mnt/dev; umount $mnt/cfg; umount $mnt; mdconfig -d -u $md; rm -d $mnt" 0
+  trap "exit 1" 1 2 3 15
+
+  # Root filesystem
+  mount /dev/${md}s1a $mnt || exit 1
+
+  # /dev/null in chroot
+  mount -t devfs devfs ${mnt}/dev || exit 1
+  
+  # Config files lives at /cfg  location
+  mount /dev/${md}s3 $mnt/cfg || exit 1
+
+  # Nasty hack to set custom prompt
+  prompt='set prompt = "image# "'
+  echo $prompt >> $mnt/root/.cshrc
+  
+  p_info "Type exit when done"
+  chroot $mnt
+  p_info "Any changes are made permanent on image $img"
+  
+  # Unset prompt again
+  sed -I '' "/^$prompt$/d" $mnt/root/.cshrc
 }
 
@@ -213,4 +245,6 @@
   fi
   config_image $node_name
+elif [ "$1" = "edit" ]; then
+  edit_image
 else
   echo "Argument Error - '$1'"; exit 128
