From 0117b7d6b22b795e5d130ba3bdf3735f867d672e Mon Sep 17 00:00:00 2001 From: Giacomo Tesio Date: Tue, 29 Nov 2016 21:02:54 +0100 Subject: [PATCH] cfg/startup: start as terminal --- cfg/startup | 157 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 93 insertions(+), 64 deletions(-) diff --git a/cfg/startup b/cfg/startup index 4ed0424..9c25956 100755 --- a/cfg/startup +++ b/cfg/startup @@ -1,87 +1,116 @@ #!/cmd/rc -# cpu server start up -date > /env/boottime +# terminal startup +TIMESYNCARGS=(-rLa1000000) +NDBFILE=/cfg/ndb/local -# mount points mntgen -s slashn && chmod 666 /srv/slashn -# name translation, cs sets /dev/sysname -ndb/cs +# bind all likely devices (#S was bound in boot) +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} - -# parallelism for mk -NPROC = `{wc -l /dev/sysname } -prompt=($sysname^'# ' ' ') -# cpu-specific startup -if(test -e /cfg/$sysname/cpurc) - . /cfg/$sysname/cpurc +# machine specific startup (e.g., for devices not probed) +if(test -e /cfg/$sysname/termrc) + . /cfg/$sysname/termrc -# start up internet if we don't already have an address -if(! grep u /net/ipselftab | grep -sv 127.0.0.1) - ip/ipconfig -if(! grep -s 127.0.0.1 /net/ipselftab) - ip/ipconfig loopback /dev/null 127.1 +# start IP on the LAN, if not already configured. diskless terminals +# are already configured by now. It's commented out to avoid a long timeout +# on startup waiting for DHCP. +# +# 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 -if(! test -e /srv/dns) +# start dns if we have an internet +if(test -e /net/ipifc/0/ctl && ! test -e /srv/dns) ndb/dns -r -# If you are on an auth server, start these before listening: -# -# auth/keyfs -wp -m /mnt/keys /adm/keys >/dev/null >[2=1] -# auth/cron >>/sys/log/cron >[2=1] & +if(! ~ $terminal *vx32*){ + # start timesync if it isn't running and we weren't told not to + if(! ps|grep -s timesync) + if(! ~ $TIMESYNCARGS '') + ip/timesync $TIMESYNCARGS -# keep other bootes processes from creating capabilities -rm -f '#¤/caphash' + # add the loop-back medium + if(! grep -s 127.0.0.1 /net/ipselftab) + ip/ipconfig loopback /dev/null 127.1 -# also rename some files on an auth server: -# -# if(! test -e /arch/rc/cmd/service.auth/tcp567){ -# mv /arch/rc/cmd/service.auth/authsrv.il566 /arch/rc/cmd/service.auth/il566 -# 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 -# } + # set things up for vmware + if(! ~ `{cat /dev/user} none) + if(test -e /cmd/aux/vmware) + aux/vmware +} -# 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(! netstat -n | grep -s 'tcp.*Listen.* (7|9|21|22|23|25|110|113|565|993|17007|17009|17010) .*') - ip/listen -q tcp +if(~ $vgasize ask){ + echo -n 'vgasize [1024x768x8]: ' + vgasize=`{read} +} +if(~ $#vgasize 0) + vgasize=1024x768x8 -# TODO: Removed until awk works -#if(! ps|grep -s timesync) { -# aux/timesync -n pool.ntp.org -# if (test -e '#r/rtc') @ { -# sleep 10 # let timesync correct the time -# awk '{print $1}' /dev/time >'#r/rtc' # fix hw clock -# } & -#} +if(~ $monitor ask){ + echo -n 'monitor is [vesa]: ' + monitor=`{read} +} +if(~ $#monitor 0) + monitor=vesa -# cpu-specific late startup -if(test -e /cfg/$sysname/cpustart) - . /cfg/$sysname/cpustart +if(test -f /dev/mousectl){ + switch($mouseport){ + 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 -# other /proc files, such as note, so let listen be killed. -#dontkill '^(ipconfig|factotum|mntgen|venti|fossil|cs|dns|reboot)$' +# usb listener +/arch/rc/aux/usb/usbrc -ip/listen1 -t -v tcp!*!1522 /cmd/hmi/pipeconsole /cmd/rc -m /arch/rc/lib/rcmain -i & -if(test ! -e '#s/comconsole') - hmi/comconsole '#t/eia0' /cmd/rc -m/arch/rc/lib/rcmain -i & +if (test -f /dev/apm) + aux/apm -echo 'key proto=p9sk1 dom=jehanne user=glenda !password=demodemo' >/mnt/factotum/ctl -ip/listen1 -t tcp!*!17010 /cmd/cpu -R & - -# echo `{date} $sysname >>/sys/log/boot -exit '' +dontkill '^(ipconfig|factotum|mntgen|fossil|cs|dns|listen|reboot)$'