summaryrefslogtreecommitdiff
path: root/rc/bin/ipconf/theworld
blob: b68df19797af9f54a97ae6e4e2d72003cdbb340e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/rc

fn initfn {
	dial/flush
	echo +++
	echo -n atzh0
	dial/expect -q -t 5 OK
}

fn dialfn {
	dial/flush
	echo -n atdt^$telno^
	dial/expect -q -t 60 CONNECT
}

# process options
for(i in $*){
	switch($i){
	case '-P'
		primary=-P
	}
}

switch($dev){
case ''
	dev=/dev/eia1
}
switch($telno){
case ''
	telno=18009878722
}
switch($baud){
case ''
	baud=115200
}

{
	# set up uart
	if( test -e $dev^ctl ){
		echo -n b^$baud
		echo -n m1	# cts/rts flow control
		echo -n q64000	# big buffer
		echo -n n1	# nonblocking writes
		echo -n r1	# rts on
		echo -n d1	# dtr on
		echo -n c1	# handup wen we lose dcd
	} > $dev^ctl

	# get the modem's attention
	while( ! initfn )
		sleep 1

	# dial
	while( ! dialfn )
		sleep 30
	echo connected to the world >[1=2]

	# start ppp
	ip/ppp $primary -f
} < $dev > $dev

# supply unknowns with outside addresses
if( ! grep -s 'auth=' /net/ndb){
	echo '	auth=204.178.31.3'>>/net/ndb
	echo '	authdom=cs.bell-labs.com'>>/net/ndb
}
if( ! grep -s 'ntp=' /net/ndb)
	echo '	ntp=204.178.31.2'>>/net/ndb
if( ! grep -s 'dns=' /net/ndb){
	echo '	dns=204.178.31.3'>>/net/ndb
	echo '	dns=204.178.31.4'>>/net/ndb
}

# start dns if it isn't already going
if(! test -e /srv/dns )
	ndb/dns -r