[ previous ] [ next ] [ threads ]
 
 From:  Peter Curran <lists at closeconsultants dot com>
 To:  Jeb Campbell <jebc at c4solutions dot net>, m0n0wall at lists dot m0n0 dot ch
 Subject:  Re: [m0n0wall] Script to work on .img files (must have FreeBSD box)
 Date:  Wed, 26 Jan 2005 19:07:58 +0000
Jeb

This won't work on 4.x use vnconfig instead as shown....


On Wednesday 26 January 2005 16:55, Jeb Campbell wrote:
> This was tested on FreeBSD 5.3 (I think it would work on 4.x).
>
> This is a post of the contents of the script and it is also attached:
>
> #/bin/sh
> # Instructions (as root)-- make a directory and put this script inside it.
> # chmod +x workon.sh
> # Download or copy an image file into the directory
> # ./workon.sh wrap-1.11.img
> # This will start your SHELL inside the mounted image.
> # When you are done, type exit.  This exits your SHELL and lets
> # this script proceed (umount, gzip, etc).
> # The image file now contains your changes (and is no longer signed).
>
> # Set your shell -- /bin/csh will always work
> SHELL=/usr/local/bin/bash
> [ ! -x $SHELL ] && echo "${SHELL} not executable (try /bin/csh)" && exit 1
>
> # No more edits
>
> IMAGE=$1
>
> # Make dirs
> mkdir -p tmp; mkdir -p mnt1; mkdir -p mnt2
>
> # Decompress IMAGE
> gzip -dc < ${IMAGE} > tmp/${IMAGE}
>
> # Mount IMAGE
> mdconfig -a -t vnode -f tmp/${IMAGE} -u 90

vnconfig -s labels -c vn0 tmp/${IMAGE}

> mount /dev/md90 mnt1

mount /dev/vn0c mnt1

>
> # Decompress mfsroot
> gzip -dc < mnt1/mfsroot.gz > tmp/${IMAGE}-mfsroot
>
> # Mount mfsroot
> mdconfig -a -t vnode -f tmp/${IMAGE}-mfsroot -u 91

vnconfig -s labels -c vn1 tmp/${IMAGE}-mfsroot


> mount /dev/md91 mnt2

mount /dev/vn1c mnt2

>
> # cd to 2nd mount and exec SHELL
> cd mnt2
> ${SHELL}
>
> # SHELL has exited -- clean up and compress
> for vtmp in `find . | grep '~$'`; do
> 	echo Removing: ${vtmp}
> 	rm -f ${vtmp}
> done
> cd ../
>
> umount mnt2
> mdconfig -d -u 91
 vnconfig -u vn1

>
> gzip -c9 < tmp/${IMAGE}-mfsroot > mnt1/mfsroot.gz
> rm -f tmp/${IMAGE}-mfsroot
>
> umount mnt1
> mdconfig -d -u 90
vnconfig -u vn0
>
> gzip -c9 < tmp/${IMAGE} > ${IMAGE}
> rm -f tmp/${IMAGE}

-- 
----------------------------------------------------------------------------
Peter Curran				  Leveraging Internet Technology
Close Consultants			       for Businesses
p: +44-1225-463700			 
f: +44-1225-463705			  
e: peter at closeconsultants dot com		  
sip: peter at closeconsultants dot com 


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.