xref: /plan9/rc/bin/termrc (revision e9b54818716d7e3e58c57fc2d88eb8b05defef08)
1#!/bin/rc
2# terminal startup
3TIMESYNCARGS=(-rLa1000000)
4NDBFILE=/lib/ndb/local
5
6mntgen -s slashn && chmod 666 /srv/slashn
7
8# bind all likely devices (#S was bound in boot)
9for(i in f t m v L P u U '$' Σ κ)
10	/bin/bind -a '#'^$i /dev >/dev/null >[2=1]
11
12# set up any partitions
13diskparts
14
15# start up local swapping
16disk=`{ls /dev/sd*/swap >[2]/dev/null}
17if (! ~ $#disk 0)
18	swap $disk(1) >/dev/null >[2=1]
19rm /env/disk
20
21# we do this before we have a name.  we may need to do network
22# setup so that we can get a name.
23if(test -e /rc/bin/termrc.local)
24	. /rc/bin/termrc.local
25
26# cs sets sysname (termrc.local may already have started it so check)
27if(! test -e /srv/cs && ! test -e /net/cs)
28	ndb/cs -f $NDBFILE
29sysname=`{cat /dev/sysname}
30if (~ $#sysname 0 || ~ $sysname '') {
31	sysname = gnot			# default
32	echo -n $sysname >/dev/sysname
33}
34
35# machine specific startup (e.g., for devices not probed)
36if(test -e /cfg/$sysname/termrc)
37	. /cfg/$sysname/termrc
38
39# start IP on the LAN, if not already configured.  diskless terminals
40# are already configured by now.  It's commented out to avoid a long timeout
41# on startup waiting for DHCP.
42#
43# If your site provides DHCP service,
44#
45#if(! test -e /net/ipifc/0/ctl)
46#	ip/ipconfig
47#
48# Otherwise, see /cfg/$sysname/termrc (/cfg/example/termrc is an example).
49
50# start dns if we have an internet
51if(test -e /net/ipifc/0/ctl && ! test -e /srv/dns)
52	ndb/dns -r
53
54if(! ~ $terminal *vx32*){
55	# start timesync if it isn't running and we weren't told not to
56	if(! ps|grep -s timesync)
57		if(! ~ $TIMESYNCARGS '')
58			aux/timesync $TIMESYNCARGS
59
60	# add the loop-back medium
61	if(! grep -s 127.0.0.1 /net/ipselftab)
62		ip/ipconfig loopback /dev/null 127.1
63
64	# set things up for vmware
65	if(! ~ `{cat /dev/user} none)
66		if(test -e /bin/aux/vmware)
67			aux/vmware
68}
69
70# query user if terminal isn't adequately configured yet
71if(~ $mouseport ask){
72	echo -n 'mouseport is (ps2, ps2intellimouse, 0, 1, 2)[ps2]: '
73	mouseport=`{read}
74	if(~ $#mouseport 0)
75		mouseport=ps2
76}
77if(~ $vgasize ask){
78	echo -n 'vgasize [640x480x8]: '
79	vgasize=`{read}
80	if(~ $#vgasize 0)
81		vgasize=640x480x8
82}
83if(~ $monitor ask){
84	echo -n 'monitor is [xga]: '
85	monitor=`{read}
86	if(~ $#monitor 0)
87		monitor=xga
88}
89if(test -f /dev/mousectl){
90	switch($mouseport){
91	case ps2 ps2intellimouse 0 1 2
92		aux/mouse $mouseport
93		# parse vgasize into fields
94		vgasize=`{echo $vgasize}
95		if(! ~ $"monitor '' && ! ~ `{cat /dev/user} none)
96			aux/vga -l $vgasize
97		if(~ $accupoint 1)
98			pipefile -dr /bin/aux/accupoint /dev/mouse
99	}
100}
101
102usbstart
103if (test -f /dev/apm)
104	aux/apm
105
106dontkill '^(ipconfig|factotum|mntgen|fossil|cs|dns|listen|reboot)$'
107