cfg/startup: start as terminal

This commit is contained in:
Giacomo Tesio 2016-11-29 21:02:54 +01:00
parent 9bceb6b04e
commit 0117b7d6b2
1 changed files with 93 additions and 64 deletions

View File

@ -1,87 +1,116 @@
#!/cmd/rc #!/cmd/rc
# cpu server start up # terminal startup
date > /env/boottime TIMESYNCARGS=(-rLa1000000)
NDBFILE=/cfg/ndb/local
# mount points
mntgen -s slashn && chmod 666 /srv/slashn mntgen -s slashn && chmod 666 /srv/slashn
# name translation, cs sets /dev/sysname # bind all likely devices (#S was bound in boot)
ndb/cs for(i in f t m v L P u U '$' Σ κ)
/cmd/bind -a '#'^$i /dev >/dev/null >[2=1]
rm -f /env/i
# set up any partitions
diskparts
# start up local swapping
disk=`{ls /dev/sd*/swap >[2]/dev/null}
if (! ~ $#disk 0)
swap $disk(1) >/dev/null >[2=1]
rm /env/disk
# we do this before we have a name. we may need to do network
# setup so that we can get a name.
if(test -e /arch/rc/cmd/termrc.local)
. /arch/rc/cmd/termrc.local
# cs sets sysname (termrc.local may already have started it so check)
if(! test -e /srv/cs && ! test -e /net/cs)
ndb/cs -f $NDBFILE
sysname=`{cat /dev/sysname} sysname=`{cat /dev/sysname}
# parallelism for mk
NPROC = `{wc -l </dev/sysstat}
# site-specific startup
if(test -e /arch/rc/cmd/cpurc.local)
. /arch/rc/cmd/cpurc.local
if (~ $#sysname 0 || ~ $sysname '') { if (~ $#sysname 0 || ~ $sysname '') {
sysname = jehanne # default sysname = jehanne # default
echo -n $sysname >/dev/sysname echo -n $sysname >/dev/sysname
} }
prompt=($sysname^'# ' ' ')
# cpu-specific startup # machine specific startup (e.g., for devices not probed)
if(test -e /cfg/$sysname/cpurc) if(test -e /cfg/$sysname/termrc)
. /cfg/$sysname/cpurc . /cfg/$sysname/termrc
# start up internet if we don't already have an address # start IP on the LAN, if not already configured. diskless terminals
if(! grep u /net/ipselftab | grep -sv 127.0.0.1) # are already configured by now. It's commented out to avoid a long timeout
ip/ipconfig # on startup waiting for DHCP.
if(! grep -s 127.0.0.1 /net/ipselftab) #
ip/ipconfig loopback /dev/null 127.1 # If your site provides DHCP service,
#
#if(! test -e /net/ipifc/0/ctl)
# ip/ipconfig
#
# Otherwise, see /cfg/$sysname/termrc (/cfg/example/termrc is an example).
# if we're not a server, start a dns resolver # start dns if we have an internet
if(! test -e /srv/dns) if(test -e /net/ipifc/0/ctl && ! test -e /srv/dns)
ndb/dns -r ndb/dns -r
# If you are on an auth server, start these before listening: if(! ~ $terminal *vx32*){
# # start timesync if it isn't running and we weren't told not to
# auth/keyfs -wp -m /mnt/keys /adm/keys >/dev/null >[2=1] if(! ps|grep -s timesync)
# auth/cron >>/sys/log/cron >[2=1] & if(! ~ $TIMESYNCARGS '')
ip/timesync $TIMESYNCARGS
# keep other bootes processes from creating capabilities # add the loop-back medium
rm -f '#¤/caphash' if(! grep -s 127.0.0.1 /net/ipselftab)
ip/ipconfig loopback /dev/null 127.1
# also rename some files on an auth server: # set things up for vmware
# if(! ~ `{cat /dev/user} none)
# if(! test -e /arch/rc/cmd/service.auth/tcp567){ if(test -e /cmd/aux/vmware)
# mv /arch/rc/cmd/service.auth/authsrv.il566 /arch/rc/cmd/service.auth/il566 aux/vmware
# mv /arch/rc/cmd/service.auth/authsrv.tcp567 /arch/rc/cmd/service.auth/tcp567 }
# mv /arch/rc/cmd/service/il566 /arch/rc/cmd/service/_il566
# mv /arch/rc/cmd/service/tcp567 /arch/rc/cmd/service/_tcp567
# }
# netssh # query user if terminal isn't adequately configured yet
if(~ $mouseport ask){
echo -n 'mouseport is (ps2, ps2intellimouse, 0, 1, 2)[ps2]: '
mouseport=`{read}
}
if(~ $#mouseport 0)
mouseport=ps2
# start listeners if it hasn't already been done (dicey check) if(~ $vgasize ask){
if(! netstat -n | grep -s 'tcp.*Listen.* (7|9|21|22|23|25|110|113|565|993|17007|17009|17010) .*') echo -n 'vgasize [1024x768x8]: '
ip/listen -q tcp vgasize=`{read}
}
if(~ $#vgasize 0)
vgasize=1024x768x8
# TODO: Removed until awk works if(~ $monitor ask){
#if(! ps|grep -s timesync) { echo -n 'monitor is [vesa]: '
# aux/timesync -n pool.ntp.org monitor=`{read}
# if (test -e '#r/rtc') @ { }
# sleep 10 # let timesync correct the time if(~ $#monitor 0)
# awk '{print $1}' /dev/time >'#r/rtc' # fix hw clock monitor=vesa
# } &
#}
# cpu-specific late startup if(test -f /dev/mousectl){
if(test -e /cfg/$sysname/cpustart) switch($mouseport){
. /cfg/$sysname/cpustart case ps2 ps2intellimouse 0 1 2
hmi/mouse $mouseport
ms &
# parse vgasize into fields
vgasize=`{echo $vgasize}
if(! ~ $"monitor '' && ! ~ `{cat /dev/user} none) {
hmi/realemu
hmi/vga -m $monitor -l $vgasize
}
if(~ $accupoint 1)
pipefile -dr /cmd/aux/accupoint /dev/mouse
rio -i /lib/riostart
}
}
# mode of /proc/*/ctl is inherited across rfork, and sets modes on # usb listener
# other /proc files, such as note, so let listen be killed. /arch/rc/aux/usb/usbrc
#dontkill '^(ipconfig|factotum|mntgen|venti|fossil|cs|dns|reboot)$'
ip/listen1 -t -v tcp!*!1522 /cmd/hmi/pipeconsole /cmd/rc -m /arch/rc/lib/rcmain -i & if (test -f /dev/apm)
if(test ! -e '#s/comconsole') aux/apm
hmi/comconsole '#t/eia0' /cmd/rc -m/arch/rc/lib/rcmain -i &
echo 'key proto=p9sk1 dom=jehanne user=glenda !password=demodemo' >/mnt/factotum/ctl dontkill '^(ipconfig|factotum|mntgen|fossil|cs|dns|listen|reboot)$'
ip/listen1 -t tcp!*!17010 /cmd/cpu -R &
# echo `{date} $sysname >>/sys/log/boot
exit ''