userinstall

Annotated uml-make-image

32:deda6d07bdc4
2011-07-12 Paul Boddie Added a script which controls access to the UML image. Reorganised the image making script to delegate work to other scripts using the image access script.
paul@31 1
#!/bin/sh
paul@31 2
paul@31 3
# Configuration:
paul@31 4
if [ -e userinstall-defaults-uml ]; then
paul@31 5
        . "$PWD/userinstall-defaults-uml"
paul@31 6
elif [ -e /etc/default/userinstall-uml ]; then
paul@31 7
        . /etc/default/userinstall-uml
paul@31 8
else
paul@31 9
        echo "No defaults found for userinstall (UML)." 1>&2
paul@31 10
        exit 1
paul@31 11
fi
paul@31 12
paul@31 13
if [ ! "$1" ]; then
paul@31 14
	echo "Need a root image size in GB." 1>&2
paul@31 15
	exit 1
paul@31 16
fi
paul@31 17
paul@31 18
if [ ! "$2" ]; then
paul@31 19
	echo "Need a swap image size in MB." 1>&2
paul@31 20
	exit 1
paul@31 21
fi
paul@31 22
paul@31 23
IMAGESIZE=$1
paul@31 24
SWAPSIZE=$2
paul@31 25
THISDIR=`dirname "$0"`
paul@31 26
paul@31 27
if [ ! -e "$PACKAGEROOT" ]; then
paul@31 28
	echo "A package root must first be made using user-setup." 1>&2
paul@31 29
	exit 1
paul@31 30
fi
paul@31 31
paul@31 32
if [ ! "$IMAGEDIR" ]; then
paul@31 33
	echo "An image directory must be defined." 1>&2
paul@31 34
	exit 1
paul@31 35
fi
paul@31 36
paul@31 37
echo "Making the filesystem with size ${IMAGESIZE}GB..."
paul@31 38
dd if=/dev/zero of=$IMAGE bs=1024 count=1 seek=$(($IMAGESIZE*1024*1024-1024))
paul@31 39
mkfs.ext3 $IMAGE
paul@31 40
paul@31 41
echo "Making the swap file with size ${SWAPSIZE}MB..."
paul@31 42
dd if=/dev/zero of=$SWAPIMAGE bs=1M count=$SWAPSIZE
paul@31 43
paul@32 44
# Image population activities.
paul@31 45
paul@32 46
"$THISDIR/uml-access-image" "$THISDIR/uml-populate-image"
paul@32 47
"$THISDIR/uml-access-image" "$THISDIR/uml-make-network"