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