#!/bin/rc

rfork e
if(! ~ $#* 2) {
	echo 'usage: setup.9fat /dev/sdC0/9fat plan9.ini' >[1=2]
	exit usage
}

. /rc/bin/pc/defs
fat=$1
ini=$2
if(! test -f  $fat) {
	echo fat partition not found >[1=2]
	exit fat
}
if(! test -f $ini) {
	echo plan9.ini not found >[1=2]
	exit ini
}

if(pc/isfat $fat) {
	echo 'Already a FAT partition in '^$fat^'; ream it?'
	prompt 'ream 9fat' y n
	switch($rd) {
	case n
		exit
	}
}

disk/format -r 2 -d -b /386/pbs $fat /386/9load /386/9pcdisk
mount -c /srv/dos /n/9fat $fat
cp $ini /n/9fat/plan9.ini
unmount /n/9fat
