@ECHO OFF
REM CIXSTA.BAT
REM Automated CREATOR/xattr test for MARS NWE.
REM
REM PART1 runs as SUPERVISOR, prepares data and queues CIXC via DLYSTRT.
REM PART2 runs after CIXC has logged SUPERVISOR back in and collects results
REM from C:\CIXTMP into F:\CIXCMP.
REM
REM Optional NOPASSUSER readback requires:
REM   SET LGNTPWD=your-supervisor-password

IF "%1"=="" GOTO PART1
IF "%1"=="PART2" GOTO PART2
IF "%1"=="part2" GOTO PART2
IF "%1"=="Part2" GOTO PART2
ECHO Usage: CIXSTA [PART2]
GOTO END

:PART1
F:
CD \

REM --- Clean generated test/result directories (contents only). ---
IF EXIST CIXTEST\NUL DELTREE /Y CIXTEST\*.*
IF EXIST CIXCMP\NUL DELTREE /Y CIXCMP\*.*

IF NOT EXIST CIXTEST\NUL MD CIXTEST
IF NOT EXIST CIXTEST\SUP\NUL MD CIXTEST\SUP
IF NOT EXIST CIXCMP\NUL MD CIXCMP
IF NOT EXIST CIXCMP\PRE\NUL MD CIXCMP\PRE
IF NOT EXIST CIXCMP\POST\NUL MD CIXCMP\POST
IF NOT EXIST CIXCMP\LINUX\NUL MD CIXCMP\LINUX
IF NOT EXIST CIXCMP\UNOV\NUL MD CIXCMP\UNOV
IF NOT EXIST CIXCMP\UPUB\NUL MD CIXCMP\UPUB
IF NOT EXIST CIXCMP\UCREATOR\NUL MD CIXCMP\UCREATOR

IF EXIST F:\CIXCMP\RUN.LOG DEL F:\CIXCMP\RUN.LOG
IF EXIST F:\CIXCMP\SUMMARY.TXT DEL F:\CIXCMP\SUMMARY.TXT
IF EXIST F:\CIXCMP\CIXSTA.ZIP DEL F:\CIXCMP\CIXSTA.ZIP
IF EXIST F:\CIXCMP\ZIP.LOG DEL F:\CIXCMP\ZIP.LOG

IF EXIST F:\CIXCMP\PRE\*.OUT DEL F:\CIXCMP\PRE\*.OUT
IF EXIST F:\CIXCMP\POST\*.OUT DEL F:\CIXCMP\POST\*.OUT
IF EXIST F:\CIXCMP\LINUX\*.TXT DEL F:\CIXCMP\LINUX\*.TXT
IF EXIST F:\CIXCMP\UNOV\*.OUT DEL F:\CIXCMP\UNOV\*.OUT
IF EXIST F:\CIXCMP\UPUB\*.OUT DEL F:\CIXCMP\UPUB\*.OUT
IF EXIST F:\CIXCMP\UCREATOR\*.OUT DEL F:\CIXCMP\UCREATOR\*.OUT
IF EXIST F:\CIXCMP\UCOMP.LOG DEL F:\CIXCMP\UCOMP.LOG
IF EXIST F:\CIXCMP\HELPER.TXT DEL F:\CIXCMP\HELPER.TXT
IF EXIST F:\CIXCMP\ULOG1.OUT DEL F:\CIXCMP\ULOG1.OUT
IF EXIST F:\CIXCMP\ULOGIN.OUT DEL F:\CIXCMP\ULOGIN.OUT
IF EXIST F:\CIXCMP\ULOG2.OUT DEL F:\CIXCMP\ULOG2.OUT
IF EXIST F:\CIXCMP\ULGSUP.OUT DEL F:\CIXCMP\ULGSUP.OUT

REM Reset files from previous runs.
IF EXIST F:\CIXTEST\SUP\S_SUP.TXT DEL F:\CIXTEST\SUP\S_SUP.TXT
IF EXIST F:\CIXTEST\SUP\S_ARCH.TXT DEL F:\CIXTEST\SUP\S_ARCH.TXT
IF EXIST F:\CIXTEST\SUP\S_ALL.TXT DEL F:\CIXTEST\SUP\S_ALL.TXT

ECHO CIXSTA creator/xattr test using PUBLIC\CREATOR > F:\CIXCMP\RUN.LOG
ECHO Run this as SUPERVISOR. >> F:\CIXCMP\RUN.LOG
ECHO Date/time stamp skipped to avoid DOS prompt. >> F:\CIXCMP\RUN.LOG
ECHO Optional user-context target: NOPASSUSER >> F:\CIXCMP\RUN.LOG
ECHO. >> F:\CIXCMP\RUN.LOG

ECHO SUP CREATOR FILE > F:\CIXTEST\SUP\S_SUP.TXT
ECHO SUP ARCHIVE FILE > F:\CIXTEST\SUP\S_ARCH.TXT
ECHO SUP ALL FILE > F:\CIXTEST\SUP\S_ALL.TXT

NPUBLIC\FLAG F:\CIXTEST\SUP\S_SUP.TXT N >> F:\CIXCMP\RUN.LOG
NPUBLIC\FLAG F:\CIXTEST\SUP\S_ARCH.TXT N >> F:\CIXCMP\RUN.LOG
NPUBLIC\FLAG F:\CIXTEST\SUP\S_ALL.TXT N >> F:\CIXCMP\RUN.LOG

ECHO === PRE READBACK === >> F:\CIXCMP\RUN.LOG
NPUBLIC\NDIR F:\CIXTEST\SUP /DATES > F:\CIXCMP\PRE\SUPDAT.OUT
NPUBLIC\NDIR F:\CIXTEST\SUP /RIGHTS > F:\CIXCMP\PRE\SUPRGT.OUT
PUBLIC\CREATOR F:\CIXTEST\SUP\S_SUP.TXT /SHOW > F:\CIXCMP\PRE\CSUP.OUT
PUBLIC\CREATOR F:\CIXTEST\SUP\S_ARCH.TXT /SHOW > F:\CIXCMP\PRE\CARCH.OUT
PUBLIC\CREATOR F:\CIXTEST\SUP\S_ALL.TXT /SHOW > F:\CIXCMP\PRE\CALL.OUT

ECHO === CREATOR TOOL SET INFO === >> F:\CIXCMP\RUN.LOG

REM Set fileinfo xattr fields.
PUBLIC\CREATOR F:\CIXTEST\SUP\S_SUP.TXT /CREATOR MARIO >> F:\CIXCMP\RUN.LOG
PUBLIC\CREATOR F:\CIXTEST\SUP\S_SUP.TXT /MODIFIER MARIO >> F:\CIXCMP\RUN.LOG

REM Set archive xattr fields.
PUBLIC\CREATOR F:\CIXTEST\SUP\S_ARCH.TXT /ARCHIVE MARIO >> F:\CIXCMP\RUN.LOG

REM Set all three groups with one command and explicit date/time.
PUBLIC\CREATOR F:\CIXTEST\SUP\S_ALL.TXT /ALL MARIO 2026-05-25 16:12:00 >> F:\CIXCMP\RUN.LOG

ECHO === POST READBACK === >> F:\CIXCMP\RUN.LOG
NPUBLIC\NDIR F:\CIXTEST\SUP /DATES > F:\CIXCMP\POST\SUPDAT.OUT
NPUBLIC\NDIR F:\CIXTEST\SUP /RIGHTS > F:\CIXCMP\POST\SUPRGT.OUT
PUBLIC\CREATOR F:\CIXTEST\SUP\S_SUP.TXT /SHOW > F:\CIXCMP\POST\CSUP.OUT
PUBLIC\CREATOR F:\CIXTEST\SUP\S_ARCH.TXT /SHOW > F:\CIXCMP\POST\CARCH.OUT
PUBLIC\CREATOR F:\CIXTEST\SUP\S_ALL.TXT /SHOW > F:\CIXCMP\POST\CALL.OUT

NPUBLIC\FLAG F:\CIXTEST\SUP\S_SUP.TXT > F:\CIXCMP\POST\FSUP.OUT
NPUBLIC\FLAG F:\CIXTEST\SUP\S_ARCH.TXT > F:\CIXCMP\POST\FARCH.OUT
NPUBLIC\FLAG F:\CIXTEST\SUP\S_ALL.TXT > F:\CIXCMP\POST\FALL.OUT

REM Allow NOPASSUSER to read this tree for optional user-context readback.
REM Creator metadata is set by SUPERVISOR above; the helper only verifies
REM that /SHOW and effective rights look sane for a normal user.
\NPUBLIC\GRANT R F FOR F:\CIXTEST\SUP TO USER NOPASSUSER > F:\CIXCMP\POST\UGRANTD.OUT
\NPUBLIC\GRANT R F FOR F:\CIXTEST\SUP\S_SUP.TXT TO USER NOPASSUSER > F:\CIXCMP\POST\UGRNTS.OUT
\NPUBLIC\GRANT R F FOR F:\CIXTEST\SUP\S_ARCH.TXT TO USER NOPASSUSER > F:\CIXCMP\POST\UGRNTA.OUT
\NPUBLIC\GRANT R F FOR F:\CIXTEST\SUP\S_ALL.TXT TO USER NOPASSUSER > F:\CIXCMP\POST\UGRNTL.OUT

REM --- Queue delayed NOPASSUSER readback helper. ---
IF "%LGNTPWD%"=="" GOTO NEEDPWD
IF EXIST C:\CIXTMP\*.* DELTREE /Y C:\CIXTMP
IF NOT EXIST C:\CIXTMP MD C:\CIXTMP
IF NOT EXIST C:\CIXTMP\UNOV MD C:\CIXTMP\UNOV
IF NOT EXIST C:\CIXTMP\UPUB MD C:\CIXTMP\UPUB
IF NOT EXIST C:\CIXTMP\UCREATOR MD C:\CIXTMP\UCREATOR

REM DLYSTRT must be local because F: disappears after LOGOUT.
IF EXIST \PUBLIC\DLYSTRT.EXE COPY \PUBLIC\DLYSTRT.EXE C:\CIXTMP > NUL
IF EXIST C:\CIXTMP\DLYSTRT.EXE GOTO HAVEDLY
ECHO ERROR: DLYSTRT.EXE not found. >> F:\CIXCMP\RUN.LOG
ECHO ERROR: DLYSTRT.EXE not found.
GOTO END

:HAVEDLY
REM Only the helper and DLYSTRT must be local. CIXSTA stays on F:\ and is
REM started as F:\CIXSTA.BAT PART2 after the SUPERVISOR re-login.
COPY F:\CIXC.BAT C:\CIXTMP\CIXC.BAT > NUL

C:
CD \CIXTMP
DLYSTRT /T:2 CIXC.BAT
ECHO CIXC queued via DLYSTRT. >> F:\CIXCMP\RUN.LOG
ECHO CIXC wurde via DLYSTRT gestartet.
ECHO Nach automatischem Re-Login wird CIXSTA PART2 gestartet.
GOTO END

:PART2
F:
CD \
IF NOT EXIST CIXCMP\UNOV MD CIXCMP\UNOV
IF NOT EXIST CIXCMP\UPUB MD CIXCMP\UPUB
IF NOT EXIST CIXCMP\UCREATOR MD CIXCMP\UCREATOR

IF EXIST C:\CIXTMP\UNOV\*.* COPY C:\CIXTMP\UNOV\*.* F:\CIXCMP\UNOV > NUL
IF EXIST C:\CIXTMP\UPUB\*.* COPY C:\CIXTMP\UPUB\*.* F:\CIXCMP\UPUB > NUL
IF EXIST C:\CIXTMP\UCREATOR\*.* COPY C:\CIXTMP\UCREATOR\*.* F:\CIXCMP\UCREATOR > NUL
IF EXIST C:\CIXTMP\HELPER.TXT COPY C:\CIXTMP\HELPER.TXT F:\CIXCMP\HELPER.TXT > NUL
IF EXIST C:\CIXTMP\ULOG1.OUT COPY C:\CIXTMP\ULOG1.OUT F:\CIXCMP\ULOG1.OUT > NUL
IF EXIST C:\CIXTMP\ULOGIN.OUT COPY C:\CIXTMP\ULOGIN.OUT F:\CIXCMP\ULOGIN.OUT > NUL
IF EXIST C:\CIXTMP\ULOG2.OUT COPY C:\CIXTMP\ULOG2.OUT F:\CIXCMP\ULOG2.OUT > NUL
IF EXIST C:\CIXTMP\ULGSUP.OUT COPY C:\CIXTMP\ULGSUP.OUT F:\CIXCMP\ULGSUP.OUT > NUL

ECHO === COMPARE NOPASSUSER NOVELL RIGHTS AGAINST PUBLIC RIGHTS === > F:\CIXCMP\UCOMP.LOG
ECHO Comparing SUP directory >> F:\CIXCMP\UCOMP.LOG
FC F:\CIXCMP\UNOV\SUPRGT.OUT F:\CIXCMP\UPUB\SUPRGT.OUT >> F:\CIXCMP\UCOMP.LOG
ECHO Comparing S_SUP.TXT >> F:\CIXCMP\UCOMP.LOG
FC F:\CIXCMP\UNOV\RSUP.OUT F:\CIXCMP\UPUB\RSUP.OUT >> F:\CIXCMP\UCOMP.LOG
ECHO Comparing S_ARCH.TXT >> F:\CIXCMP\UCOMP.LOG
FC F:\CIXCMP\UNOV\RARCH.OUT F:\CIXCMP\UPUB\RARCH.OUT >> F:\CIXCMP\UCOMP.LOG
ECHO Comparing S_ALL.TXT >> F:\CIXCMP\UCOMP.LOG
FC F:\CIXCMP\UNOV\RALL.OUT F:\CIXCMP\UPUB\RALL.OUT >> F:\CIXCMP\UCOMP.LOG

ECHO === SUMMARY === > F:\CIXCMP\SUMMARY.TXT
ECHO CIXSTA creator/xattr test with PUBLIC\CREATOR finished. >> F:\CIXCMP\SUMMARY.TXT
ECHO. >> F:\CIXCMP\SUMMARY.TXT
ECHO Expected: >> F:\CIXCMP\SUMMARY.TXT
ECHO - S_SUP.TXT has creator/modifier MARIO via user.mars_nwe.fileinfo. >> F:\CIXCMP\SUMMARY.TXT
ECHO - S_ARCH.TXT has archive date/time/archiver MARIO via user.mars_nwe.archive. >> F:\CIXCMP\SUMMARY.TXT
ECHO - S_ALL.TXT has fileinfo and archive metadata with explicit date/time. >> F:\CIXCMP\SUMMARY.TXT
ECHO - POST\C*.OUT shows PUBLIC\CREATOR /SHOW readback. >> F:\CIXCMP\SUMMARY.TXT
ECHO - POST\SUPDAT.OUT shows NDIR /DATES readback. >> F:\CIXCMP\SUMMARY.TXT
ECHO - UCREATOR/UNOV/UPUB show NOPASSUSER readback. >> F:\CIXCMP\SUMMARY.TXT
ECHO. >> F:\CIXCMP\SUMMARY.TXT
ECHO Next Linux-side step: run cix_collect_xattr.sh, then CIXZIP. >> F:\CIXCMP\SUMMARY.TXT

ECHO.
ECHO CIXSTA PART2 fertig.
ECHO Jetzt auf Linux cix_collect_xattr.sh ausfuehren, dann CIXZIP.
ECHO.
GOTO END

:NEEDPWD
ECHO ERROR: LGNTPWD ist nicht gesetzt.
ECHO Fuer den automatischen CREATOR/NOPASSUSER-Test zuerst setzen, z.B.:
ECHO   SET LGNTPWD=dein-supervisor-passwort
ECHO Danach starten:
ECHO   F:\CIXSTA
ECHO Es wurde kein DLYSTRT installiert und kein User-Kontext-Test gestartet.
GOTO END

:END
