]> git.lizzy.rs Git - plan9front.git/blob - sys/src/9/boot/net.rc
fix fuckup
[plan9front.git] / sys / src / 9 / boot / net.rc
1 #!/bin/rc
2
3 fn confignet{
4         # get primary default interface if not specified
5         if(~ $#* 0){
6                 e=/net/ether*
7                 if(! ~ $e '/net/ether*')
8                         *=(ether $e(1))
9         }
10
11         # setup wifi encryption if any
12         if(~ $1 ether && ~ $service terminal && test -x /bin/aux/wpa){
13                 if(grep -s '^status: need authentication' $2/ifstats >[2]/dev/null){
14                         aux/wpa -p $2
15                 }
16         }
17
18         must ip/ipconfig -p $*
19         if(~ $#fs 0)
20                 fs=`{awk -F'=' '/^[     ]*fs=/{print $2}' /net/ndb}
21         if(~ $#auth 0)
22                 auth=`{awk -F'=' '/^[   ]*auth=/{print $2}' /net/ndb}
23         if(~ $#fs 0)
24                 ask fs ' address is? ' $auth(1)
25         if(~ $#auth 0)
26                 ask auth ' address is? ' $fs(1)
27
28         # resolve dns names
29         if(test -x /bin/ndb/dnsgetip){
30                 for(i in fs auth secstore){
31                         x=`{for(x in $$i) ndb/dnsgetip -a $x}
32                         ~ $#x 0 || $i=$x
33                 }
34         }
35
36         # set bootstrap authservers for factotum
37         if(! ~ $#auth 0){
38                 grep -v '^[     ]*auth=' /net/ndb >/env/x
39                 cat /env/x <{echo '     auth='^$auth^'
40 '} >/net/ndb
41                 rm /env/x
42         }
43 }
44
45 fn connecttcp{
46         while(! ~ $#fs 0 && ! srv -q tcp!$fs(1)^!564 boot)
47                 fs=$fs(2-);
48         fs=$fs(1)
49 }
50
51 fn connectil{
52         while(! ~ $#fs 0 && ! srv -q il!$fs(1)^!17008 boot)
53                 fs=$fs(2-);
54         fs=$fs(1)
55 }
56
57 mtcp=(confignet connecttcp)
58 mil=(confignet connectil)
59 mt=(mtcp mil $mt)