]> git.lizzy.rs Git - plan9front.git/blob - sys/src/9/boot/net.rc
bootrc: handle multiple fs and auth addresses in netboot, always set auth= in /net/ndb
[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         # set bootstrap authservers for factotum
29         if(! ~ $#auth 0){
30                 grep -v '^[     ]*auth=' /net/ndb >/env/x
31                 cat /env/x <{echo '     auth='^$auth^'
32 '} >/net/ndb
33                 rm /env/x
34         }
35 }
36
37 fn connecttcp{
38         while(! ~ $#fs 0 && ! srv -q tcp!$fs(1)^!564 boot)
39                 fs=$fs(2-);
40         fs=$fs(1)
41 }
42
43 fn connectil{
44         while(! ~ $#fs 0 && ! srv -q il!$fs(1)^!17008 boot)
45                 fs=$fs(2-);
46         fs=$fs(1)
47 }
48
49 mtcp=(confignet connecttcp)
50 mil=(confignet connectil)
51 mt=(mtcp mil $mt)