.bra {
.ket }
.key exclusive
.def exclusive YES

; Script installed with iNTERiNSTALL 1.51 by Christopher Laprise



path amitcp:bin sys:rexxc sys:system add
failat 20
stack 8000

IF exists amitcp:l/apipe-handler
  Assign APIPE: Exists >NIL:
  IF Warn
    Mount APIPE: from AmiTCP:devs/APipe-Mountlist
  EndIf
ENDIF

if {exclusive} EQ "YES"
  rx 'if show("P","AMITCP") then return 5'
  if warn
    echo >con:0/0/360/32/STARTINTERNET1.51/CLOSE/NODRAG/WAIT "AmiTCP already active."
    quit
  endif
endif

serline "!!" $IPMODEMPORT
if $rc EQ 10
  echo >con:0/0/360/32/STARTINTERNET1.51/CLOSE/NODRAG/WAIT "Serial port in use!"
  quit
endif
wait 1

rx 'say Starting Internet connection'
login -f nobody
umask 022

delete >nil: ENV:ppp0IPLocal
online devs:networks/ppp.device 0
IF NOT EXISTS ENV:ppp0IPLocal
  echo >con:0/0/240/32/STARTINTERNET1.51/CLOSE/NODRAG/WAIT "PPP FAILED!"
  offline ppp.device 0
  quit
ENDIF

PPPConfigAmiTCP30b 0
rx 'if ~show("P","AMITCP") then address command "run AmiTCP:AmiTCP"'
WaitForPort AMITCP
if WARN
  echo >con:0/0/240/32/STARTINTERNET1.51/CLOSE/NODRAG/WAIT "AMITCP FAILED!"
  offline ppp.device 0
  quit
endif
execute T:AmiTCP.tmp
hostname >ENV:HOSTNAME

Assign INET: Exists >NIL:
IF Warn
  Mount INET: from AmiTCP:devs/Inet-Mountlist
EndIf
Assign TCP: Exists >NIL:
IF Warn
  Mount TCP: from AmiTCP:devs/Inet-Mountlist
EndIf
; Start the internet `super server'
run AmiTCP:bin/inetd

if EXISTS AmiTCP:LIBS/socket.library
  LOADLIB AmiTCP:LIBS/socket.library
endif

WaitForPort AMITCP
if WARN
  echo >con:0/0/240/32/STARTINTERNET1.51/CLOSE/NODRAG/WAIT "FAILED!"
else
  echo >con:0/0/240/32/STARTINTERNET1.51/CLOSE/NODRAG/WAIT "complete."
endif
