.KEY CONNECT/S
.BRA {
.KET }
; $VER: start 1.0 (13.10.1997)
; Start rc5v2 client
;
; Use this script to run rc5v2 offline or online.
; Place it in the same dir you have the rc5v2 client in.
; Needs Miami OR AmiTCP to be properly installed.
; Set the Script protection bit on (protect +s start).
;
; This is a do-what-you-want-with-it product  ;-)
;
; AmigaPhil@ping.be  http://www.ping.be/amigaphil/
;
; USAGE: open a shell and type:
; ------
; START         First check if Miami is running;
;                 if it is, run rc5v2 (offline or online,
;                 depending the state Miami was).
;               If not, load Miami if exists; then run
;                 rc5v2 (offline).
;               If not, check if AmiTCP is running;
;                 if it is, run rc5v2 (offline or online,
;                 depending the state AmiTCP was).
;               If not, load AmiTCP if exists; then run
;                 rc5v2 (offline).
;               If not, exit without running rc5v2.
;
; START CONNECT Same as above, but put Miami online if it
;                 is offline.
;

FailAt 21

; ***
; *** Check if Miami is running.
; *** If not but exists, start it.
; ***
If `rx "say show('P','MIAMI.1')"` EQ 0
  Avail >NIL: FLUSH
  Version bsdsocket.library >nil:      ; *** If no other TCP/IP stack
  If Warn                              ; *** are running
    Assign Miami: EXISTS >NIL:
    If NOT Warn
      If Exists Miami:Miami                  ; *** and if Miami exists,
        echo "Attempting to start Miami..."
        run <>NIL: Miami:Miami DONTCONNECT        ;  *** load Miami.
        WaitForPort MIAMI.1
      EndIf
    EndIf
  EndIf
EndIf
If `rx "say show('P','MIAMI.1')"` EQ 1 ; *** If Miami is running
  if {CONNECT}                         ; *** and you want to go online;
    rx >NIL: "options results; address 'MIAMI.1'; ISONLINE; return RC"
    If $rc EQ 0                              ; *** if offline,
      echo "Connecting... Please wait..."
      rx "address 'MIAMI.1'; ONLINE"         ; *** go online.
      Wait 15 secs
    EndIf
    rx >NIL: "options results; address 'MIAMI.1'; ISONLINE; return RC"
    If $rc EQ 0
      echo "Miami seems to have trouble to get online."
    else
      echo "Miami is now online."
    EndIf
  EndIf
  echo ""
  skip startrc5v2
EndIf

; ***
; *** If not, start AmiTCP (if exists)
; *** and run rc5v2 (offline mode).
; ***
echo "Attempting to start AmiTCP..."
echo ""
Version bsdsocket.library >nil:
If NOT Warn
  Skip startrc5v2
EndIf
Assign AmiTCP: EXISTS >NIL:
If NOT Warn
  Cpu Check 68020 >nil:
  If NOT Warn
    If Exists AmiTCP:AmiTCP.020
      Run >nil: <nil: AmiTCP:AmiTCP.020
      Skip startrc5v2
    EndIf
  EndIf
  If Exists AmiTCP:AmiTCP
    Run >nil: <nil: AmiTCP:AmiTCP
  else
    echo "AmiTCP/IP can't be started"
    echo "Exiting..."
    Quit 20
  EndIf
EndIf
echo "Failed to load socket.library."
echo "Can't start rc5v2."
echo ""
Quit 20

Lab startrc5v2
; ***
; *** Run the rc5v2 client in a new shell
; ***
wait 3 secs
status command rc5v2 >NIL:
If NOT Warn
  echo "rc5v2 is already cracking !"
  echo ""
else
  echo "Starting rc5v2..."
  echo ""
  If exists rc5v2 then
    stack 200000
    Run >NIL: rc5v2 <>"CON:/100//100/rc5v2 cracking..."
    If `rx "say show('P','BLITZBLANK')"` EQ 1          ; if BlitzBlanker exists
       rx "address 'BLITZBLANK'; 'MODULE=Blackout'"    ; switch to a low CPU
    EndIf                                              ; consumming module
  else
    echo "rc5v2 can't be started !"
    echo ""
    Quit 20
  EndIf
EndIf

