@echo off
 cls
 echo.
 echo.
 rem ... A FrontDoor/RemoteAccess batchfile by T. Graves - 159/500
 rem ... set default drive here and before every questionable return to RA
 rem ... in an interactive scenario like this, repeating the drive setting
 rem ... is not overkill.
 rem ... Note especially that this batch file may be restarted without the 
 rem ... modem being re-initialized at any point in the batch file where 
 rem ... there is a flag (ie: :HERE).  
 rem ... If an outside function fails, you may restart your user by typing:
 rem ... FDRA RESTART-RA and that will bring the same user right back online.
 rem ... Every routine in this batch file may be tested the same way.
 :c:
 set RA=\RA
 set FD=\FD
 set DSZLOG=\RA\DSZ.LOG
 if "%1." == "." goto start
 dtr on >nul
 goto %1

:START
 dtr on >nul
 at h1 >nul
 cls
 echo.
 echo.
 echo.
 echo.
 echo.
 echo.
 echo.
 echo.
 echo.
 echo       -------------- FrontDoor ---- RemoteAccess ------------------
 echo.
 echo.
 echo.
 :c:
 cd \RA
 if not exist logon.flg goto runfdra
 Setflags after AX-????-? >nul
 del logon.flg
:runfdra
 cd \fd
 FD 
:AFTER-FD
 if errorlevel 238 goto 19200_BBS
 if errorlevel 219 goto 19200_BBS
 if errorlevel 196 goto 9600_BBS
 if errorlevel 124 goto 2400_BBS
 if errorlevel 112 goto 1200_BBS
 if errorlevel 103 goto 300_BBS
 if errorlevel 100 goto LOCALBBS
 if errorlevel  90 goto SCANECHO
 if errorlevel  80 goto TOSSNET
 if errorlevel  70 goto UNPACKMAIL
 if errorlevel  60 goto CLEANUP
 if errorlevel  55 goto DAILY
 if errorlevel  50 goto RA
 if errorlevel  11 goto START
 if errorlevel  10 goto END
 if errorlevel   6 goto FOSSIL
 if errorlevel   5 goto MODEMINIT
 if errorlevel   4 goto MODEMRESP
 if errorlevel   3 goto FULLDISK
 if errorlevel   2 goto EXTERNAL
 if errorlevel   1 goto INTERNAL
  goto start

rem ***** FrontDoor executes BBS for human callers baud rate/errorlevels *****
:19200_BBS
 :c:
 cd\RA
 echo .... User Logged On > logon.flg
 RA.exe -n1 -b19200 -E0
 goto AFTER-RA

:9600_BBS
 :c:
 cd\RA
 echo .... User Logged On > logon.flg
 RA.exe -n1 -b9600 -E0
 goto AFTER-RA

:2400_BBS
 :c:
 cd\RA
 echo .... User Logged On > logon.flg
 RA.exe -n1 -b2400 -E0
 goto AFTER-RA

:1200_BBS
 :c:
 cd\RA
 echo .... User Logged On > logon.flg
 RA.exe -n1 -b1200 -E0
 goto AFTER-RA

:300_BBS
 :c:
 cd\RA
 echo .... User Logged On > logon.flg
 RA.exe -n1 -b300 -E0
 goto AFTER-RA

:LOCALBBS
 :c:
 DTR ON >nul
 AT M0H1 >nul
 cd\RA
 echo .... User Logged On > logon.flg
 RA.exe -n1 -L -E0
 goto AFTER-RA

:AFTER-RA
 rem   ***** AFTER_RA traps the errorlevel exits from RA *****
 if errorlevel 20 goto OUTSIDE
 if errorlevel 10 goto START
 if errorlevel  5 goto NET&ECHO
 if errorlevel  4 goto ECHOONLY
 if errorlevel  3 goto NETONLY
 if errorlevel  1 echo INITIALIZATION ERROR!  Modem Init failed or NO FOSSIL!   
  goto END-RA

:rem Outside routines requiring exit from RA to run (saves RAM).
:rem -===========================================================-

 rem prevent accidental drop to DOS through batch
 goto start
:OUTSIDE
 findcd 1
 if errorlevel 0 goto tuit
 xu watchcd:0:on
 ctty gate1
:tuit 
 prompt Outside_(exit returns)$p$g 
 c:\command.com
 cd \RA
 prompt $p$g
 xu watchcd:0:off
 ctty con 
  goto restart-RA

:RESTART-RA
 :c:
 CD \RA
 RA.exe -n1 -r 
  goto AFTER-RA

:NET&ECHO
 DTR ON  >nul
 AT M0 >nul
 AT H1 >nul
 :c:
 cd \RA
 mbutil export
 :mailscan 3
 :
:ECHOONLY
 DTR ON  >nul
 AT M0 >nul
 AT H1 >nul
 :c:
 cd \RA
 qecho -E -A -P
 :ZMailQ EE EP PA NS
 :echogen -E -A -P -S900
  goto end-RA

:NETONLY
 DTR ON >nul
 AT M0 >nul
 AT H1 >nul
 :c:
 cd \RA
 mbutil export
 :mailscan 3
  goto end-RA

:END-RA
 DTR ON >nul
 AT M0 >nul
 AT H1 >nul
 cls
 cd\ra
 doink 
  goto start

:UNPACKMAIL
 :c:
 cd\RA
 echo **** Unpacking mail; exit from FD errorlvl 70;  F7 manually ****
 qecho -A -H -S900 -T -U 
 :ZMailQ PI PA PU EI EP EF NF NP
 :EchoGen -B -P -T -U -A -H
 mbutil import
 if not exist \netfiles\nodediff.* goto nexttest
:PARSE
  echo    ........... Nodediff found... Processing Nodelist .......... 
  cd \netfiles
  for %%F IN (nodediff.???) Do Echo %%F Weekly Nodelist Change File >> \fidonet\files.bbs
  cd \RA\nodelist
  copy \netfiles\nodediff.* \fidonet 
  pkunpak/r \netfiles\nodediff.*
  del \netfiles\nodediff.*
  parselst
  del nodediff.*
  pkzip -m \fidonet\nodelist.zbs nodelist.bbs
:killist
  cd \RA\nodelist
  del nodelist.f*
  killist
  md temp
  for %%F  in (nodelist.???) do zip \nodelist\temp\%%F nodelist.???
  cd temp
  rename nodelist.??? nodelist.z??
  for %%F in (nodelist.???) do echo %%F Weekly Compiled Nodelist "Zipped" >> \fidonet\files.bbs
  copy nodelist.??? \fidonet
  del nodelist.???
  cd \RA
  RAnode
  cd \fd
  fdnc
:nexttest
  echo    ........... Checking for received File Lists ...............
  if not exist d:\netfiles\f159_*.* goto nextst2
  copy \netfiles\f159_*.* \fidonet
  del \netfiles\f159_*.*
:nextst2
  goto START

:TOSSNET
 :c:
 cd\RA
 echo **** Toss net-mail; Manual exit from FD Errorlvl 80  ****
 mbutil import
 goto START

:SCANECHO
 :c:
 cd\RA
 echo ***** Echo Mail Scan; Manual exit from FD Errorlvl 90 *****
 qecho -E -A -P
 :echogen -E -A -P
 :ZMailQ EE EP PA NS
 goto START

:CLEANUP
 :c:
 cd\RA
 echo **** Cleanup; Auto exit FD, 2am event FD Errorlvl 60 ****
 mbutil import
 mbutil export
 qecho -E -A -P
 :echogen -E -A -P
 :ZMailQ EE EP PA NS
 RAmsg -K
 RAmsg -PKRA
 RAuser -V -S -P -D90 -M50
 goto start

:DAILY
 echo * Special Daily Midnight Maintenance Routines  *
 :c:
 cd\RA
 echo ..... GeneRAting daily files list with XLIST ....................
 X_list XL_RA.Ctl
 pkzip \fidonet\F159_999 f159_999.lst
 echo ..... Reading System Log & Packing RA Daily Log .................
: strip system.log
 Daynbr ren system.log RAlog.@###
 Daynbr pkzip -m \ra\logs\RAlog.zip RAlog.@###
 :
 cd\fd
 echo.
 echo ..... Packing FrontDoor Daily log................................. 
 echo.
: strip fd.log
 Daynbr ren fd.log fdlog.@###
 Daynbr pkzip -m \ra\logs\fdlog.zip fdlog.@###
 :
:dly
 :c:
 cd \RA
 echo.
 echo  ....  Packing RA RegistRAtion Answers ..................... 
 echo.
 Pkzip -u \ra\logs\answers.zip answers.dat
 :
 goto start

 rem ***** Some basic error codes in case we get in trouble *****
:FOSSIL
 echo.
 echo.
 Echo Wrong Fossil Version Error|goto END
:MODEMINIT
 echo.
 echo.
 Echo Unable To Initialize Modem|goto END
:MODEMRESP
 echo.
 echo.
 Echo Modem Not Responding|goto END
:FULLDISK
 echo.
 echo.
 Echo Insufficient Disk Space To Proceed|goto END
:EXTERNAL
 echo.
 echo.
 Echo External Error - System File Missing|goto END
:INTERNAL
 echo.
 echo.
 Echo Internal Error
:END
 cd \RA
 DTR ON
 AT M0
 AT H1
 AT M0
 echo.
 echo.
 echo.
 echo.
 echo.
 echo ...... outta there!

