.; BRUDSK.CMD	-	COPY VOLUMES VIA BRU
.; 02-NOV-79	S. ROSE
.; 21-NOV-79	S. ROSE	ADD FORMAT OPTION
.; 23-NOV-79	B. KENNEDY  DELETE BRU COMMAND OPTIONS TO AVOID BUG (WIN:)
.;			    ADD TRAP FOR FORMAT OF NON-LAST TRACK DISKS
.; 26-NOV-79	S. ROSE	  SET /PUB AT END AND PIP /FR
.; 28-NOV-79	B. KENNEDY CORRECT SYNTAX ERROR FROM FORMAT OPTION
.; 3-DEC-79	B. KENNEDY ADD SET /WCHK TO INCREASE DATA INTEGRITY
.; 20-FEB-80	B. KENNEDY MODIFY FOR RSX-11M+
.; 11-MAY-81	K. BETHE  RUN TIME BEFORE AND AFTER EACH COPY, DO ERRLOG
.;		(USE ERRCHK TO SEE IF ANY ERRORS DURING COPY)
.; 03-JUN-81	K. BETHE CLEAN OUT ERROR.TMP'S, DON'T ERRLOG DURING BAD
.; 05-JUN-81	K. BETHE  ENHANCE READABILITY CONSOLE OUTPUT, USE ERRSUM
.; 24-JUN-81	K. BETHE  REPLACE DISK WRITE CHECK WITH BRU VERIFY
.; 29-JUN-81	K. BETHE  USE EXIT STATUS ON MOUNTS AND DISMOUNTS
.;			  USE LOG FACILITY TO LOG ALL BRU'S TO DISK
.;  9-JUL-81	K. BETHE  BACKED OUT VERIFY, USING WRITE CHECK AGAIN
.; 13-JUL-81	K. BETHE  ASK FOR DB WHEN POSSIBLE, MODULARZE VIA FF
.;			  ENSURE TIME IS RUN DURING BRU, IF BADDED
.;			  LABEL MUST = "BADDED"
.; 17-JUL-81	K. BETHE  AUDIT TRAIL IMPLEMENTED
.; 02-OCT-81	K. BETHE  EXIT STATUS ON BAD + FORMAT
.; 21-OCT-81	K. BETHE  SSM USED TO WRITE BRU INFO TO ERROR LOG,
.;			  DATE OF LAST BAD FROM BADBLK.SYS FILE
.; 22-JUN-82	K. BETHE  TURN OFF ERROR LOGGING DURING FMT AND BAD
.; 25-AUG-82	K. BETHE  RUN THE BAD WITH WRITE CHECK ON
.; 30-AUG-82	K. BETHE  LOG ALL BRU FAILURES TO [1,4]BRUFAIL.LOG

.ENABLE SUBSTITUTION
.ENABLE GLOBAL
	@[1,2]SYSID
.;		FOR SOME REASON THE D SYSTEM GETS A SYSID OF ZERO
	.IF $SYSID EQ "0" .SETS $SYSID "D"
.;
	.OPEN TI:COMMENT.FIL
	.ENABLE DATA
*
************************************************************************
*
*	THIS COMMAND FILE USES BRU TO COPY DISK TO DISK
*		OPTIONAL FORMATING AND BADDING
*		OF THE OUTPUT DISK IS SUPPORTED
*
*	RUN ON THE '$SYSID' MACHINE '<DATE>' '<TIME>'
*
************************************************************************
*
.DISABLE DATA
.CLOSE
.;
.;			SET UP VARIABLES, DO INSTALLS
.SETN SYS <SYSTEM>
.SETS DISK "'<SYDISK>'"
.SETS SPC " "
.SETS SNAM " SYSTEM "
.SETF TWOTYP
.IF $SYSID EQ "O" .GOSUB TWOSET
.IF $SYSID EQ "M" .GOSUB TWOSET
.IF $SYSID EQ "N" .GOSUB TWOSET
.IF $SYSID EQ "P" .GOSUB TWOSET
.;
.SETS	DR	"DR"
.SETS	DM	"DM"
.;		SET UP VARIABLES NEEDED BY LP11 IN CASE OF ERRLOG REPORT
.SETT	$PRINT
.SETT	$TTY
.SETN	$FLAG 2
.SETF	SPLON
.;		INSTALL ALL NEEDED TASKS, MAINTAINING INDICATORS
.ENABLE QUIET
.SETF INSBAD
.SETF INSBRU
.SETF INSFMT
.SETF INSSYE
.SETF INSPSE
.IFNINS ...BAD .SETT INSBAD
.IFNINS ...BRU .SETT INSBRU
.IFNINS ...FMT .SETT INSFMT
.IFNINS ...SYE .SETT INSSYE
.IFNINS ...PSE .SETT INSPSE
.IFT INSBRU INS $BRU
.IFT INSBAD INS $BAD
.IFT INSFMT INS $FMT
.IFT INSSYE INS $SYE
.IFT INSPSE INS $PSE
.IFNINS UFD INS $UFD
.;
.;		CLEAN OUT ALL OLD ERRLOG FILES, EXCEPT LAST
.;
.;		7 ERROR.SYS FILES (SAVED AS ERROR.SAV)
SET /UIC=[1,6]
PIP ERROR.LST;*/DE/NM
PIP ERROR.SAV/PU:30/NM
PIP ERROR.OLD;*/NV/RE/NM=ERROR.TMP;*
PIP ERROR.OLD/PU:15/NM
SET /UIC=[1,7]
PIP BRUCPYTMP.CMD;*/DE/NM
.IFNINS ...ERF INS $ERF
.DISABLE QUIET
.;
.;					INPUT QUERIES
.INMOR:
;********************************************************************
;
	.ENABLE QUIET
	SET /UIC=[1,6]
	PIP ERROR.SAV/NV/RE/NM=ERROR.SYS
	SET /UIC=[1,7]
	.DISABLE QUIET
;		-------------------------------  GET "FROM" PACK INFORMATION
.INASK:
.SETS INDSK DISK
.ASKS INVOL WHAT IS ''FROM'' PACK VOLUME LABEL
	.IF <STRLEN> GT 14 .GOTO INSYN	.; N.B. 14 IS OCTAL
	.IF <STRLEN> EQ 0 .GOTO INSYN
	.IFT <ALPHAN> .GOTO INDRV
.INSYN:
; ******************** PLEASE RETYPE THE "FROM" PACK LABEL CORRECTLY
	.GOTO INASK
.INDRV:
.ASKN[0:17] INDRV AND WHAT IS ''FROM'' DRIVE NUMBER
.IFF TWOTYP .GOTO 1
	.SETS WHO "IN"
	.GOSUB DBASK
	.IF <SYDISK> NE INDSK .GOTO 2
.1:
	.IF INDRV NE <SYUNIT> .GOTO 2
.;
;**************************************
;BRUDSK - ''FROM'' DRIVE ('INDRV') CANNOT BE THE SYSTEM DISK
;**************************************
	.GOTO INDRV
.;
.2:
	SET /NOPUB='INDSK''INDRV':
.IF <EXSTAT> EQ 1 .GOTO 3
.;
;************************************************************
;*	A FAILURE AT THIS POINT IS USUALLY BECAUSE
;*	'INDSK''INDRV' IS ALREADY MOUNTED VIA THE MOU
;*	COMMAND, IF YOU ARE SURE YOU HAVE THE RIGHT
;*	DRIVE - EXIT FROM THIS COMMAND FILE, AND MAKE SURE
;*	NO ONE ELSE IS USING THAT PACK BEFORE USING DMO ON IT
;*************************************************************
	.GOTO INASK
.3:
.IF <SYSTEM> NE 6 .GOTO NOCON
.;
	CON OFFLINE 'INDSK''INDRV':
	CON ONLINE 'INDSK''INDRV':
.NOCON:
.;
.;				MOUNT INPUT PACK AND PICK UP AUDIT TRAIL
	.SETF INBACK
	.SETN $IDID 0
	MOU 'INDSK''INDRV':'INVOL'/VI
	.SETN MOUSTA <EXSTAT>
.IF MOUSTA NE 1 .GOTO MFAIL
	PIP 'INDSK''INDRV':/FR/NM
	.ENABLE QUIET
	.TESTFILE 'INDSK''INDRV':DISK.ID
.IF <FILERR> NE 1 .GOTO 4
	@'INDSK''INDRV':DISK.ID
	.SETN $IDID $DID
	.TESTFILE 'INDSK''INDRV':BACKUP.ID
.IF <FILERR> NE 1 .GOTO 4
	@'INDSK''INDRV':BACKUP.ID
	.SETT INBACK
	.DISABLE QUIET
.IF $STATE EQ "CURRENT" .GOTO 5
;**********************************************************
;		W A R N I N G
;
;	'INDSK''INDRV': 'INVOL' IS NOT THE CURRENT PACK
;
;	IT WAS '$STATE'
;
;**********************************************************
	.GOTO 5
.4:
	.DISABLE QUIET
.5:
	DMO 'INDSK''INDRV':/LOCK=V/DEV
	.IF <EXSTAT> EQ 1 .GOTO INQ
.MFAIL:
;***********************************************************
;	MOUNT OR DISMOUNT FAILURE
;***********************************************************
.IF MOUSTA EQ 1 .GOTO REIN
	MOU 'INDSK''INDRV':/VI/OVR
.IF <EXSTAT> NE 1 .GOTO INTRY
	DMO 'INDSK''INDRV':/LOCK=V/DEV
.GOTO REIN
.INQ:
;
;
.ASK QU DID YOU ANSWER THE ''FROM'' DRIVE QUESTIONS CORRECTLY
	.IFF QU .GOTO REIN
.INOK:
.IF	SYS = 1 .GOTO OUTASK
	ALL 'INDSK''INDRV':
	MOU 'INDSK''INDRV': /FOR
	.IF <EXSTAT> EQ 1 .GOTO OUTASK
	DEA 'INDSK''INDRV':
.INTRY:
;***************************************************
;	MOUNT FAILURE --
;		AT THIS POINT TRY ANOTHER DISK DRIVE
;***************************************************
.REIN:
	SET /PUB='INDSK''INDRV':
	.GOTO INASK
..;
.;
;		-------------------------------- GET "TO" PACK INFORMATION
.OUTASK:
	.SETS OUTDSK DISK
;
.ASKS OUTVOL WHAT IS ''TO'' PACK VOLUME LABEL
	.IF <STRLEN> EQ 0 .GOTO OUTSYN
	.IF <STRLEN> GT 14 .GOTO OUTSYN.	; N.B. 14 IS OCTAL
	.IFT <ALPHAN> .GOTO OUTDRV
.OUTSYN:
;
;*********** PLEASE RETYPE "TO" PACK LABEL CORRECTLY
.GOTO OUTASK
.;
.OUTDRV:
.ASKN[0:17] OUTDRV AND WHAT IS ''TO'' DRIVE NUMBER
	.IFF TWOTYP .GOTO 18
	.SETS WHO "OUT"
	.GOSUB DBASK
	.IF <SYUNIT> NE OUTDRV .GOTO 17
	.IF <SYDISK> = OUTDSK .GOTO 21
.17:
	.IF INDRV NE OUTDRV .GOTO 30
	.IF INDSK = OUTDSK .GOTO 19
	.GOTO 30
.18:
.IF OUTDRV NE INDRV .GOTO 20
.19:
.;
;**************************************
;BRUSK - ''TO'' DRIVE ('OUTDRV') CANNOT BE THE SAME AS ''FROM'' DRIVE ('INDRV')
;**************************************
.GOTO OUTDRV
.;
.20:
.IF OUTDRV NE <SYUNIT> .GOTO 30
.21:
;**************************************
;BRUDSK - ''TO'' DRIVE ('OUTDRV') CANNOT BE THE SYSTEM DISK
;**************************************
.GOTO OUTDRV
.;
.30:
	SET /NOPUB='OUTDSK''OUTDRV':
.IF <EXSTAT> EQ 1 .GOTO 32
;************************************************************
;*	A FAILURE AT THIS POINT IS USUALLY BECAUSE
;*	'OUTDSK''OUTDRV' IS ALREADY MOUNTED VIA THE MOU
;*	COMMAND, IF YOU ARE SURE YOU HAVE THE RIGHT
;*	DRIVE - EXIT FROM THIS COMMAND FILE, AND MAKE SURE
;*	NO ONE ELSE IS USING THAT PACK BEFORE USING DMO ON IT
;*************************************************************
	.ASK Q DO YOU WISH TO EXIT THIS COMMAND FILE
.IFF Q .GOTO OUTASK
	DMO 'INDSK''INDRV':/DEV/LOCK=V
	DEA 'INDSK''INDRV':
	SET /PUB='INDSK''INDRV':
	.GOTO EXIT0
.32:
.;
.;				ASK IF FORMAT, IF BAD, MOUNT OUTPUT PACK
.SETF INICHK
.IF <SYSTEM>  NE 6 .GOTO NOCON2
	CON OFFLINE 'OUTDSK''OUTDRV':
	CON ONLINE 'OUTDSK''OUTDRV':
.NOCON2:
	.SETS $ODSK OUTDSK
	.SETN $ODRV OUTDRV
.33:	MOU 'OUTDSK''OUTDRV':'OUTVOL'/VI
.35:	.SETN MOUSTA <EXSTAT>
.IF MOUSTA NE 1 .GOTO MFAIL2
	@BRUGETDID
	DMO 'OUTDSK''OUTDRV':'OUTVOL'/LOCK=V/DEV
.IF <EXSTAT> EQ 1 .GOTO OUTOK
.MFAIL2:
;****************************************************
;	MOUNT OR DISMOUNT FAILURE
;****************************************************
.IF MOUSTA EQ 1  .GOTO  REOUT
;	THE ONLY REASONS FOR THE LABEL TO BE
;	INCORRECT ON THE OUTPUT VOLUME ARE:
;		THE INTRODUCTION OF A NEW PACK INTO THE
;		ROUND ROBIN OR LAST WEEKS BACKUP
;		WAS DONE VIA @COPY OR A PREVIOUS
;		BRUDSK FAILED
;*****************************************************
	MOU 'OUTDSK''OUTDRV':/VI/OVR
	.SETN MOUSTA <EXSTAT>
	@BRUGETDID
.IF MOUSTA EQ 1	DMO 'OUTDSK''OUTDRV':/LOCK=V/DEV
.;
.ASK Q ARE YOU SURE THAT 'OUTDSK''OUTDRV': SHOULD BECOME 'OUTVOL'
.IFF Q .GOTO REOUT
	.SETT INICHK
;
.OUTOK:
;
;** 'OUTDSK''OUTDRV':'OUTVOL' WAS LAST BADDED ON:
;		'$BADON'
;
.ASK FORMAT DO YOU WISH TO ALSO FORMAT 'OUTDSK''OUTDRV':'OUTVOL'
.SETT BADIT
.IFF FORMAT .ASK BADIT DO YOU NEED TO BAD 'OUTDSK''OUTDRV':
.IFT BADIT .SETF INICHK
.;
.;				LAST OUTPUT PACK CHECKING, ANSWERED OK ?
.IF SYS = 1 .GOTO OUTQ
	ALL 'OUTDSK''OUTDRV':
	MOU 'OUTDSK''OUTDRV': /FOR
	.IF <EXSTAT> EQ 1 .GOTO OUTQ
;***************************************************
;	MOUNT FAILURE -- 
;		TRY ANOTHER DISK DRIVE
;***************************************************
.DEOUT:
	DMO 'OUTDSK''OUTDRV':/DEV/LOCK=V
	DEA 'OUTDSK''OUTDRV':
.REOUT:
	SET /PUB='OUTDSK''OUTDRV':
	.GOTO OUTASK
.OUTQ:
	.IFF INICHK .GOTO OUTQ2
.;			THE FOLLOWING CHECK IS MADE ON PACKS
.;			THAT DID NOT MOUNT WITH OVERRIDE
.;			TO DISCRIMINATE BETWEEN PACKS WHERE
.;			THE BOOT BLOCK HAS GONE BAD AS OPPOSED
.;			TO FRESHLY FORMATTED PACKS (OR BADDED 
.;			OUTSIDE THE STANDARD COMMAND FILES)
;************************************CHECK IF PACK HAS A BAD BLOCK FILE
	INI 'OUTDSK''OUTDRV':'OUTVOL'/INF=15
	.IF <EXSTAT> GT 1 .GOTO IFAIL
.; THE NO BAD BLOCK FILE DOES NOT RETURN A WARNING STATUS SO...
;
.ASK Q DID THE MESSAGE "INI -- NO BAD BLOCK DATA FOUND" PRINT OUT
.IFF Q .GOTO OUTQ2
;**************************************************************
;	A BAD WILL BE DONE ON 'OUTDSK''OUTDRV' IF YOU CONTINUE 
;		ON (BY ANSWERING Y TO NEXT QUESTION)
;	IN ANY CASE A BAD MUST BE DONE BEFORE BRUING TO THIS PACK
;		(ELSE BRU WILL FAIL)
;**************************************************************
	.SETT BADIT
	.GOTO OUTQ2
.IFAIL:
;************************************************************
;	INI  FAILURE
;
;	THE PACK ON 'OUTDSK''OUTDRV' MAY NOT BE USABLE,
;	TRY ON ANOTHER DRIVE (IF TIME) ELSE USE ANOTHER PACK
;************************************************************
	.GOTO REOUT
.OUTQ2:
.ASK QU DID YOU ANSWER THE ''TO'' DRIVE QUESTIONS CORRECTLY
.IFF QU .GOTO DEOUT
.;
.;
.;
.;			FORMAT AND BAD OUTPUT PACK
.;
.ENABLE QUIET
.;		RESET ERROR COUNT TO 0
	ERF
	SET /UIC=[1,6]
.;	SAVE OLD ERR.TMP'S (WHILE ERRLOG INACTIVE)
PIP ERR.OLD;*/RE/NV/NM=ERR.TMP;*
PIP ERROR.OLD/NV/RE/NM=ERROR.TMP
	SET /UIC=[1,7]
.DISABLE QUIET
.IFF FORMAT .GOTO DONFMT
.;
.;
;		__________________________ START FORMATTING 'OUTDSK''OUTDRV'
	TIM
	.SETS $FMTON $SYSID+SNAM+OUTDSK+"'OUTDRV' "+<DATE>+SPC+<TIME>
.IF DISK = DR  	FMT 'OUTDSK''OUTDRV':/VE/WLT=123456
.IF DISK = DM   FMT 'OUTDSK''OUTDRV':/VE/WLT=123456
.IF DISK <> DR .AND .IF  DISK <> DM  FMT 'OUTDSK''OUTDRV':/VE
.;
.; NEXT SET COMMMENTED OUT - FORMAT DOESN'T HAVE AN EXIT STATUS
.;	.IF <EXSTAT> EQ 1 .GOTO DONFMT
.;*************************************************************************
.;****
.;****		FORMAT FAILURE
.;****
.;****		TRY A DIFFERENT DISK DRIVE - IF THAT FAILS ALSO
.;****			TRY ANOTHER PACK, AND REMOVE THIS PACK
.;****			FROM SERVICE (WRITE UP AN IR ON IT)
.;****
.;*************************************************************************
.;	.GOTO DEOUT
.;
.DONFMT:
	.IFF BADIT .GOTO DONBAD
	SET /WCHK='OUTDSK''OUTDRV':
;		__________________________ START BADDING 'OUTDSK''OUTDRV'
.;
	.SETS $BADON $SYSID+SNAM+OUTDSK+"'OUTDRV' "+<DATE>+SPC+<TIME>
	TIM
	BAD 'OUTDSK''OUTDRV':/LI
.; NO EXIT STATUS ON CURRENT BAD ...
.;	.IF <EXSTAT> NE 1 .GOTO BFAIL
.BAD02:
	TIM
;************* CHECK IF BAD SUCCEEDED
	INI 'OUTDSK''OUTDRV':'OUTVOL'/INF=15
	.IF <EXSTAT> NE 1 .GOTO BFAIL
.ASK Q DID THE MESSAGE "INI -- NO BAD BLOCK DATA FOUND" PRINT OUT
.IFF Q .GOTO DONBAD
.BFAIL:
;;*************************************************************************
;;****
;;****		BAD FAILURE
;;****
;;****		TRY A DIFFERENT DISK DRIVE - IF THAT FAILS ALSO
;;****			REMOVE THE PACK FROM SERVICE, ATTACH
;;****			COPIES OF THE CONSOLE SHEET FOR EACH TRY
;;****			AND WRITE UP AN IR
;;****
;;*************************************************************************
	.GOTO DEOUT
.;
.;					DO THE BRU
.DONBAD:
.;
.OPEN BRUCPYTMP.CMD
.ENABLE DATA
/INI/BAD:AUTO/OUT:'OUTVOL'/INV:'INVOL'/POS:MID
'INDSK''INDRV':
'OUTDSK''OUTDRV':
.DISABLE DATA
.CLOSE
.;
PIP TI:=BRUCPYTMP.CMD
;
	.ENABLE QUIET
	RUN ERRLOG
	.WAIT ERRLOG
SSM '$SYSID' SYSTEM BRU OF 'INDSK''INDRV':'INVOL' TO 'OUTDSK''OUTDRV':'OUTVOL'
	.DISABLE QUIET
.IFF BADIT SET /WCHK='OUTDSK''OUTDRV':
	.SETS BEGTIM <DATE>+" "+<TIME>
;		__________________________ START THE BRU 'INDSK''INDRV' TO 'OUTDSK''OUTDRV'
RUN [2,1]TIME
	BRU @BRUCPYTMP
	.SETN BRUERR <EXSTAT>
RUN [2,1]TIME
;*********** PLEASE DO NOT TAKE PACKS DOWN UNTIL ** FINISHED WITH ... MESSAGES
SET /NOWCHK='OUTDSK''OUTDRV':
.;
.;
.;			ACT ON EXIT STATUS FROM BRU (BRUERR)
.;DEBUG
.;.ASKN BRUERR ENTER EXIT STATUS TO CHECK
.;		PICK UP ERROR LOG COUNT FROM COPY VIA ERRCHK EXIT STATUS
RUN [2,1]ERRCHK
.SETN NUMERR <EXSTAT>
.;
.;	**DEBUG LOGIC
.;.ASKN NUMERR ENTER SIMULATED ERROR COUNT
.;.ASKN BRUERR ENTER SIMULATED BRU STATUS
.;	**END DEBUG LOGIC
.;		DID BRU SUCCEED ?
	.IF BRUERR GT 1 .GOTO BRUER0	.; NO
	.IF NUMERR LT 24 .GOTO W00	.; MAYBE
;******************************************************************
;    WARNING -- TOO MANY ERRORS LOGGED DURING COPY
;		ERROR REPORT SHOULD BE GENERATED
;		HAVE SHIFT SUPERVISOR LOOK AT ERRLOG
;		HE MAY WISH DEC TO LOOK AT IT ALSO
;
;	IF THE NUMBER OF ERRORS IS GREATER THAN THE NUMBER
;		OF MINUTES THE BRU TOOK TO DO THE COPY
;			** THEN THE BRU FAILED **
;		AND THE BRU MUST BE REDONE (THE ERROR
;		SUMMARY WILL TELL YOU WHICH DRIVE
;		HAS THE ERRORS - MOVE OFF THAT DRIVE)
;******************************************************************
	.IF BRUERR EQ 0 .GOTO BRUER5
	.SETN BRUERR 0
	.GOTO BRUER6
.W00:
	.IF BRUERR EQ 1 .GOTO DMO0	.; YES
.BRUER5:
;***********************************************************************
;	WARNING 	WARNING		WARNING
;
;	COPY MAY NOT BE SUCCESSFUL, PLEASE CHECK THE
;		MESSAGE(S) BRU PRINTED OUT (ABOVE) TO 
;		DETERMINE IF THE COPY IS OKAY
;
;***********************************************************************
;
.BRUER6:
.ASK Q IS 'OUTDSK''OUTDRV':'OUTVOL' A GOOD COPY OF 'INDSK''INDRV':'INVOL'
.IFF Q .GOTO BRUER2
.SETN BRUERR 1
.GOTO DMO0
.BRUER0:
;***********************************************************************
;***********************************************************************
;	BRU FAILURE	BRU FAILURE	BRU FAILURE
;
;	THE COPY CANNOT BE USED, REDO OPERATION AFTER CHECKING
;		WITH THE SHIFT SUPERVISOR
;
;
;	IF THE FAILURE WAS DUE TO A "DISK WRITE ERROR", I/O CODE -86
;		BAD 'OUTDSK''OUTDRV':'OUTVOL' BEFORE RETRYING
;		AND/OR SWITCH DRIVES FIRST
;
.IF NUMERR = 0 .GOTO BRUER2
;	AN ERROR SUMMARY WILL PRINT OUT NEXT SHOWING YOU WHICH
;		DRIVE WAS AT FAULT, SO THAT YOU CAN CHANGE THAT DRIVE
;***********************************************************************
;*********************************************************************** 
.BRUER2:
	INI 'OUTDSK''OUTDRV':'OUTVOL'/INF=10
	.WAIT INI
.;			RESTORE FORMATTING AND BADDED AUDIT TRAILS
.ENABLE QUIET
	DMO 'OUTDSK''OUTDRV':/LOCK=S
	MOU 'OUTDSK''OUTDRV':'OUTVOL'
	.IF <EXSTAT> NE 1 .GOTO BE2
	.TESTFILE 'OUTDSK''OUTDRV':[0,0]001007.DIR
	.IF <FILERR> NE 1 UFD 'OUTDSK''OUTDRV':[1,7]
	@BRUWRTDID
.BE2:
	.SETS ERRS "	"+"'BRUERR'"+"	"+"'NUMERR'"+"	"+"'$ODID'"
	.OPEN BRU.TMP
.DATA 'OUTVOL'	'<DATE>' '<TIME>'  '$SYSID' 'DISK''OUTDRV''ERRS'
	.CLOSE
	PIP [1,4]BRUFAIL.LOG/AP=BRU.TMP
	PIP BRU.TMP;*/DE
.DISABLE QUIET
	.GOTO DMO1
.DMO0:
.ASKS $OPRID PLEASE TYPE YOUR FIRST NAME AND LAST INITIAL
.IF <STRLEN> LT 4 .GOTO DMO0
.;
.;				ACT ON NUMBER OF ERRORS LOGGED (NUMERR)
.;				DURING THE BRU COPY
.DMO1:
.IF NUMERR = 0 .GOTO DMO2
.;		ON ANY ERRORS DURING COPY,GET A QUICK DEVICE ERROR SUMMARY
	SET /UIC=[1,6]
	ERF
;		_________________ PLEASE WAIT FOR ERROR SUMMARY TO COMPLETE
	PSE =
	RUN ERRLOG
.SETS ACT "TYP"
.;		GET THE QUICK DEVICE ERROR SUMMARY
.SYE1:
	RUN [2,1]ERRSUM
.IF <EXSTAT> EQ 1	SYE TI:=/SU
.ASK Q DO YOU WANT THE ERRLOG FOR DISK ERRORS NOW ?
.IFF Q .GOTO DMO2
.SYE2:
.;		GET THE ERROR LOG REPORT FOR DISK ERRORS
.IF NUMERR LE 5 .GOTO SYE4
.;		IF MORE THAN 5 ERRORS GIVE OPERATOR THE PRINTER OPTION
.IFT SPLON .GOTO SYE3
;
;	IF NO LINE PRINTER IS AVAILABLE THE ERROR REPORT
;	WILL PRINT OUT ON THE CONSOLE
;
.ASK SPLON DO YOU HAVE A LINE PRINTER PATCHED TO THIS SYSTEM ?
.IFF SPLON .GOTO SYE4
.;	NOW SET UP PRINTER (MAKE IT DEFAULT)
.ASKN $NUM ENTER THE TERMINAL LINE NUMBER TO MAKE A PRINTER
@LP11
.SYE3:
.SETS ACT "PRI"
.;		GET THE REPORT (ACT WILL BE EITHER "PRI" OR "TYP")
.SYE4:
SYE ERROR.LST=/RP:HDW:DSK
'ACT' ERROR.LST
SYE ERROR.LST=/RP:TMO
'ACT' ERROR.LST
.;		ALWAYS DELETE OLD ERROR LOGS AT START OF THIS COMMAND FILE
.;
.;				WRITE OUT AUDIT TRAILS
.DMO2:
	.ENABLE QUIET
	SET /UIC=[1,7]
	.SETS TYP ""
.IF BRUERR NE 1 .SETS TYP "/DEV"
	.DISABLE QUIET
.IF SYS = 1 .GOTO RSXM3
	DMO 'INDSK''INDRV': /LOCK=V'TYP'
	DMO 'OUTDSK''OUTDRV': /LOCK=V'TYP'
.RSXM3:
	.IF BRUERR NE 1 .GOTO RSXM8
	.DISABLE QUIET
.;
.;
.RSXM4:
	MOU 'OUTDSK''OUTDRV':'OUTVOL'/VI
	.IF <EXSTAT> EQ 1 .GOTO RSXM3A
;	************ PLEASE PUT 'OUTVOL' BACK UP ON 'OUTDSK''OUTDRV':
.ASK Q TYPE RETURN WHEN 'OUTVOL' IS BACK UP ON 'OUTDSK''OUTDRV':
	.GOTO RSXM4
.RSXM3A:
	.ENABLE QUIET
	.TESTFILE 'OUTDSK''OUTDRV':[0,0]001007.DIR
	.IF <FILERR> NE 1 UFD 'OUTDSK''OUTDRV':[1,7]
.RSXM4A:
	@BRUWRTDID
	.SETS $STATE "CURRENT"
	.SETS $CPYON $SYSID+SNAM+SPC+BEGTIM
	.SETS $FROM INDSK+"'INDRV' "+INVOL+" ('$IDID')"
	.SETS $TO OUTDSK+"'OUTDRV' "+OUTVOL
	@BRUWRTBAK
.RSXM5:
	.DISABLE QUIET
	.IF BRUERR EQ 1	PIP 'OUTDSK''OUTDRV':/FR/NM
	DMO 'OUTDSK''OUTDRV':/LOCK=V/DEV
.RSXM8:
;
;		**********  FINISHED WITH 'OUTDSK''OUTDRV':'OUTVOL'
.;
;
	.IF BRUERR NE 1 .GOTO WRTP7	.; NOT "COPIED" IF FAILED
	.IFF INBACK .GOTO WRTP7
.WRTP:
.ASK QU IS 'INDSK''INDRV': WRITE PROTECTED
.IFF QU .GOTO WRTP2
.WRTP1:
.ASK QU TYPE RETURN WHEN 'INDSK''INDRV' IS NO LONGER WRITE PROTECTED
.IFT QU .GOTO WRTP
.WRTP2:
	.ENABLE QUIET
	MOU 'INDSK''INDRV':'INVOL'
	.IF <EXSTAT> EQ 1 .GOTO WRTP4
	.DISABLE QUIET
;		 ******** PLEASE PUT 'INVOL' BACK UP ON 'INDSK''INDRV':
	.GOTO WRTP
.WRTP4:
	@'INDSK''INDRV':BACKUP.ID
.;	CHECK IF WRITE PROTECTED
	PIP 'INDSK''INDRV':BACKUP.ID;*/DE
	.IF <EXSTAT> EQ 1 .GOTO WRTP5
	DMO 'INDSK''INDRV':/LOCK=V
	.DISABLE QUIET
;		********* 'INDSK''INDRV IS WRITE PROTECTED !!!
	.GOTO WRTP1
.WRTP5:
	.SETS $STATE "COPIED ON "+$SYSID+SNAM+"TO "+OUTVOL+SPC+BEGTIM
	.SETS $ODSK INDSK
	.SETN $ODRV INDRV
	@BRUWRTBAK
	.DISABLE QUIET
.WRTP6:
	DMO 'INDSK''INDRV':/DEV/LOCK=V
.WRTP7:
;
;		**********  FINISHED WITH 'INDSK''INDRV':'INVOL'
.;
.;
.ENABLE QUIET
	PIP BRUCPYTMP.CMD;*/DE/NM
.IF SYS = 1 .GOTO RSXM4
	DEA 'INDSK''INDRV':
	DEA 'OUTDSK''OUTDRV':
.RSXM4:
	SET /PUB='INDSK''INDRV':
	SET /PUB='OUTDSK''OUTDRV':
.DISABLE QUIET
;
.ASK QU MORE
.IFT QU .GOTO INMOR
.GOTO EXIT0
.;
.;			SUBROUTINES
.;	TWOSET
.;		SET UP TO ASK FOR DB ON MIXED DR,DB SYSTEMS
.TWOSET:
	.SETT TWOTYP
	.SETS DISK "DR"
	.RETURN
.;
.;	DBASK
.;		ASK IF DRIVE IS AN RP04 WHEN POSSIBLE
.;
.DBASK:
	.SETS 'WHO'DSK DISK
	.IF 'WHO'DRV GT 1 .GOTO DBASK2
.ASK Q AND IS IT AN RP04
	.IFT Q .SETS 'WHO'DSK "DB"
.DBASK2:	.RETURN
.;
.;
.;		EXITS
.;
.;		NORMAL EXIT
.;
.EXIT0:
.;
.ENABLE QUIET
	ERF
	.IFT INSBAD REM BAD
	.IFT INSBRU REM BRU
	.IFT INSFMT REM FMT
	.IFT INSSYE REM SYE
	.IFT INSPSE REM PSE
	.WAIT ERRLOG
	RUN ERRLOG
.DISABLE QUIET
/
