]> git.lizzy.rs Git - plan9front.git/blob - sys/src/9/boot/net.rc
bootrc: add ndb/dnsgetip resolver to bootfs so domain names can be used for fs=,...
[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 ' ip is? ' $auth(1)
25         if(~ $#auth 0)
26                 ask auth ' ip is? ' $fs(1)
27
28         # resolve dns names
29         if(test -x /bin/ndb/dnsgetip){
30                 for(i in fs auth secstore){
31                         $i=`{for(x in $$i) ndb/dnsgetip -a $x}
32                 }
33         }
34
35         # set bootstrap authservers for factotum
36         if(! ~ $#auth 0){
37                 grep -v '^[     ]*auth=' /net/ndb >/env/x
38                 cat /env/x <{echo '     auth='^$auth^'
39 '} >/net/ndb
40                 rm /env/x
41         }
42 }
43
44 fn connecttcp{
45         while(! ~ $#fs 0 && ! srv -q tcp!$fs(1)^!564 boot)
46                 fs=$fs(2-);
47         fs=$fs(1)
48 }
49
50 fn connectil{
51         while(! ~ $#fs 0 && ! srv -q il!$fs(1)^!17008 boot)
52                 fs=$fs(2-);
53         fs=$fs(1)
54 }
55
56 mtcp=(confignet connecttcp)
57 mil=(confignet connectil)
58 mt=(mtcp mil $mt)