123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- #!/bin/rc
- # cpu server startup
- boottime=`{date}
- boottime=$"boottime
- echo cpurc starting $boottime
- # cs sets /dev/sysname
- ndb/cs -4 # bloody google's ipv6 mail sending rules
- sysname=`{cat /dev/sysname}
- # get rid of need for dirs in /n
- mntgen -s slashn && chmod 666 /srv/slashn
- # parallelism for mk
- NPROC = `{wc -l </dev/sysstat}
- # enable usb keyboard, among other usb devices
- if (! test -e /srv/usb && test -e '#u/usb')
- usb/usbd
- # site-specific startup
- listener=()
- if(test -e /rc/bin/cpurc.local)
- . /rc/bin/cpurc.local
- # sysname sanity checks
- if (~ $#sysname 0 || ~ $sysname '') {
- sysname = helix # default
- echo -n $sysname >/dev/sysname
- }
- prompt=($sysname^'# ' ' ')
- # cpu-specific startup
- # if it runs aux/listen, it must first run ndb/dns.
- if(! test -e '/env/*envloaded')
- . loadcfgpxe
- if(test -e /cfg/$sysname/cpurc)
- . /cfg/$sysname/cpurc
- # if we're not a server, start a dns resolver
- if(! test -e /srv/dns && ! test -e /env/dns) {
- echo -n dns...
- ndb/dns & # -rF
- }
- # reboot cpu server if we lose the file server
- if (! ~ $sysname fs)
- aux/reboot &
- # don't turn on dong's tcp port hog defense; our firewall drops
- # the out-of-sequence keepalives it uses, thus dropping
- # inside-to-outside connections after 5 minutes.
- #if( test -e /net/tcp/clone)
- # echo -n tcpporthogdefense on > /net/tcp/0/ctl
- # keep other bootes processes from creating capabilities (optional)
- rm '#¤/caphash' > /dev/null >[2=1]
- # start up internet if we don't already have an address
- if(! grep u /net/ipselftab | grep -sv 127.0.0.1) {
- echo -n ipconfig for ip...
- ip/ipconfig
- }
- if not if (~ $sysname pi) # in case on net 10 and answered by fw or airport extreme
- ip/ipconfig
- if(! grep -s 127.0.0.1 /net/ipselftab) {
- echo -n loopbacks...
- ip/ipconfig loopback /dev/null 127.1
- ip/ipconfig loopback /dev/null ::1 /128
- }
- # start listeners if it hasn't already been done (dicey check; auth can be slow)
- if(! netstat -n | grep -s '^tcp.*Listen.* (7|9|21|22|23|25|110|113|565|993|17007|17009|17010|17013) .*' &&
- ! ~ $listener yes) {
- echo -n listen...
- aux/listen -q &
- sleep 2
- }
- if(! ps|grep -s timesync) {
- echo -n timesync...
- starttimesync &
- sleep 2
- }
- # cpu-specific late startup
- if(test -e /cfg/$sysname/cpustart)
- . /cfg/$sysname/cpustart
- # prevent killing specific processes when out of memory.
- # processes started via listen must be killable, so exclude listen.
- dontkill '^(ipconfig|factotum|mntgen|venti|fossil|cs|dns|reboot)$' &
- # log boot and kernel information
- kern=`{ls -ld `{kern}}
- echo $"boottime $sysname $terminal $"kern >>/sys/log/boot
- ls -l /srv/boot | sed -e 's/.* 0 /kernel built: /' -e 's; /srv/boot;;'
- echo $terminal $"kern
- echo -n `{date} ' '; uptime
- echo collect kmesg...
- kmesg.boot &
- exit ''
|