/* Prolog; See Epilog for additional information ******************** * Exec Name - CPCONFIG EXEC * * Unit Support - OSS/VM * * Status - Version 2, Release 1.0 * ********************************************************************/ address 'COMMAND' parse source xos xct xfn xft xfm xcmd xenvir . parse upper arg parms 0 operands '(' options ')' parmrest ?noprompt=wordpos('NOPROMPT',options)>0 ?nosyntax=wordpos('NOSYNTAX',options)>0 ?test=wordpos('NOPROMPT',options)>0 /*Allow test w/o MAINT disks */ exitwords='QQUIT QQUI QQU QQ QUIT QUI QU Q EXIT HALT HX HI LEAVE' If parms='?' then Signal Explain /* ------------------------------------------------------------- */ /* ====> Update the following variables for YOUR system <==== */ /* ------------------------------------------------------------- */ ?UpdRec1=1 /* If set to '1', will REPLACE the 1st record of the */ /* SYSTEM CONFIG on the CF2 disk with the next var. */ UpdRec1=' say "Beginning: ''SYSTEM CONFIG'' from MAINT''s CF2' , 'disk."' /* ------------------------------------------------------------- */ /* Important when synching disks, "ACCESSM0" on MAINT 193 disk */ address CMS 'STATE ACCESSM0 MODULE *' If rc<>0 then Call Exit rc /* Ensure that any updated "SYSTEM CONFIG" file is valid. */ address CMS 'STATE CPSYNTAX EXEC *' If rc<>0 then Call Exit rc Signal ON NoValue Signal ON Syntax Signal ON Error 'ACCESSM0 ON' If \?test then Do Signal OFF Error 'PIPE CP CPRELEASE A SYNCH | STEM emsg.' If rc<>0 & rc<>6706 then /* 6706=was not accessed */ Do src=rc say 'CP CPRELEASE A SYNCH failed...' 'PIPE STEM emsg.| CONSOLE' Call Exit src End Signal ON Error 'EXEC VMLINK MAINT CF1 (NONAMES' End /*---------------------------------------------------------------*/ /* Prepare to permit backup/update/validation of the CONFIG */ /*---------------------------------------------------------------*/ Signal OFF Error /* May not have a SYSTEM CONFIG yet */ CfgBefore='' 'PIPE (NAME CfgBefore)' , '| COMMAND LISTFILE SYSTEM CONFIG I (ISODATE NOHEADER' , '| VAR CfgBefore TRACKING' ?backup=0 Do forever say say 'The following "*SYSTEM CONFIG" files exist on the I(CF1)' , 'disk now:' 'LISTFILE *SYSTEM CONFIG I (ISODATE' say 'Do you want an automatic copy/rename of them as a backup' say 'before starting? (Reply: Yes | No | Quit)' parse upper pull reply . If wordpos(reply,exitwords)>0 then Do say 'Aborting' xfn 'per reply: "'reply'".' Call Exit 8 End If abbrev('NO',reply,1) then Leave If abbrev('YES',reply,1) then Do ?backup=1 Leave End say say 'Invalid reply:' reply say End If ?backup then Do /* Filetype must be CONFIG for SAPL to select it at IPL. */ 'ERASE -9SYSTEM CONFIG I' 'RENAME -8SYSTEM CONFIG I -9SYSTEM CONFIG I' 'RENAME -7SYSTEM CONFIG I -8SYSTEM CONFIG I' 'RENAME -6SYSTEM CONFIG I -7SYSTEM CONFIG I' 'RENAME -5SYSTEM CONFIG I -6SYSTEM CONFIG I' 'RENAME -4SYSTEM CONFIG I -5SYSTEM CONFIG I' 'RENAME -3SYSTEM CONFIG I -4SYSTEM CONFIG I' 'RENAME -2SYSTEM CONFIG I -3SYSTEM CONFIG I' 'RENAME -1SYSTEM CONFIG I -2SYSTEM CONFIG I' 'COPYFILE SYSTEM CONFIG I -1SYSTEM CONFIG I (OLDDATE' End /* Give 'em a chance to make changes to ANY file... */ 'EXEC FILELIST * * I' /* See if they made any changes to SYSTEM CONFIG I */ CfgAfter='' 'PIPE (NAME CfgAfter)' , '| COMMAND LISTFILE SYSTEM CONFIG I (ISODATE NOHEADER' , '| VAR CfgAfter TRACKING' ?CfgChanged=0 If CfgBefore<>CfgAfter then If ?nosyntax then say '+++Warning! CPSYNTAX command skipped per option:' , 'NOSYNTAX' Else Do ?CfgChanged=1 cmd='EXEC CPSYNTAX SYSTEM CONFIG I' say cmd cmd If rc<>0 then Do say '+++WARNING+++ Error in SYSTEM CONFIG -' , 'it has NOT been placed into production.' say 'I(CF1) R/W link retained so you can' , 'correct the error(s).' Call Exit rc End End If CfgAfter='' then 'CP MSG * WARNING!!! There is no SYSTEM CONFIG file' , 'on the I-CF1 DISK!' Signal ON Error If \?CfgChanged & CfgAfter<>'' then 'CP MSG * +++ NOTE: The "SYSTEM CONFIG I" was not changed.' Call FindDifferences say identical If cf2only.0>0 & \?noprompt then Call Prompt 'CF2only.' If cf2newer.0>0 & \?noprompt then Call Prompt 'CF2newer.' /*----------------------------------------------------------------*/ /* Place CF1 back in production, get CF2 read/write. */ /*----------------------------------------------------------------*/ If \?test then Do 'RELEASE I (DET' 'CP CPACCESS MAINT CF1 A SR SYNCH' End say 'CF1 update complete and in production...' say say 'CF2 update in progress...' If \?test then Do 'EXEC VMLINK MAINT CF1 (NONAMES MODE0' 'RELEASE O (DET' Signal OFF Error 'PIPE CP CPRELEASE B SYNCH | STEM emsg.' If rc<>0 & rc<>6706 then Do src=rc say 'CP CPRELEASE B SYNCH failed...' 'PIPE STEM emsg.| CONSOLE' Call Exit src End Signal ON Error 'EXEC VMLINK MAINT CF2 (NONAMES' End If ?CfgChanged then Do 'PIPE (NAME CopyBackupConfigs)' , '| COMMAND LISTFILE -%SYSTEM CONFIG I (NOHEADER' , '| SPECS /COPYFILE/ 1' , 'WORDS 1-3 NW' , '/= = O ( OLDDATE REPLACE/ NW' , '| COMMAND' 'COPYFILE SYSTEM CONFIG I SYSTEM CONFIG O (OLDDATE REPLACE' If ?UpdRec1 then 'EXECIO 1 DISKW SYSTEM CONFIG O 1 F 80 (FINIS VAR UPDREC1' 'STATE SETDATE EXEC *' /* On IBM VM Download Page */ If rc=0 then Do parse var CfgAfter . . . . . . . CfgNewDt CfgNewTm . 'EXEC SETDATE SYSTEM CONFIG O' CfgNewDt CfgNewTm 'ISODATE' End End If cf1only.0>0 & \?noprompt then Call Prompt 'CF1only.' If cf1newer.0>0 & \?noprompt then Call Prompt 'CF1newer.' If \?test then Do 'RELEASE O (DET' 'CP CPACCESS MAINT CF2 B SR SYNCH' 'RELEASE I (DET' End say 'CF2 update complete and in production...' Call Exit rc /********************************************************************/ /* Sub-Routines below this point */ /********************************************************************/ Exit: parse arg exitrc . If verify(exitrc,'-0123456789')=0 then Exit exitrc else Exit 999999 FindDifferences: If \?test then 'EXEC VMLINK MAINT CF2 (NONAMES MODE0' 'PIPE (END ? NAME FileDifferences)' , '| COMMAND LISTFILE * * I (NOHEADER ISODATE' , '| NLOCATE /SYSTEM CONFIG /' , /* Handled separately */ '| NLOCATE /-1SYSTEM CONFIG /' , '| NLOCATE /-2SYSTEM CONFIG /' , '| NLOCATE /-3SYSTEM CONFIG /' , '| NLOCATE /-4SYSTEM CONFIG /' , '| NLOCATE /-5SYSTEM CONFIG /' , '| NLOCATE /-6SYSTEM CONFIG /' , '| NLOCATE /-7SYSTEM CONFIG /' , '| NLOCATE /-8SYSTEM CONFIG /' , '| NLOCATE /-9SYSTEM CONFIG /' , '| SPECS 19-21 1.3' , /* Move filemode up front */ '1-18 4.18 22-* 22' , /* then fn, ft and the rest */ '| l: LOOKUP 4-*' , /* Lookup fname/ftype/etc. */ '| COUNT LINES' , '| INSERT / identical files on both disks./ AFTER' , '| VAR identical' , '| HOLE' , /* Discard exact matches */ , /* All files from both, not exactly the same go into diff: */ '| diff: FANINANY' , '| SORT WORDS 2.2 A' , /* Sort by filename/type */ '| uniq: UNIQUE WORDS 2.2 MULTIPLE' , /* Keep dup fileIDs */ , /* Pairs of matching fileIDs, different in some other way */ '| SPECS 4.18 1.18' , /* Fn/ft back in front */ '1.3 19-21' , /* then fm */ '22-* 22' , /* and the rest */ '| SORT WORDS 1.3 A', /* By filename/type/mode */ '| JOIN 1 / /' , /* I-disk then O-disk */ , /* Again, by now we KNOW the date or time is different */ '| O_newerD: PICK WORD8 == WORD 17' , /* I-disk newer date */ '| O_newerT: PICK WORD9 >> WORD 18' , /* I-disk new | = O */ '| I_newerD: FANINANY' , /* I-disk newer date */ '| SPECS WORDS 1-9 1' , /* Drop O-disk info */ '| STEM CF1newer.' , '? COMMAND LISTFILE * * O (NOHEADER ISODATE' , '| NLOCATE /SYSTEM CONFIG /' , /* Handled separately */ '| NLOCATE /-1SYSTEM CONFIG /' , '| NLOCATE /-2SYSTEM CONFIG /' , '| NLOCATE /-3SYSTEM CONFIG /' , '| NLOCATE /-4SYSTEM CONFIG /' , '| NLOCATE /-5SYSTEM CONFIG /' , '| NLOCATE /-6SYSTEM CONFIG /' , '| NLOCATE /-7SYSTEM CONFIG /' , '| NLOCATE /-8SYSTEM CONFIG /' , '| NLOCATE /-9SYSTEM CONFIG /' , '| SPECS 19-21 1.3' , /* Move filemode up front */ '1-18 4.18 22-* 22' , /* then fn, ft and the rest */ '| l:' , /* UnRefed I(CF1) files */ '| diff:' , /* Shunt to find differences */ '? l:' , /* UnRefed O(CF2) files */ '| diff:' , /* Shunt to find differences */ '? uniq:' , /* All unique files */ '| uniqI: STRFIND /O/' , '| SPECS 4.18 1.18' , /* Fn/ft back in front */ '1.3 19-21' , /* then fm */ '22-* 22' , /* and the rest */ '| BUFFER' , '| STEM CF2only.' , '? uniqI:' , /* Unique I-files */ '| SPECS 4.18 1.18' , /* Fn/ft back in front */ '1.3 19-21' , /* then fm */ '22-* 22' , /* and the rest */ '| BUFFER' , '| STEM CF1only.' , '? O_newerD:' , /* O-disk newer or equal date*/ '| ShuntID: PICK WORD8 << WORD 17' , /* Pass back newer date*/ '| warnmore: FANINANY' , '| DEBLOCK 76' , '| BUFFER' , '| NLOCATE SUBSTR 1.1 OF WORD 3 /I/' , /* Drop I(CF1) files */ '| STEM CF2newer.' , '? O_newerT:' , /* O-disk date date, new time*/ '| warnmore:' , /* Shunt to O_newer */ '? ShuntID:' , '| I_newerD:' /* Shunt to O_newer */ Return Prompt: parse arg thisstem . Select When thisstem='CF2only.' then Do msg1='The following files exist ONLY on the CF2 disk,' , 'not the CF1 disk:' msg2='Do you wish to have them copied from the CF2' , 'to the CF1 disk automatically?' msg3='Unique files on the CF2 disk were NOT copied' , 'to the CF1 disk per reply:' End When thisstem='CF1only.' then Do msg1='The following files exist ONLY on the CF1 disk,' , 'not the CF2 disk:' msg2='Do you wish to have them copied from the CF1' , 'to the CF2 disk automatically?' msg3='Unique files on the CF1 disk were NOT copied' , 'to the CF2 disk per reply:' End When thisstem='CF1newer.' then Do msg1='The following files are NEWER on the CF1 disk,' , 'than the CF2 disk:' msg2='Do you wish to have them copied from the CF1' , 'to the CF2 disk automatically?' msg3='NEWER files on the CF1 disk were NOT copied' , 'to the CF2 disk per reply:' End When thisstem='CF2newer.' then Do msg1='The following files are NEWER on the CF2 disk,' , 'than the CF1 disk:' msg2='Do you wish to have them copied from the CF2' , 'to the CF1 disk automatically?' msg3='NEWER files on the CF2 disk were NOT copied' , 'to the CF1 disk per reply:' End Otherwise Do say '+++ Unexpected stem value in "Prompt" routine:' , '"'thisstem'".' Call Exit 24 End End /* Select */ If \?noprompt then Do forever say say msg1 'PIPE STEM' thisstem '| CONSOLE' say msg2 say 'Reply: (Yes | No | Quit)' parse upper pull reply . If wordpos(reply,exitwords)>0 then Do say 'Aborting' xfn 'per reply: "'reply'".' say 'WARNING! CP CONFIG disks may be linked R/W' , 'at this time!' Call Exit 8 End If abbrev('NO',reply,1) then Do say msg3 '"'reply'"' Return End If abbrev('YES',reply,1) then Leave say say 'Invalid reply:' reply say End /* Prompt forever */ thisrec=value(thisstem||1) parse var thisrec . . ifm . parse var ifm ifm 2 . Select When ifm='I' then ofm='O' When ifm='O' then ofm='I' Otherwise Do say '+++ Unexpected input filemode for COPYFILE "'ifm'".' say '+++ Record in question: "'thisrec'".' say '+++ When processing stem:' thisstem Call Exit 20 End End /* Select */ 'PIPE (END ? NAME CopyFiles)' , '| STEM' thisstem , '| SPECS /COPYFILE/ 1' , 'WORDS 1.3 NW' , '/= =' ofm '(OLDDATE REPLACE/ NW' , '| COMMAND' , '| CONSOLE' Return Error: say '+++ Error routine entered in:' xfn xft xfm say '+++ from line:' sigl', which reads:' say '+++'sourceline(sigl) Call Exit 20 Syntax: say '+++ Syntax error routine entered in:' xfn xft xfm say '+++ from line:' sigl', which reads:' say '+++'sourceline(sigl) Call Exit 20 NoValue: say '+++ NoValue error routine entered in:' xfn xft xfm say '+++ from line:' sigl', which reads:' say '+++'sourceline(sigl) say '+++ Variable with no value is:' condition('Description') Call Exit 24 Explain: 'PIPE (END ? NAME Explain)' , '| <' xfn xft xfm , '| INSIDE /ExplainBegin:/ /ExplainEnd:/' , '| CONSOLE' Call Exit 4 /* Beginning of Explanation comments ... ExplainBegin: CPCONFIG EXEC is used to help manage the SYSTEM CONFIG file, and optionally keep the CF1 and CF2 disks in synch. It assumes that the CF1 disk is the primary disk, and CF2 is the backup disk during changes to the CF1 (or should the CF1 disk become unavailable/corrupted). _________________________________________________________________________ Syntax: >--CPCONFIG--+----------------------------+------------------------->< +-(-+------------------------+ +-NOPROMPT-+--+-TEST-+---+ +-)-+ Where: NOPROMPT Eliminates the prompt asking if files should be copied between the the CF1 disks and CF2 disks to synch them up. Instead, the copies will be made without asking, but files copied will be reported. TEST Skips CPREL, CPACC, and VMLINK commands permitting tests using **pre-existing** I-CF1 and O-CF2 disks (perhaps TDISK copies of MAINT's CF1 and CF2 disks). _________________________________________________________________________ The processing performed by the CPCONFIG EXEC includes: o Obtain a R/W link to the CF1 disk as "I" (Input). o Prompt the user to ask if optional backups of the "SYSTEM CONFIG" should be made. The backups are made by erasing "-9SYSTEM CONFIG", renaming "-nSYSTEM CONFIG" files upwards sequentially, and then COPYFILEing "SYSTEM CONFIG" to "-1SYSTEM CONFIG". o Enter "FILELIST * * I" (to see all CF1 files), permitting update to any and all files in the "I" disk. o If the resulting "SYSTEM CONFIG I" was changed, execute "CPSYNTAX SYSTEM CONFIG I" to verify it's syntax. o If CPSYNTAX is unsuccessful, exit immediately. o If files on the CF2 disk are unique, or newer than those on the CF1 disk, and the NOPROMPT option was not given, ask if they should be automatically copied to the CF1 disk. Do so if requested, or if NOPROMPT was specified. o Place the CF1 disk back into production, LINK it R/O as the "I" disk, and obtain R/W access to the CF2 disk as "O" (Output). o Copy the "-%SYSTEM CONFIG I" files to the CF2 disk (OLDDATE REPLACE) o Copy the "SYSTEM CONFIG I" on the CF1 disk to the CF2 disk (OLDD REPL) o If the ?UpdRec1 flag is turned on at the top of this exec (?UpdRec1=1) update the first record of the "SYSTEM CONFIG" on the CF2 disk with the value of the hardcoded "UpdRec1" variable. o If files on the CF1 disk are unique, or newer than those on the CF2 disk, and the NOPROMPT option was not given, ask if they should be automatically copied to the CF1 disk. Do so if requested, or if NOPROMPT was specified. ExplainEnd: ... end of Explanation comments */ /* Epilog *********************************************************** * Function - Backup (optionally), validate and make copy of * * SYSTEM CONFIG from CF1 to CF2. * * Component of - VM Sysprog Toolkit * * Command format- CPCONFIG * * Called by - VM Sysprogs * * Dependencies - Non-standard requirements: * * - SETDATE EXEC (optional) * * - ACCESSM0 MODULE * * - CPSYNTAX EXEC * * - Authority to: * * - CPREL MAINT CF1 and CF2 * * - CPACC MAINT CF1 A SR SYNCH and CF2 B SR SYNCH * * - CP LINK MAINT CF1 and CF2 R/O and R/W. * * Program Lang. - CMS REXX * * Date Written - 20000320 * * Author - Michael R. Walter * * Changed | By | Description of Change * * --------+-----+------------------------------------------------- * * 20010208 mrw - V2R1.0, remove ASG-FCOPY reliance, * * - Change backup filename rather than filetype, * * - Add optional CF1/CF2 synchronization. * * 20010309 mrw - Minor commenting improvements. * * 20020718 mrw - Add NOSYNTAX option. * * - Display error messages from COPYFILE command. * * 20020916 mrw - Change ASG-FCOPY copyfile cmd syntax to PIPE. * * 20021121 mrw - Add "EXEC SETDATE" to keep SYSTEM CONFIG date * * and time the same on CF1 and CF2. * * 20030421 mrw - Correct I- and O-disk date/time checking in Pipe.* * * ********************************************************************/