xref: /plan9/rc/bin/ipconf/theworld (revision 1cea15714743963faff4290d6d10fb8f68cb0f53)
1#!/bin/rc
2
3fn initfn {
4	dial/flush
5	echo +++
6	echo -n atzh0
7	dial/expect -q -t 5 OK
8}
9
10fn dialfn {
11	dial/flush
12	echo -n atdt^$telno^
13	dial/expect -q -t 60 CONNECT
14}
15
16# process options
17for(i in $*){
18	switch($i){
19	case '-P'
20		primary=-P
21	}
22}
23
24switch($dev){
25case ''
26	dev=/dev/eia1
27}
28switch($telno){
29case ''
30	telno=18009878722
31}
32switch($baud){
33case ''
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
63if( ! grep -s 'auth=' /net/ndb){
64	echo '	auth=204.178.31.3'>>/net/ndb
65	echo '	authdom=cs.bell-labs.com'>>/net/ndb
66}
67if( ! grep -s 'ntp=' /net/ndb)
68	echo '	ntp=204.178.31.2'>>/net/ndb
69if( ! 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
75if(! test -e /srv/dns )
76	ndb/dns -r
77