source: hybrid/branches/releng-9.0/nanobsd/tools/edit-image.sh@ 10804

Last change on this file since 10804 was 10759, checked in by rick, 13 years ago

Make sure to mount a /dev to allow more easier hacking and playing around.

Related-To: nodefactory:ticket:144

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
File size: 1.1 KB
Line 
1#!/bin/sh
2# Chroot into image to edit bits and pieces
3#
4# XXX: Error handing
5. $(dirname $0)/package-build.inc.sh
6
7BASEDIR=`dirname $0`
8if [ -n "$1" ]; then
9 IMG=$1
10else
11 CFG="${BASEDIR}/../cfg/nanobsd.wleiden"
12
13 # Find object directory
14 eval `grep '^NANO_NAME=' ${CFG}`
15 OBJDIR="/usr/obj/nanobsd.${NANO_NAME}"
16 IMG=${OBJDIR}/_.disk.full
17fi
18
19if [ ! -r "${IMG}" ]; then
20 p_err Source ${IMG} does not exists
21fi
22
23# Make sure we are root from this point on
24f_check_root
25
26
27MNT=`mktemp -d -t $(basename $0)`
28
29# If target nfs image is mounted somehow, bail out
30if mdconfig -l -v | grep -q "${IMG}"; then
31 MD=`mdconfig -l -v | grep "${IMG}" | cut -c -4`
32 p_err "'${IMG}' already mounted at '$MD'"
33 exit 1
34fi
35
36
37MD=`mdconfig -a -t vnode -f ${IMG}`
38mount /dev/${MD}s1a ${MNT}
39
40# Config files lives at /cfg location
41mount /dev/${MD}s3 ${MNT}/cfg
42
43# Devfs for some special foo
44mount -t devfs devfs ${MNT}/dev
45
46# Try to fetch and store config
47p_info "Type exit when done"
48chroot ${MNT}
49p_info "Any changes are made permanent on image ${IMG}"
50
51# Clean up
52umount ${MNT}/cfg
53umount ${MNT}/dev
54umount ${MNT}
55mdconfig -d -u ${MD}
56rm -d ${MNT}
57
58
Note: See TracBrowser for help on using the repository browser.