#!/bin/bash
eval "set -- $(cat /proc/cmdline)"
for x; do
    case $x in
	ip=*)
	/usr/lib/klibc/bin/ipconfig -d ${x#ip=}
	;;
	mirror=*)
	export MIRROR=${x#mirror=}
	;;
	dist=*)
	export DIST=${x#dist=}
	;;
	arch=*)
	export ARCH=${x#arch=}
	;;
	imagesize=*)
	export FSSIZE=${x#imagesize=}
	;;
	noinstall=)
	exit 0
	;;
    esac
done

mount -t tmpfs none /var/log
mount -t tmpfs none /tmp

export TARGET=/dev/hda
export ARCH=${ARCH-amd64}
export IP=$(ifconfig eth0 | sed -n 's/.*inet addr:\([0-9\.]*\).*/\1/p')
export HOSTNAME=$(hostname)

/etc/init.d/udev start

# args passed through environment rather than as 7 positional args
/usr/sbin/sipb-xen-create-image

busybox poweroff
exit 0
