xref: /plan9/rc/bin/cpurc (revision 63afb9a5d3f910047231762bcce0ee49fed3d07c)
1#!/bin/rc
2# cpu server start up
3date > /env/boottime
4
5# mount points
6mntgen -s slashn && chmod 666 /srv/slashn
7
8# name translation, cs sets /dev/sysname
9ndb/cs
10sysname=`{cat /dev/sysname}
11
12# parallelism for mk
13NPROC = `{wc -l </dev/sysstat}
14
15# site-specific startup
16if(test -e /rc/bin/cpurc.local)
17	. /rc/bin/cpurc.local
18
19if (~ $#sysname 0 || ~ $sysname '') {
20	sysname = helix			# default
21	echo -n $sysname >/dev/sysname
22}
23prompt=($sysname^'# ' '	')
24
25# cpu-specific startup
26if(test -e /cfg/$sysname/cpurc)
27	. /cfg/$sysname/cpurc
28
29# start up internet if we don't already have an address
30if(! grep u /net/ipselftab | grep -sv 127.0.0.1)
31	ip/ipconfig
32if(! grep -s 127.0.0.1 /net/ipselftab)
33	ip/ipconfig loopback /dev/null 127.1
34
35# if we're not a server, start a dns resolver
36if(! test -e /srv/dns)
37	ndb/dns -r
38
39# If you are on an auth server, start these before listening:
40#
41# auth/keyfs -wp -m /mnt/keys /adm/keys >/dev/null >[2=1]
42# auth/cron >>/sys/log/cron >[2=1] &
43
44# keep other bootes processes from creating capabilities
45rm -f '#¤/caphash'
46
47# also rename some files on an auth server:
48#
49# if(! test -e /rc/bin/service.auth/tcp567){
50#	mv /rc/bin/service.auth/authsrv.il566 /rc/bin/service.auth/il566
51#	mv /rc/bin/service.auth/authsrv.tcp567 /rc/bin/service.auth/tcp567
52#	mv /rc/bin/service/il566 /rc/bin/service/_il566
53#	mv /rc/bin/service/tcp567 /rc/bin/service/_tcp567
54# }
55
56# netssh
57
58# start listeners if it hasn't already been done (dicey check)
59if(! netstat -n | grep -s 'tcp.*Listen.* (7|9|21|22|23|25|110|113|565|993|17007|17009|17010) .*')
60	aux/listen -q tcp
61# we don't use IL, maybe you do
62if(! netstat -n | grep -v 17008 | grep -s il.*Listen)
63	aux/listen -q il
64
65if(! ps|grep -s timesync) {
66	aux/timesync -n pool.ntp.org
67	if (test -e '#r/rtc') @ {
68		sleep 10			# let timesync correct the time
69		awk '{print $1}' /dev/time >'#r/rtc'	# fix hw clock
70	} &
71}
72
73# cpu-specific late startup
74if(test -e /cfg/$sysname/cpustart)
75	. /cfg/$sysname/cpustart
76
77# mode of /proc/*/ctl is inherited across rfork, and sets modes on
78# other /proc files, such as note, so let listen be killed.
79dontkill '^(ipconfig|factotum|mntgen|venti|fossil|cs|dns|reboot)$'
80
81# echo `{date} $sysname >>/sys/log/boot
82exit ''
83