#!/bin/sh

# /etc/inittab: "tty21::respawn:/bin/su -c '/boot/vm-uml 1 /boot/guests/slitaz.img 2 512m' nobody"
n=${1:-0}
tap=tap$n
args="rw root=/dev/null"
dev="initrd=$(ls -r /boot/rootfs*.gz | sed q)"
if [ -n "$2" ]; then
	args="ro root=620${3:-1} screen=text sound=noconf"
	dev="ubd0=$2"
fi

cd $(dirname $0)
ifconfig $tap 192.168.$n.1
./linux-uml-@VERSION@ $dev mem=${4:-512m} fakehd fake_ide ubd=3 con0=fd:0,fd:1 \
	con=pts ssl=pts eth0=tuntap,$tap,fe:f0:00:00:00:0$n,192.168.$n.1 \
	$args cpuinfo=$(sed '/model name/!d;s/.*: //;s/ /_/g;q' /proc/cpuinfo)
