@ECHO OFF
REM LGNTSTA.BAT
REM Automated LOGIN/LOGOUT baseline test for MARS NWE.
REM
REM START from F: while logged in as SUPERVISOR:
REM   SET LGNTPWD=your-supervisor-password
REM   F:\LGNTSTA
REM
REM LGNTSTA prepares C:\LGNTTMP, installs a delayed start for LGNTC.BAT,
REM and then exits while F: is still available. DLYSTRT starts the local
REM C: helper after a short delay. The helper logs out, logs in as
REM NOPASSUSER, captures MAP, logs out, then logs in as SUPERVISOR again
REM using F:\LOGIN\LOGIN /PWD:%LGNTPWD%, then queues PART2 with DLYSTRT.
REM LGNTZIP is not started automatically.
REM
REM SYS:LOGIN / SYS:PUBLIC are NOT overwritten by this test.

IF "%1"=="" GOTO PART1
IF "%1"=="PART2" GOTO PART2
IF "%1"=="PARt2" GOTO PART2
IF "%1"=="PArT2" GOTO PART2
IF "%1"=="PArt2" GOTO PART2
IF "%1"=="PaRT2" GOTO PART2
IF "%1"=="PaRt2" GOTO PART2
IF "%1"=="ParT2" GOTO PART2
IF "%1"=="Part2" GOTO PART2
IF "%1"=="pART2" GOTO PART2
IF "%1"=="pARt2" GOTO PART2
IF "%1"=="pArT2" GOTO PART2
IF "%1"=="pArt2" GOTO PART2
IF "%1"=="paRT2" GOTO PART2
IF "%1"=="paRt2" GOTO PART2
IF "%1"=="parT2" GOTO PART2
IF "%1"=="part2" GOTO PART2
GOTO USAGE

:PART1
F:
CD \

IF NOT "%LGNTPWD%"=="" GOTO PWDCHECKOK
ECHO ERROR: LGNTPWD ist nicht gesetzt.
ECHO.
ECHO Fuer den vollautomatischen LOGIN/LOGOUT-Test zuerst setzen, z.B.:
ECHO   SET LGNTPWD=dein-supervisor-passwort
ECHO Danach starten:
ECHO   F:\LGNTSTA
ECHO.
ECHO Es wurde kein DLYSTRT installiert und kein Login-Test gestartet.
GOTO END
:PWDCHECKOK

REM --- Recreate generated result/temp directories. ---
IF EXIST LGNTCMP DELTREE /Y LGNTCMP
MD LGNTCMP > NUL
MD LGNTCMP\OUT > NUL

ECHO LGNTSTA LOGIN/LOGOUT test > F:\LGNTCMP\RUN.LOG
ECHO Part 1 started while logged in as SUPERVISOR. >> F:\LGNTCMP\RUN.LOG
ECHO Helper will use user NOPASSUSER on server MARS. >> F:\LGNTCMP\RUN.LOG
ECHO This test uses DLYSTRT so F:\LGNTSTA can finish before LOGOUT. >> F:\LGNTCMP\RUN.LOG
ECHO SYS:LOGIN, SYS:PUBLIC, and SYS:NPUBLIC are not modified. >> F:\LGNTCMP\RUN.LOG
ECHO. >> F:\LGNTCMP\RUN.LOG

ECHO LGNTPWD is set; automatic SUPERVISOR login is enabled. >> F:\LGNTCMP\RUN.LOG

IF EXIST C:\LGNTTMP DELTREE /Y C:\LGNTTMP
MD C:\LGNTTMP > NUL

REM --- Copy Novell baseline tools to local C: directory only. ---
REM Do not overwrite SYS:LOGIN, SYS:PUBLIC, or SYS:NPUBLIC.
REM LOGIN/MAP are from NLOGIN, LOGOUT is from NPUBLIC.
ECHO Copying Novell runtime tools to C:\LGNTTMP. >> F:\LGNTCMP\RUN.LOG
COPY \NLOGIN\LOGIN.* C:\LGNTTMP >> F:\LGNTCMP\RUN.LOG
COPY \NLOGIN\MAP.* C:\LGNTTMP >> F:\LGNTCMP\RUN.LOG
COPY \NPUBLIC\LOGOUT.* C:\LGNTTMP >> F:\LGNTCMP\RUN.LOG

REM DLYSTRT is also copied to C: so the whole delayed phase uses local tools.
IF EXIST \PUBLIC\DLYSTRT.EXE GOTO HAVEDLY
ECHO ERROR: \PUBLIC\DLYSTRT.EXE not found. >> F:\LGNTCMP\RUN.LOG
ECHO ERROR: \PUBLIC\DLYSTRT.EXE not found.
ECHO Build/install dostools with MAINTAINER_BUILD=ON.
GOTO END
:HAVEDLY
COPY \PUBLIC\DLYSTRT.EXE C:\LGNTTMP >> F:\LGNTCMP\RUN.LOG

ECHO Copying helper to C:\LGNTTMP\LGNTC.BAT >> F:\LGNTCMP\RUN.LOG
COPY F:\LGNTC.BAT C:\LGNTTMP >> F:\LGNTCMP\RUN.LOG

ECHO Installing delayed helper start from local C:\LGNTTMP. >> F:\LGNTCMP\RUN.LOG
IF EXIST C:\LGNTTMP\DLYSTRT.EXE GOTO HAVEDLYLOCAL
ECHO ERROR: C:\LGNTTMP\DLYSTRT.EXE not copied. >> F:\LGNTCMP\RUN.LOG
ECHO ERROR: C:\LGNTTMP\DLYSTRT.EXE not copied.
GOTO END
:HAVEDLYLOCAL
REM Switch to C: before installing DLYSTRT.  The delayed command is
REM typed into the current DOS prompt, so the prompt must not still be F:.
C:
CD \LGNTTMP
DLYSTRT /T:2 LGNTC.BAT >> F:\LGNTCMP\RUN.LOG

ECHO. >> F:\LGNTCMP\RUN.LOG
ECHO DLYSTRT installed LGNTC.BAT from C:\LGNTTMP. >> F:\LGNTCMP\RUN.LOG
ECHO LGNTSTA Part 1 finished; helper will start from local C: after delay. >> F:\LGNTCMP\RUN.LOG

ECHO LGNTSTA Part 1 fertig.
ECHO DLYSTRT startet gleich C:\LGNTTMP\LGNTC.BAT.
ECHO Bitte warten...
GOTO END

:PART2
F:
CD \
MD LGNTCMP > NUL
MD LGNTCMP\OUT > NUL

ECHO. >> F:\LGNTCMP\RUN.LOG
ECHO Part 2 collecting files from C:\LGNTTMP. >> F:\LGNTCMP\RUN.LOG
COPY C:\LGNTTMP\*.OUT F:\LGNTCMP\OUT >> F:\LGNTCMP\RUN.LOG
COPY C:\LGNTTMP\*.TXT F:\LGNTCMP\OUT >> F:\LGNTCMP\RUN.LOG

ECHO === SUMMARY === > F:\LGNTCMP\SUMMARY.TXT
ECHO LGNTSTA LOGIN/LOGOUT baseline finished. >> F:\LGNTCMP\SUMMARY.TXT
ECHO Novell LOGIN/MAP/LOGOUT were copied only to C:\LGNTTMP. >> F:\LGNTCMP\SUMMARY.TXT
ECHO LOGIN/MAP source: SYS:NLOGIN. LOGOUT source: SYS:NPUBLIC. >> F:\LGNTCMP\SUMMARY.TXT
ECHO SYS:LOGIN, SYS:PUBLIC, and SYS:NPUBLIC were not modified. >> F:\LGNTCMP\SUMMARY.TXT
ECHO DLYSTRT was used to start C:\LGNTTMP\LGNTC.BAT after Part 1 returned. >> F:\LGNTCMP\SUMMARY.TXT
ECHO. >> F:\LGNTCMP\SUMMARY.TXT
ECHO Expected files: >> F:\LGNTCMP\SUMMARY.TXT
ECHO - D01_LOG.OUT   LOGOUT output from initial supervisor session. >> F:\LGNTCMP\SUMMARY.TXT
ECHO - D02_LGIN.OUT  LOGIN NOPASSUSER baseline output. >> F:\LGNTCMP\SUMMARY.TXT
ECHO - D03_MAP.OUT   MAP output after NOPASSUSER login. >> F:\LGNTCMP\SUMMARY.TXT
ECHO - D04_LGOT.OUT  LOGOUT output from NOPASSUSER session. >> F:\LGNTCMP\SUMMARY.TXT
ECHO - D05_LGSU.OUT  F:\LOGIN\LOGIN SUPERVISOR /PWD output. >> F:\LGNTCMP\SUMMARY.TXT
ECHO - D06_P2.OUT    DLYSTRT output for delayed PART2 start. >> F:\LGNTCMP\SUMMARY.TXT
ECHO - D99_HELP.OUT  Simulated LOGIN usage baseline if help is not redirectable. >> F:\LGNTCMP\SUMMARY.TXT
ECHO DLYSTRT.EXE was copied locally to C:\LGNTTMP before starting the helper and PART2. >> F:\LGNTCMP\SUMMARY.TXT
ECHO LGNTZIP is not started automatically; run it manually after inspection. >> F:\LGNTCMP\SUMMARY.TXT
ECHO. >> F:\LGNTCMP\SUMMARY.TXT
ECHO Optional: LGNTZIP ausfuehren. >> F:\LGNTCMP\SUMMARY.TXT

ECHO LGNTSTA PART2 fertig.
ECHO Ergebnisse liegen in F:\LGNTCMP
ECHO Optional: LGNTZIP ausfuehren.
GOTO END

:USAGE
ECHO Usage: LGNTSTA [PART2]
ECHO.
ECHO Ohne Parameter startet LGNTSTA Part 1 und installiert DLYSTRT.
ECHO PART2 sammelt nach dem erneuten SUPERVISOR-Login die C:-Ergebnisse ein.
ECHO Gueltiger Parameter ist PART2; part2/Part2 wird ebenfalls akzeptiert.
ECHO.
ECHO Fuer vollautomatischen Lauf vorher setzen, z.B.:
ECHO   SET LGNTPWD=dein-supervisor-passwort
ECHO Danach starten:
ECHO   F:\LGNTSTA
GOTO END

:END
