$!----------------------------------------------------------------------------! $! $! MODULE: CDD_BUILD_TEMPLATE.COM $! $!----------------------------------------------------------------------------! $! $! Copyright Oracle Corporation 1991, 1997. All rights reserved. $! $!----------------------------------------------------------------------------! $! $! Functional Description: $! $! This procedure is used to create a template repository $! $! Arguments: $! P1 - Anchor spec - the VMS anchor of the repository $! to be made into a template $! $! P2 - the VMS anchor to hold the database files for the $! template repository - this must be an empty directory $! $! NOTE: $! $! If you make any changes in this module to the ACLs and/or file $! protections on any template repository files, you may have to $! make the same changes in KITINSTAL.COM. $! $!----------------------------------------------------------------------------! $! $ set on $ ON control_y THEN goto CTRL_Y_ABORT $ ON warning THEN GOTO FAILURE $! $!----------------------------------------------------------------------------! $! Process the first parameter. If not specified on the command line $! prompt the user for it. $! $ wr := "WRITE SYS$OUTPUT" $ if P1 .nes. "" then goto CHECK_P1 $ INQUIRE_P1: $ wr := "WRITE SYS$OUTPUT" $ wr "" $ wr " Please enter the VMS anchor of the repository you want to make $ wr " a template for." $ wr "" $ inquire P1 " DEVICE:[DIRECTORY] " $CHECK_P1: $ cdd$bracket_pos = f$locate("]",P1) $ IF f$length(P1) .gt. cdd$bracket_pos $ THEN $ TEMPLATE := 'P1 $ ELSE $ !+ $ ! append the ":" $ !- $ TEMPLATE := 'P1'":" $ ENDIF $!+ $! Verify that the repository specified is a valid repository $! Break up specification in order to validate it $!- $ f_dev = f$parse (P1,,, "device", "no_conceal") $ f_dir = f$parse (P1,,, "directory", "no_conceal") $ f_fil = f$parse (P1,,, "name", "no_conceal") $ f_typ = f$parse (P1,,, "type", "no_conceal") $ f_ver = f$parse (P1,,, "version", "no_conceal") $!+ $! Validate specification $!- $ if (f_dev .eqs. "") .or. - (f_dir .eqs. "") .or. - (f_fil .nes. "") .or. - (f_typ .nes. ".") .or. - (f_ver .nes. ";") then goto BAD_FILE $ CHECK_DICT_CONTENTS: $!+ $! Verify that the repository specified is a valid repository. $!- $ check_contents = f$parse ("CDD$DATABASE.RDB;", P1) $ if f$search (check_contents) .nes. "" then GOTO PROCESS_P2 $ type sys$input: You have specified a directory that does not contain a valid repository. Please pick a directory that is a valid repository.. $ goto INQUIRE_P1 $ $ BAD_FILE: $ wr "" $ wr "You have specified an illegal file specification:" $ wr " ", P1 $ wr "Please reenter." $ wr "" $ goto INQUIRE_P1 $! $!----------------------------------------------------------------------------! $! Process the second parameter. If not specified on the command line $! prompt the user for it. $! $PROCESS_P2: $ if P2 .nes. "" then goto CHECK_P2 $INQUIRE_P2: $ wr := "WRITE SYS$OUTPUT" $ wr "" $ wr " Please enter the VMS anchor for the template database files. This" $ wr " must be an empty directory" $ wr "" $ inquire P2 " DEVICE:[DIRECTORY] " $CHECK_P2: $ cdd$bracket_pos = f$locate("]",P2) $ IF f$length(P2) .gt. cdd$bracket_pos $ THEN $ TEMPLATEDB := 'P2 $ ELSE $ !+ $ ! append the ":" $ !- $ TEMPLATEDB := 'P2'":" $ ENDIF $!+ $! Break up specification in order to validate it $!- $ f_dev = f$parse (P2,,, "device", "no_conceal") $ f_dir = f$parse (P2,,, "directory", "no_conceal") $ f_fil = f$parse (P2,,, "name", "no_conceal") $ f_typ = f$parse (P2,,, "type", "no_conceal") $ f_ver = f$parse (P2,,, "version", "no_conceal") $!+ $! Validate specification $!- $ if (f_dev .eqs. "") .or. - (f_dir .eqs. "") .or. - (f_fil .nes. "") .or. - (f_typ .nes. ".") .or. - (f_ver .nes. ";") then goto BAD_FILE2 $ goto CHECK_DB_CONTENTS $ $ BAD_FILE2: $ wr "" $ wr "You have specified an illegal file specification:" $ wr " ", P2 $ wr "Please reenter." $ wr "" $ goto INQUIRE_P2 $ CHECK_DB_CONTENTS: $!+ $! verify template db specified is an empty directory $! Check to see if the directory specified exists and has files. If it does, $! make the user pick another one. $!- $ check_contents = f$parse ("*.*;*", P2) $ if f$search (check_contents) .eqs. "" then GOTO CREATE_CDD_TEMPLATE $ type sys$input: You have specified a directory that exists and contains files. Please pick a directory that does not contain files. $ goto INQUIRE_P2 $ $CREATE_CDD_TEMPLATE: $ type sys$input ******************************************************* A template repository will now be created. ******************************************************* $! $!----------------------------------------------------------------------------! $! Process the template repository directory name. The goal is to get the $! name into the following format --> device:[directory]file.DIR $! This is done so we can set ACLs on that file. The template repository $! directory name is located in P1. $! $! The processing here is EXACTLY the same as that done below for the $! template repository database directory name. If you make any changes $! here, you must make them below as well. $! $! First - parse the name, unconcealing any concealed logicals and remove $! the .; that appears at the end. $! $ CDD$TEMPLATE_ANCHOR = F$PARSE (P1,,,,"NO_CONCEAL") $ CDD$TEMPLATE_ANCHOR = - F$EXTRACT (0, F$LENGTH (CDD$TEMPLATE_ANCHOR)-2, CDD$TEMPLATE_ANCHOR) $! $! Second - remove "][" if present. This occurs if concealed logicals $! were used in the original name. $! $ CDD$COUNT = F$LOCATE("][",CDD$TEMPLATE_ANCHOR) $ CDD$CURR_LEN = F$LENGTH(CDD$TEMPLATE_ANCHOR) $ IF CDD$COUNT .GE. CDD$CURR_LEN THEN GOTO TMP_SKIP_BRACKET_PROCESSING $ CDD$TMP1 = F$EXTRACT (0,CDD$COUNT,CDD$TEMPLATE_ANCHOR) $ CDD$TMP2 = F$EXTRACT (CDD$COUNT+2,CDD$CURR_LEN,CDD$TEMPLATE_ANCHOR) $ CDD$TEMPLATE_ANCHOR := 'CDD$TMP1''CDD$TMP2' $! $TMP_SKIP_BRACKET_PROCESSING: $! $! Third - get the [directory] portion of the name and remove the $! brackets. The result is a directory name, followed by 0 or more $! subdirectories. $! $ CDD$CURR_DIR = F$PARSE (CDD$TEMPLATE_ANCHOR,,,"DIRECTORY", "NO_CONCEAL") $ CDD$CURR_DIR = F$EXTRACT (1,F$LENGTH(CDD$CURR_DIR)-2,CDD$CURR_DIR) $! $! Fourth - find the last subdirectory in the directory name. If $! there are no subdirectories, the result is the directory name $! itself. $! $ CDD$CURR_LEN = F$LENGTH (CDD$CURR_DIR) $ CDD$COUNT = 0 $! $TMP_BEGIN_DIRECTORY_LOOP: $! $ CDD$DOT_POS = F$LOCATE(".",CDD$CURR_DIR) $ IF CDD$DOT_POS .GE. CDD$CURR_LEN THEN GOTO TMP_END_DIRECTORY_LOOP $ CDD$CURR_DIR = F$EXTRACT(CDD$DOT_POS+1,CDD$CURR_LEN,CDD$CURR_DIR) $ CDD$CURR_LEN = F$LENGTH (CDD$CURR_DIR) $ CDD$COUNT = CDD$COUNT + 1 $ GOTO TMP_BEGIN_DIRECTORY_LOOP $! $TMP_END_DIRECTORY_LOOP: $! $! Fifth and last - append the directory or subdirectory name to its $! parent anchor and append ".DIR". $! $ CDD$TEMPLATE_DIRECTORY_FILE := - 'F$EXTRACT(0,F$LOCATE(CDD$CURR_DIR,CDD$TEMPLATE_ANCHOR)-1, CDD$TEMPLATE_ANCHOR)' $ IF CDD$COUNT .GE. 1 THEN GOTO TMP_SKIP_TOP_LEVEL_DIRECTORY $ CDD$TEMPLATE_DIRECTORY_FILE := - 'CDD$TEMPLATE_DIRECTORY_FILE'"[000000]"'CDD$CURR_DIR'.DIR" $ GOTO TMP_END_DIRECTORY_PROCESSING $! $TMP_SKIP_TOP_LEVEL_DIRECTORY: $! $ CDD$TEMPLATE_DIRECTORY_FILE := - 'CDD$TEMPLATE_DIRECTORY_FILE'"]"'CDD$CURR_DIR'.DIR" $! $TMP_END_DIRECTORY_PROCESSING: $! $!----------------------------------------------------------------------------! $! Now process the template repository database directory name. As with $! the template repository directory name, the goal is to get the name into $! the following format --> device:[directory]file.DIR $! This is done so we can set ACLs on that file. The template repository $! database directory name is located in P2. $! $! The processing here is EXACTLY the same as that done above for the $! template repository directory name. If you make any changes $! here, you must make them above as well. $! $! First - parse the name, unconcealing any concealed logicals and remove $! the .; that appears at the end. $! $ CDD$TEMPLATEDB_ANCHOR = F$PARSE (P2,,,, "NO_CONCEAL") $ CDD$TEMPLATEDB_ANCHOR = - F$EXTRACT (0, F$LENGTH (CDD$TEMPLATEDB_ANCHOR)-2, CDD$TEMPLATEDB_ANCHOR) $! $! Second - remove "][" if present. This occurs if concealed logicals $! were used in the original name. $! $ CDD$COUNT = F$LOCATE("][",CDD$TEMPLATEDB_ANCHOR) $ CDD$CURR_LEN = F$LENGTH(CDD$TEMPLATEDB_ANCHOR) $ IF CDD$COUNT .GE. CDD$CURR_LEN THEN GOTO TMPDB_SKIP_BRACKET_PROCESSING $ CDD$TMP1 = F$EXTRACT (0,CDD$COUNT,CDD$TEMPLATEDB_ANCHOR) $ CDD$TMP2 = F$EXTRACT (CDD$COUNT+2,CDD$CURR_LEN,CDD$TEMPLATEDB_ANCHOR) $ CDD$TEMPLATEDB_ANCHOR := 'CDD$TMP1''CDD$TMP2' $! $TMPDB_SKIP_BRACKET_PROCESSING: $! $! Third - get the [directory] portion of the name and remove the $! brackets. The result is a directory name, followed by 0 or more $! subdirectories. $! $ CDD$CURR_DIR = F$PARSE (CDD$TEMPLATEDB_ANCHOR,,,"DIRECTORY", "NO_CONCEAL") $ CDD$CURR_DIR = F$EXTRACT (1,F$LENGTH(CDD$CURR_DIR)-2,CDD$CURR_DIR) $! $! Fourth - find the last subdirectory in the directory name. If $! there are no subdirectories, the result is the directory name $! itself. $! $ CDD$CURR_LEN = F$LENGTH (CDD$CURR_DIR) $ CDD$COUNT = 0 $! $TMPDB_BEGIN_DIRECTORY_LOOP: $! $ CDD$DOT_POS = F$LOCATE(".",CDD$CURR_DIR) $ IF CDD$DOT_POS .GE. CDD$CURR_LEN THEN GOTO TMPDB_END_DIRECTORY_LOOP $ CDD$CURR_DIR = F$EXTRACT(CDD$DOT_POS+1,CDD$CURR_LEN,CDD$CURR_DIR) $ CDD$CURR_LEN = F$LENGTH (CDD$CURR_DIR) $ CDD$COUNT = CDD$COUNT + 1 $ GOTO TMPDB_BEGIN_DIRECTORY_LOOP $! $TMPDB_END_DIRECTORY_LOOP: $! $! Fifth and last - append the directory or subdirectory name to its $! parent anchor and append ".DIR". $! $ CDD$TEMPLATEDB_DIRECTORY_FILE := - 'F$EXTRACT(0,F$LOCATE(CDD$CURR_DIR,CDD$TEMPLATEDB_ANCHOR)-1, CDD$TEMPLATEDB_ANCHOR)' $ IF CDD$COUNT .GE. 1 THEN GOTO TMPDB_SKIP_TOP_LEVEL_DIRECTORY $ CDD$TEMPLATEDB_DIRECTORY_FILE := - 'CDD$TEMPLATEDB_DIRECTORY_FILE'"[000000]"'CDD$CURR_DIR'.DIR" $ GOTO TMPDB_END_DIRECTORY_PROCESSING $! $TMPDB_SKIP_TOP_LEVEL_DIRECTORY: $! $ CDD$TEMPLATEDB_DIRECTORY_FILE := - 'CDD$TEMPLATEDB_DIRECTORY_FILE'"]"'CDD$CURR_DIR'.DIR" $! $TMPDB_END_DIRECTORY_PROCESSING: $! $!----------------------------------------------------------------------------! $! $! These comments regarding ACLs are left-over from previous edits to this $! file. I have left them here to maintain the history (Karen McKeen): $! $! Set the anchor directory file protection. $! CDD$SYSTEM must recieve all RMU privileges. [*,*] must be able to $! restore the template. $! For SPR ICAX42273, the ACLs are deleted and completely reset on $! the template. $! Delete the existing ACL on the template directory because if you $! don't, you get the ACLs you're adding here on top of whatever $! ACLs the user had specified or had been given by default. $! This causes a mishmash of ACLs that are mostly out of order. $! This is confusing and could potentially cause problems. kc - 7/19/94 $! $!----------------------------------------------------------------------------! $! Display the anchor directory ACLs to the user. Let the user know $! the ACLs will be deleted and prompt to see if the user wants to $! continue. $! $ DIRECTORY/ACL 'CDD$TEMPLATE_DIRECTORY_FILE' $! $ wr "" $ wr "The ACLs listed above on your anchor directory will be deleted." $ inquire yn "Do you want to continue? Enter Y to continue" $ if yn .nes. "Y" .and. yn .nes. "y" then goto failure $! $! For the template repository directory - delete existing ACLs, define $! the standard set of ACLs, and set the file protections. $! $ SET ACL/DELETE 'CDD$TEMPLATE_DIRECTORY_FILE' $ SET ACL 'CDD$TEMPLATE_DIRECTORY_FILE' - /ACL=(- (IDENTIFIER=CDD$SYSTEM,- ACCESS=READ+WRITE+EXECUTE+DELETE+CONTROL+- BIT_5+BIT_6+BIT_7+BIT_8+BIT_9+BIT_10+- BIT_11+BIT_12+BIT_13+BIT_14+BIT_15+- BIT_16+BIT_17+BIT_18),- (IDENTIFIER=[*,*],- ACCESS=READ+BIT_7+BIT_8+BIT_14),- (IDENTIFIER=CDD$SYSTEM,- OPTIONS=DEFAULT+NOPROPAGATE,- ACCESS=READ+WRITE+EXECUTE+DELETE+CONTROL+- BIT_5+BIT_6+BIT_7+BIT_8+BIT_9+BIT_10+- BIT_11+BIT_12+BIT_13+BIT_14+BIT_15+- BIT_16+BIT_17+BIT_18),- (IDENTIFIER=[*,*],- OPTIONS=DEFAULT+NOPROPAGATE,- ACCESS=READ+BIT_7+BIT_8+BIT_14)- ) $ SET PROTECTION=(S:RWED,O:RWED,G,W) 'CDD$TEMPLATE_DIRECTORY_FILE' $! $! For the template repository database directory - delete existing ACLs, $! define the standard set of ACLs, and set the file protections. $! $ SET ACL/DELETE 'CDD$TEMPLATEDB_DIRECTORY_FILE' $ SET ACL 'CDD$TEMPLATEDB_DIRECTORY_FILE' - /ACL=(- (IDENTIFIER=CDD$SYSTEM,- ACCESS=READ+WRITE+EXECUTE+DELETE+CONTROL+- BIT_5+BIT_6+BIT_7+BIT_8+BIT_9+BIT_10+- BIT_11+BIT_12+BIT_13+BIT_14+BIT_15+- BIT_16+BIT_17+BIT_18),- (IDENTIFIER=[*,*],- ACCESS=READ+BIT_7+BIT_8+BIT_14),- (IDENTIFIER=CDD$SYSTEM,- OPTIONS=DEFAULT+NOPROPAGATE,- ACCESS=READ+WRITE+EXECUTE+DELETE+CONTROL+- BIT_5+BIT_6+BIT_7+BIT_8+BIT_9+BIT_10+- BIT_11+BIT_12+BIT_13+BIT_14+BIT_15+- BIT_16+BIT_17+BIT_18),- (IDENTIFIER=[*,*],- OPTIONS=DEFAULT+NOPROPAGATE,- ACCESS=READ+BIT_7+BIT_8+BIT_14)- ) $ SET PROTECTION=(S:RWED,O:RWED,G,W) 'CDD$TEMPLATEDB_DIRECTORY_FILE' $! $! Set the ACLs and file protections for various template repository database $! files BEFORE creating the template repository database backup file. $! $ SET ACL 'CDD$TEMPLATE_ANCHOR'CDD$DATABASE.RDB- /ACL=(- (IDENTIFIER=CDD$SYSTEM,- ACCESS=READ+WRITE+EXECUTE+DELETE+CONTROL+- BIT_5+BIT_6+BIT_7+BIT_8+BIT_9+BIT_10+- BIT_11+BIT_12+BIT_13+BIT_14+BIT_15+- BIT_16+BIT_17+BIT_18),- (IDENTIFIER=[*,*],- ACCESS=READ+BIT_7+BIT_8+BIT_14)- ) $ SET PROTECTION=(O:RWED) 'TEMPLATE'CDD$DATABASE.*;* $! $! Set the database snapshot allocation to 50. When the repository was $! created, the snapshot file is larger than it needs to be. Since we are $! about to create the template repository database backup file, we want $! the snapshot area to be of minimal size (to conserve disk space). $! $ DEFINE/USER CDD$RDB_DATABASE 'TEMPLATE'CDD$DATABASE $ DEFINE/USER SYS$OUTPUT NL: $ MCR RDO CHANGE DATABASE FILE CDD$RDB_DATABASE CHANGE STORAGE AREA CDD$DATA SNAP ALLOC 50. EXIT $! $! Create the template repository database backup file. $! $ CDD$RMU_COMMAND == F$TRNLNM ("RDMS$RMU_VARIANT") $ IF CDD$RMU_COMMAND .EQS "" THEN CDD$RMU_COMMAND == "RMU" $ 'CDD$RMU_COMMAND/BACKUP/NOLOG 'TEMPLATE'CDD$DATABASE - 'TEMPLATEDB'CDD$DATABASE $! $! Delete the original database files. User repositories will now be $! created by restoring from the template repository database backup file. $! $ SET PROTECTION=(S,O:RWED,G,W) - 'TEMPLATE'CDD$DATA.RDA;0,- 'TEMPLATE'CDD$DATA.SNP;0,- 'TEMPLATE'CDD$DATABASE.RDA;0,- 'TEMPLATE'CDD$DATABASE.RDB;0,- 'TEMPLATE'CDD$DATABASE.SNP; $ DELETE/NOCONFIRM/NOLOG - 'TEMPLATE'CDD$DATA.RDA;0,- 'TEMPLATE'CDD$DATA.SNP;0,- 'TEMPLATE'CDD$DATABASE.RDA;0,- 'TEMPLATE'CDD$DATABASE.RDB;0,- 'TEMPLATE'CDD$DATABASE.SNP; $! $! Set the ACLs and file protections for the template repository database $! backup file. $! $ SET ACL 'TEMPLATEDB'*.RBF;- /ACL=(- (IDENTIFIER=CDD$SYSTEM,- ACCESS=READ+WRITE+EXECUTE+DELETE+CONTROL),- (IDENTIFIER=[*,*],- ACCESS=READ)- ) $ SET PROTECTION=(W:R) 'TEMPLATEDB'*.RBF; $! $! Set the ACLs and file protections for the directory files in the $! template repository directory (CONTEXTS.DIR, DELTAFILES.DIR, and $! PARTITIONS.DIR). $! $ SET ACL 'TEMPLATE'*.DIR;- /ACL=(- (IDENTIFIER=CDD$SYSTEM,- ACCESS=READ+WRITE+EXECUTE+DELETE+CONTROL),- (IDENTIFIER=[*,*],- ACCESS=READ),- (IDENTIFIER=CDD$SYSTEM,- OPTIONS=DEFAULT+NOPROPAGATE,- ACCESS=READ+WRITE+EXECUTE+DELETE+CONTROL),- (IDENTIFIER=[*,*],- OPTIONS=DEFAULT+NOPROPAGATE,- ACCESS=READ)- ) $ SET PROTECTION=(S:RWED,O:RWED,G,W) 'TEMPLATE'*.DIR; $! $!----------------------------------------------------------------------------! $! Let the user know the template was built successfully. $! $ wr "" $ wr "Template built successfully. To use the template," $ wr "define the logicals CDD$TEMPLATE and CDD$TEMPLATEDB to be:" $ wr P1, " and ", P2, " respectively." $ wr "" $ exit 1 $! $!----------------------------------------------------------------------------! $! Process failure conditions. $! $FAILURE: $ cddx$$status = $status $ write sys$output "" $ write sys$output "********************************************************" $ write sys$output "" $ write sys$output " Error creating template repository" $ write sys$output "" $ write sys$output "********************************************************" $ write sys$output "" $ exit cddx$$status $CTRL_Y_ABORT: $ write sys$output "" $ write sys$output "********************************************************" $ write sys$output "" $ write sys$output " Template creation aborted by CTRL/Y" $ write sys$output "" $ write sys$output "********************************************************" $ write sys$output "" $ exit 0 .or. %x10000000 $! $!----------------------------------------------------------------------------!