lra 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #!/bin/rc
  2. # on hook and initialize
  3. fn initfn {
  4. dial/drain
  5. dial/at -q -t 5 zh0
  6. }
  7. # dial telephone number
  8. fn dialfn {
  9. dial/drain
  10. dial/at -q -t 60 dt^$1
  11. }
  12. # process options
  13. for(i in $*){
  14. switch($i){
  15. case '-P'
  16. primary=-P
  17. }
  18. }
  19. # the following can be inherited
  20. switch($dev){
  21. case ''
  22. dev=/dev/eia1
  23. }
  24. switch($telno){
  25. case ''
  26. telno=18009878722
  27. }
  28. switch($baud){
  29. case ''
  30. baud=115200
  31. }
  32. {
  33. # set up uart
  34. if( test -e $dev^ctl ){
  35. echo -n b^$baud # baud rate
  36. echo -n m1 # cts/rts flow control
  37. echo -n q64000 # big buffer
  38. echo -n n1 # nonblocking writes
  39. echo -n r1 # rts on
  40. echo -n d1 # dtr on
  41. echo -n c1 # handup wen we lose dcd
  42. } > $dev^ctl
  43. # get the modem's attention
  44. while( ! initfn )
  45. sleep 1
  46. # dial
  47. while( ! dialfn $telno )
  48. sleep 30
  49. if( ! dial/expect -it 60 'username:' ){
  50. echo lra: can''t connect >[1=2]
  51. exit connect
  52. }
  53. dial/pass
  54. if( ! dial/expect -it 60 'password:' ){
  55. echo lra: can''t connect >[1=2]
  56. exit connect
  57. }
  58. dial/pass
  59. if( ! dial/expect -t 60 'telnet:' ){
  60. echo lra: can''t connect >[1=2]
  61. exit connect
  62. }
  63. echo ppp
  64. echo connected to lra >[1=2]
  65. # start ppp
  66. ip/ppp $primary -f
  67. } < $dev > $dev
  68. # supply unknowns with inside addresses
  69. if( ! grep -s 'auth=' /net/ndb){
  70. echo ' auth=135.104.9.7'>>/net/ndb
  71. echo ' authdom=cs.bell-labs.com'>>/net/ndb
  72. }
  73. if( ! grep -s 'ntp=' /net/ndb)
  74. echo ' ntp=135.104.9.2'>>/net/ndb
  75. if( ! grep -s 'dns=' /net/ndb){
  76. echo ' dns=135.104.8.38'>>/net/ndb
  77. echo ' dns=135.104.70.11'>>/net/ndb
  78. }
  79. # start dns if it isn't already going
  80. if(! test -e /srv/dns )
  81. ndb/dns -r