]> git.lizzy.rs Git - plan9front.git/blob - rc/bin/ipconf/theworld
Import sources from 2011-03-30 iso image - rc
[plan9front.git] / rc / bin / ipconf / theworld
1 #!/bin/rc
2
3 fn initfn {
4         dial/flush
5         echo +++
6         echo -n atzh0\r
7         dial/expect -q -t 5 OK
8 }
9
10 fn dialfn {
11         dial/flush
12         echo -n atdt^$telno^\r
13         dial/expect -q -t 60 CONNECT
14 }
15
16 # process options
17 for(i in $*){
18         switch($i){
19         case '-P'
20                 primary=-P
21         }
22 }
23
24 switch($dev){
25 case ''
26         dev=/dev/eia1
27 }
28 switch($telno){
29 case ''
30         telno=18009878722
31 }
32 switch($baud){
33 case ''
34         baud=115200
35 }
36
37 {
38         # set up uart
39         if( test -e $dev^ctl ){
40                 echo -n b^$baud
41                 echo -n m1      # cts/rts flow control
42                 echo -n q64000  # big buffer
43                 echo -n n1      # nonblocking writes
44                 echo -n r1      # rts on
45                 echo -n d1      # dtr on
46                 echo -n c1      # handup wen we lose dcd
47         } > $dev^ctl
48
49         # get the modem's attention
50         while( ! initfn )
51                 sleep 1
52
53         # dial
54         while( ! dialfn )
55                 sleep 30
56         echo connected to the world >[1=2]
57
58         # start ppp
59         ip/ppp $primary -f
60 } < $dev > $dev
61
62 # supply unknowns with outside addresses
63 if( ! grep -s 'auth=' /net/ndb){
64         echo '  auth=204.178.31.3'>>/net/ndb
65         echo '  authdom=cs.bell-labs.com'>>/net/ndb
66 }
67 if( ! grep -s 'ntp=' /net/ndb)
68         echo '  ntp=204.178.31.2'>>/net/ndb
69 if( ! grep -s 'dns=' /net/ndb){
70         echo '  dns=204.178.31.3'>>/net/ndb
71         echo '  dns=204.178.31.4'>>/net/ndb
72 }
73
74 # start dns if it isn't already going
75 if(! test -e /srv/dns )
76         ndb/dns -r