]> git.lizzy.rs Git - plan9front.git/blob - rc/bin/termrc
devshr: fixed crash
[plan9front.git] / rc / bin / termrc
1 #!/bin/rc
2 # terminal startup
3 TIMESYNCARGS=(-rLa1000000)
4
5 mntgen -s slashn && chmod 666 /srv/slashn
6
7 # bind all likely devices
8 for(i in S f k t m i v L P u U A '$' Σ κ)
9         bind -a '#'^$i /dev >/dev/null >[2=1]
10 rm -f /env/i
11
12 mount -qb /srv/cons /dev
13 mount -qa /srv/usb /dev
14
15 # set up any partitions
16 diskparts
17
18 # start up local swapping
19 disk=`{ls /dev/sd*/swap >[2]/dev/null}
20 if (! ~ $#disk 0)
21         swap $disk(1) >/dev/null >[2=1]
22 rm -f /env/disk
23
24 # cs sets sysname
25 ndb/cs
26 sysname=`{cat /dev/sysname}
27 if(~ $#sysname 0 || ~ $sysname ''){
28         sysname=cirno                   # default
29         echo -n $sysname >/dev/sysname
30 }
31
32 # parallelism for mk
33 NPROC = `{wc -l </dev/sysstat}
34
35 # machine specific startup (e.g., for devices not probed)
36 if(test -e /cfg/$sysname/termrc)
37         . /cfg/$sysname/termrc
38
39 # automatic ip address setup
40 if(! grep u /net/ipselftab | grep -sv 127.0.0.1){
41         ether=`{ndb/query sys $sysname ether}
42         if(~ $#ether 1){
43                 # try /lib/ndb first, then do dhcp
44                 ip/ipconfig -N >[2]/dev/null || ip/ipconfig
45         }
46         rm -f /env/ether
47 }
48
49 if(! test -e /srv/dns)
50         ndb/dns -r
51
52 if(! ~ $terminal *vx32*){
53         # start timesync if it isn't running and we weren't told not to
54         if(! ps|grep -s timesync)
55                 if(! ~ $TIMESYNCARGS '')
56                         aux/timesync $TIMESYNCARGS
57 }
58
59 fn ask {
60         if(~ $"$1 ask){
61                 echo -n $1
62                 echo -n $2
63                 echo -n ' ['
64                 echo -n $3
65                 echo -n '] '
66                 $1=`{read}
67                 if(~ $"$1 '!rc'){
68                         rc -i
69                         $1=ask
70                 }
71                 if(~ $#$1 0)
72                         $1=$3
73                 ask $*
74         }
75 }
76
77 ask vgasize ' is (text, 640x480x8, 1024x768x16, ...)' 1024x768x16
78 if(! ~ $"vgasize '' text none){
79         ask monitor ' is (vesa, xga, lcd, ...)' vesa
80         if(! ~ $"monitor ''){
81                 if(test -f /dev/mousectl)
82                         ask mouseport ' is (ps2, ps2intellimouse, 0, 1, 2)' ps2
83                 if not
84                         mouseport=none
85                 @{
86                         rfork n
87                         if(~ $monitor vesa)
88                                 aux/realemu
89                         aux/vga -l $vgasize
90                 }
91                 switch($mouseport){
92                 case ps2 ps2intellimouse 0 1 2
93                         aux/mouse $mouseport
94                         if(~ $accupoint 1)
95                                 pipefile -dr /bin/aux/accupoint /dev/mouse
96                 }
97         }
98 }
99 rm -f '/env/fn#ask'
100
101 if(test -f /dev/apm)
102         aux/apm
103
104 dontkill '^(ipconfig|factotum|mntgen|kfs|cwfs.*|cs|dns|listen|reboot)$'