#!/bin/rc
echo -n cpu > /env/service
date > /env/boottime

# replace FILESERVER with the name of your file server
# here we start with kfs, your local disk file system
fileserver=vampira
# replace FACEDOM with the local domain to be used in the faces database
facedom=FACEDOM
# this is because some sites like cse.pse.edu check reverse
# maps, see changes in the rewrite file as well...
site=acl.lanl.gov
for(i in v f t m i L S)
	/bin/bind -a '#'^$i /dev >/dev/null >[2=1]
for(disk in /dev/sd??) {
	disk/fdisk -p $disk/data >$disk/ctl >[2]/dev/null
	for(part in $disk/plan9*)
		if(test -f $part)
			disk/prep -p $part >$disk/ctl >[2]/dev/null
}
if(test -f /dev/mousectl){
	switch($mouseport){
	case ps2 ps2intellimouse 0 1 2
		aux/mouse $mouseport

		# parse vgasize into fields
		vgasize=`{echo $vgasize}

		if(! ~ $monitor '' && ! ~ `{cat /dev/user} none){
			aux/vga -l $vgasize
			# turn off hardware acceleration until you know it's ok.
#		echo -n 'hwaccel off' >'#v/vgactl' >[2]/dev/null
		}
	}
}
if(test -f /dev/sd*/swap){
	x=(`{echo /dev/sd*/swap})
	swap $x(1) >/dev/null >[2=1]
}
if(test -f /dev/sd*/dos*){
	dossrv
	c:
}




# mount mail uncached
mount -c /srv/boot /n/termrc.tmp
bind -c /n/termrc.tmp/mail /mail
unmount /n/termrc.tmp


ndb/cs -f /lib/ndb/local
sysname=`{cat /dev/sysname}

# parallelism for mk
NPROC=`{wc -l /dev/sysstat}
NPROC=`{echo $NPROC|sed 's/ .*//'}

prompt=($sysname^'# ' '	')

# no blank for powerwall machines
if (~ $sysname pw[1-9] pw1[0-2] ) {
	echo -n 'blanktime 0' >'#v/vgactl' >[2]/dev/null
}

# for the powerwall machines + other secondary cpu servers
if (~ $sysname pw[1-9] pw1[0-2] bela p[1-9] p1[0-9] ps[1-8] ) {
	ip/ipconfig > /dev/null >[2=1]
	ndb/dns -r
	aux/timesync -f	
	auth/keyfs -wp -m /mnt/keys /adm/keys >/dev/null >[2=1]
	aux/listen -q -d /rc/bin/service.cpu -t /rc/bin/service.auth il
	aux/listen -q -d /rc/bin/service.cpu -t /rc/bin/service.auth tcp
}

# for the cpu/auth server only
if (~ $sysname plan9 ) {
	ip/ipconfig -x /net -g 172.16.82.254 ether /net/ether0 172.16.82.1 255.255.255.0
	ndb/dns -f /lib/ndb/local

	# uncomment the following for booting other systems
	ip/dhcpd -f /lib/ndb/local
	ip/tftpd 


	# run these instead of the above two if you are an auth server
	# also be sure to remove /rc/bin/service/il566 and tcp567
	#
	auth/keyfs -wp -m /mnt/keys /adm/keys >/dev/null >[2=1]
	aux/listen -q -d /rc/bin/service.plan9i -t /rc/bin/service.plan9i.auth il
	aux/listen -q -d /rc/bin/service.plan9i -t /rc/bin/service.plan9i.auth tcp

	#secondary interface
	ip/ipconfig -x /net.alt -g 128.165.147.254 ether /net.alt/ether1 128.165.147.177 255.255.255.0
	ndb/cs -x /net.alt -f /lib/ndb/external
	ndb/dns -rsx /net.alt -f /lib/ndb/external
	aux/timesync -n acl.lanl.gov
	aux/listen -d /rc/bin/service.plan9e -t /rc/bin/service.plan9e.auth /net.alt/il
	aux/listen -d /rc/bin/service.plan9e -t /rc/bin/service.plan9e.auth /net.alt/tcp
}
	#setup "other" filesystem used by printing
	srv il!vampira.plan9.lanl.net other
	mount -c /srv/other /n/vampiraother other
#	bind -c /n/vampiraother/mail /mail
#	bind -c /n/vampiraother/log /sys/log


	auth/cron >>/sys/log/cron >[2=1] &
if (~ $sysname pw[1-9] pw1[0-2]) {
	rio -i /usr/bootes/bin/rc/riostart
}
if (~ $sysname plan9 bela ) {
	rio
}
# for all cpuservers
aux/reboot
#
