home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / w / wr06015.zip / WR06015.CMD < prev    next >
OS/2 REXX Batch file  |  1993-01-27  |  18KB  |  481 lines

  1. /****************************************************************************
  2.  
  3.         Module Name             = WR06015.CMD
  4.  
  5.         Descriptive Name        = SelectPak 15 (Database PC DOS Requester)
  6.                                   install tool
  7.  
  8.         Copyright               = 04G1049  (C) Copyright IBM Corp. 1988, 1991.
  9.                                   All rights reserved.
  10.                                   US Government Users Restricted Rights -
  11.                                   Use, duplication or disclosure restricted by
  12.                                   GSA ADP Schedule Contract with IBM Corp.
  13.  
  14.                                   Licensed Materials - Property of IBM
  15.  
  16.         Function                = Installation tool for SelectPak 015
  17.  
  18.         Operating System        = OS/2 Extended Services
  19.  
  20. ****************************************************************************/
  21.  
  22. signal on halt          /* call HALT: routine on CTRL-BREAK */
  23. "echo off"
  24.  
  25. /*************************************************/
  26. /* Read in command line arguements if they exist */
  27. /*************************************************/
  28. parse upper arg Base_Drive Update_Drive Backed .
  29.  
  30.  
  31. /***********************************************************/
  32. /* Verify that the Database SelectPak message file exists  */
  33. /***********************************************************/
  34. MSG_FILE = stream('WR06DBM.MSG' , 'c' , 'query exists')
  35. if MSG_FILE = "" then
  36.         do
  37.         say " ERROR: could not find message file WR06DBM.MSG "
  38.         signal End
  39.         end
  40.  
  41. /***************************************************/
  42. /* Read the message file into an array of messages */
  43. /***************************************************/
  44. do while lines(MSG_FILE) \= 0    /* While not at EOF  */
  45.  
  46.         text_of_message = MSG_Parse(linein(MSG_FILE))
  47.         MSG.message_number = text_of_message
  48.  
  49. end                              /* End of While loop */
  50.  
  51.  
  52. /**************************************/
  53. /*  Close the message file            */
  54. /**************************************/
  55. RC = stream('WR06DBM.MSG' , 'c' , 'close')
  56.  
  57. start:
  58. "cls"
  59.  
  60. /****************************************/
  61. /*  One possible input parameter is '?' */
  62. /*  Display the help panel in this case */
  63. /****************************************/
  64. if Base_Drive = "?" then signal syntax
  65.  
  66. /*************************/
  67. /*  Introductory panel   */
  68. /*************************/
  69. say
  70. say
  71. say centre(MSG.50,50)
  72. say centre(Create_MSG(MSG.01,'015'),50)
  73. say centre(MSG.02,50)
  74. say
  75. say
  76.  
  77. /***************************************************/
  78. /* The Base Drive letter is the Drive letter that  */
  79. /* contains the Base Operating System.             */
  80. /***************************************************/
  81. get_Base_Drive:
  82. if Base_Drive \= "" then signal got_Base_Drive
  83. call charout ,"  "MSG.03" "
  84. parse upper linein Base_Drive
  85. if Base_Drive = "" then
  86.         do
  87.         say "  "MSG.04
  88.         signal get_Base_Drive
  89.         end
  90.  
  91. got_Base_Drive:
  92. /*************************************************/
  93. /* Verify that the \OS2\INSTALL directory exists */
  94. /* on the drive specified by the user            */
  95. /*************************************************/
  96. "dir "Base_Drive":\OS2\INSTALL                                   >  NUL  2>>&1"
  97. if RC \= 0 then
  98.         do
  99.         say
  100.         say "  "Create_MSG2(MSG.05,Base_Drive,'\OS2\INSTALL')
  101.         say "  "Create_MSG(MSG.06,'\OS2\INSTALL')
  102.         say "  "MSG.07
  103.         parse linein ignore
  104.         Base_Drive = ""
  105.         signal get_Base_Drive
  106.         end
  107.  
  108. /***************************************************/
  109. /* The log varible will contain the full path name */
  110. /* of the output log.  The output log will contain */
  111. /* any error messages from this installation       */
  112. /***************************************************/
  113. LOG = ""Base_Drive":\OS2\INSTALL\WR06015.LOG"
  114. say
  115. say "  "Create_MSG(MSG.08,LOG)
  116. say
  117. say
  118.  
  119. /******************************************************/
  120. /* The Update Drive letter is the letter of the Drive */
  121. /* containing the Database system directory that      */
  122. /* you wish to upgrade.                               */
  123. /******************************************************/
  124. get_Update_Drive:
  125. if Update_Drive \= "" then signal got_Update_Drive
  126. call charout ,"  "MSG.09" "
  127. parse upper linein Update_Drive
  128. if Update_Drive = "" then
  129.         do
  130.         say "  "MSG.04
  131.         signal get_Update_Drive
  132.         end
  133.  
  134. got_Update_Drive:
  135. /*************************************************/
  136. /* Verify that the \DBDRQLIB directory exists    */
  137. /* on the drive specified by the user            */
  138. /*************************************************/
  139. "dir "Update_Drive":\DBDRQLIB                                    >  NUL  2>>&1"
  140. if RC \= 0 then
  141.         do
  142.         say
  143.         say "  "Create_MSG2(MSG.05,Update_Drive,'\DBDRQLIB')
  144.         say "  "Create_MSG(MSG.06,'\DBDRQLIB')
  145.         say "  "MSG.07
  146.         parse linein ignore
  147.         Update_Drive = ""
  148.         signal get_Update_Drive
  149.         end
  150.  
  151. /***********************************************************/
  152. /* Display to the user, the directory that will be updated */
  153. /***********************************************************/
  154. say
  155. say "  "Create_MSG2(MSG.12,Update_Drive,'DBDRQLIB')
  156. say
  157.  
  158. Backup:
  159. /***********************************************************/
  160. /* Ask the user if they would like the old files to be     */
  161. /* backed up to the current directory.                     */
  162. /***********************************************************/
  163. say
  164. say "  "Create_MSG(MSG.13,'0.69')
  165. call charout , "  "Create_MSG(MSG.14,Backed)
  166.  
  167. if Backed \= "" then signal got_Backup
  168. parse upper linein Backed
  169. got_Backup:
  170. if Backed  = "0" then signal verify
  171. if Backed \= "1" then              /* Only 0 and 1 are acceptable inputs */
  172.         do
  173.         say
  174.         say "  "MSG.15
  175.         Backed = ""
  176.         signal Backup
  177.         end
  178.  
  179. verify:
  180. /*************************************************/
  181. /* Ask for verification of the input parameters. */
  182. /* This is done even if the user is using the    */
  183. /* command line interface.                       */
  184. /*************************************************/
  185. say
  186. say
  187. call charout ,"  "MSG.16" "
  188. parse upper linein Verified
  189. if Verified  = "0" then        /* If the user answers NO to verification */
  190.         do                     /* then reset all of the input parameters */
  191.         Base_Drive = ""        /* and go back to the start.              */
  192.         Update_Drive = ""
  193.         Backed = ""
  194.         Verified = ""
  195.         signal start
  196.         end
  197.  
  198. if Verified \= "1" then        /* Only 0 and 1 are acceptable inputs */
  199.         do
  200.         say
  201.         say "  "MSG.15
  202.         Verified = ""
  203.         signal verify
  204.         end
  205. say
  206.  
  207. /*****************************************************************************/
  208. /*                                                                           */
  209. /* Set up the following variables:                                           */
  210. /* PDRLEVEL: The fully qualified path name of the SYSLEVEL file for DOS REQ  */
  211. /* WDCLEVEL: The fully qualified path name of the SYSLEVEL file for WIN REQ  */
  212. /* DBD_PATH: The fully qualified path name of the DBDRQLIB      directory    */
  213. /*                                                                           */
  214. /*****************************************************************************/
  215.  
  216. DBD_PATH = Update_Drive":\DBDRQLIB"
  217. PDRLEVEL = DBD_PATH"\SYSLEVEL.PDR"
  218. WDCLEVEL = DBD_PATH"\SYSLEVEL.WDC"
  219.  
  220.  
  221. /*******************************************************************/
  222. /* Check to see that the customer has WR06000 or WR06010 installed */
  223. /* by reading the syslevel file.  As well, a customer can have     */
  224. /* DOS Requester and/or Windows Requester.                         */
  225. /*******************************************************************/
  226. PDR_EXIST = stream(PDRLEVEL , 'c' , 'query exists')
  227. WDC_EXIST = stream(WDCLEVEL , 'c' , 'query exists')
  228.  
  229. /*******************************************************************/
  230. /* If neither DOS requester, nor Windows Requestor is installed    */
  231. /* then notify the user and exit.                                  */
  232. /*******************************************************************/
  233. if PDR_EXIST = "" & WDC_EXIST = "" then
  234.         do
  235.         say
  236.         say MSG.51
  237.         say MSG.52
  238.         say
  239.         signal End
  240.         end
  241.  
  242. /************************************************************/
  243. /* If Dos Requester is installed then read the syslevel     */
  244. /* file check to see if the proper service level is there   */
  245. /************************************************************/
  246.  
  247. if PDR_EXIST \= "" then
  248. do
  249.         firstline = linein(PDRLEVEL)
  250.  
  251.         level = substr(firstline,45,7)
  252.  
  253.         if level \= 'WR06010' & level \= 'WR06000' then
  254.         do
  255.                   say
  256.                   say MSG.53
  257.                   say MSG.54
  258.                   say MSG.55
  259.                   say
  260.                   signal End
  261.         end
  262. end
  263.  
  264.  
  265. /************************************************************/
  266. /* If Windows Requester is installed then read the syslevel */
  267. /* file check to see if the proper service level is there   */
  268. /************************************************************/
  269. if WDC_EXIST \= "" then
  270. do
  271.         firstline = linein(WDCLEVEL)
  272.  
  273.         level = substr(firstline,45,7)
  274.  
  275.         if level \= 'WR06010' & level \= 'WR06000' then
  276.         do
  277.                   say
  278.                   say MSG.56
  279.                   say MSG.57
  280.                   say MSG.58
  281.                   say
  282.                   signal End
  283.         end
  284. end
  285.  
  286.  
  287.  
  288. /******************************************************/
  289. /* Close the syslevel files so that it can be updated */
  290. /******************************************************/
  291. RC = stream(PDRLEVEL , 'c' , 'close')
  292. RC = stream(WDCLEVEL , 'c' , 'close')
  293.  
  294. "echo.                                                           >> "LOG" 2>>&1"
  295. "echo " centre(MSG.50,50)                                     "  >> "LOG" 2>>&1"
  296. "echo " centre(Create_MSG(MSG.01,'015'),50)                   "  >> "LOG" 2>>&1"
  297. "echo.                                                           >> "LOG" 2>>&1"
  298. "echo.                                                           >> "LOG" 2>>&1"
  299. "echo.                                                           >> "LOG" 2>>&1"
  300.  
  301. /***********************************************************************/
  302. /* If the user had chosen to backup the old version of the files,      */
  303. /* then copy the files that will be changing from the SQLLIB directory */
  304. /* to the current directory.                                           */
  305. /***********************************************************************/
  306. if Backed  = "0" then signal skip_Backup
  307. "echo "MSG.20 DBD_PATH"\PCDRDLL.DLL                              >>"LOG" 2>>&1"
  308. "copy "DBD_PATH"\PCDRDLL.DLL                                     >>"LOG" 2>>&1"
  309.  
  310. /*********************************************/
  311. /* Back up the any syslevel files that exist */
  312. /*********************************************/
  313. if PDR_EXIST \= "" then
  314. do
  315.     "echo "MSG.20  PDRLEVEL                                   " >>"LOG" 2>>&1"
  316.     "copy "PDRLEVEL" SYSLVOLD.PDR                               >>"LOG" 2>>&1"
  317. end
  318.  
  319. if WDC_EXIST \= "" then
  320. do
  321.     "echo "MSG.20  WDCLEVEL                                   " >>"LOG" 2>>&1"
  322.     "copy "WDCLEVEL" SYSLVOLD.WDC                               >>"LOG" 2>>&1"
  323. end
  324.  
  325. "echo "MSG.20 DBD_PATH"\PCDRSTAT.LIB                             >>"LOG" 2>>&1"
  326. "copy "DBD_PATH"\PCDRSTAT.LIB                                    >>"LOG" 2>>&1"
  327. "echo "MSG.20 DBD_PATH"\SQLENV_.H                                >>"LOG" 2>>&1"
  328. "copy "DBD_PATH"\SQLENV_.H                                       >>"LOG" 2>>&1"
  329. "echo "MSG.20 DBD_PATH"\SQLLOGF2.EXE                             >>"LOG" 2>>&1"
  330. "copy "DBD_PATH"\SQLLOGF2.EXE                                    >>"LOG" 2>>&1"
  331. "echo "MSG.20 DBD_PATH"\SQLLOGN2.EXE                             >>"LOG" 2>>&1"
  332. "copy "DBD_PATH"\SQLLOGN2.EXE                                    >>"LOG" 2>>&1"
  333. "echo "MSG.20 DBD_PATH"\SQLUPEXP.BND                             >>"LOG" 2>>&1"
  334. "copy "DBD_PATH"\SQLUPEXP.BND                                    >>"LOG" 2>>&1"
  335. "echo "MSG.20 DBD_PATH"\SQLUPGSI.BND                             >>"LOG" 2>>&1"
  336. "copy "DBD_PATH"\SQLUPGSI.BND                                    >>"LOG" 2>>&1"
  337. "echo "MSG.20 DBD_PATH"\SQLUPICI.BND                             >>"LOG" 2>>&1"
  338. "copy "DBD_PATH"\SQLUPICI.BND                                    >>"LOG" 2>>&1"
  339. "echo "MSG.20 DBD_PATH"\SQLUPICT.BND                             >>"LOG" 2>>&1"
  340. "copy "DBD_PATH"\SQLUPICT.BND                                    >>"LOG" 2>>&1"
  341. "echo "MSG.20 DBD_PATH"\SQLUPIWI.BND                             >>"LOG" 2>>&1"
  342. "copy "DBD_PATH"\SQLUPIWI.BND                                    >>"LOG" 2>>&1"
  343. "echo "MSG.20 DBD_PATH"\SQLUPMPM.BND                             >>"LOG" 2>>&1"
  344. "copy "DBD_PATH"\SQLUPMPM.BND                                    >>"LOG" 2>>&1"
  345. "echo "MSG.20 DBD_PATH"\SQLUPXPM.BND                             >>"LOG" 2>>&1"
  346. "copy "DBD_PATH"\SQLUPXPM.BND                                    >>"LOG" 2>>&1"
  347.  
  348. skip_Backup:
  349.  
  350.  
  351. /***************************************************************************/
  352. /* Unzip the SQLLIB files   -n means only unzip newer files                */
  353. /*                          -d means create directories stored in ZIP file */
  354. /***************************************************************************/
  355. "PKUNZIP2 -n -d WR06015.SPK "DBD_PATH"\                           >>"LOG" 2>>&1"
  356. if RC = 0 then signal Zip_Done1
  357.  
  358. if RC = 11 then  /* Make a note in the log if no files were unziped */
  359.         do
  360.         say
  361.         say "  "Create_MSG(MSG.21,DBD_PATH)
  362.         signal Zip_Done1
  363.         end
  364.  
  365. /****************************************************************************/
  366. /* If there were any errors then tell the user that there were problems.    */
  367. /****************************************************************************/
  368. say "  "MSG.22
  369. say "  "Create_MSG(MSG.23,LOG)
  370. say "  "
  371. say "  "MSG.07
  372. parse linein ignore
  373.  
  374. Zip_Done1:
  375.  
  376. /***********************************************************************/
  377. /* Update the SYSLEVEL fileS to indicate a SelectPak has been applied  */
  378. /***********************************************************************/
  379. "echo "MSG.59"                                                   >>"LOG" 2>>&1"
  380.  
  381. if WDC_EXIST \= "" then
  382. do
  383.      "attrib -r "WDCLEVEL                                      " >  NUL  2>>&1"
  384.      "copy "DBD_PATH"\SYSLEVEL.WD1 "WDCLEVEL                   " >>"LOG" 2>>&1"
  385.      "attrib +r "WDCLEVEL                                      " >  NUL  2>>&1"
  386. end
  387.  
  388. if PDR_EXIST \= "" then
  389. do
  390.      "attrib -r "PDRLEVEL                                      " >  NUL  2>>&1"
  391.      "copy "DBD_PATH"\SYSLEVEL.PD1 "PDRLEVEL                   " >>"LOG" 2>>&1"
  392.      "attrib +r "PDRLEVEL                                      " >  NUL  2>>&1"
  393. end
  394.  
  395. "del  "DBD_PATH"\SYSLEVEL.WD1                                    >  NUL  2>>&1"
  396. "del  "DBD_PATH"\SYSLEVEL.PD1                                    >  NUL  2>>&1"
  397.  
  398.  
  399. Done:
  400.  
  401. /**************************************************************/
  402. /* The installation is now complete, inform the user and exit */
  403. /**************************************************************/
  404. say
  405. say centre(Create_MSG(MSG.25,'WR06015'),50)
  406. say
  407. signal End
  408.  
  409. /***********************************************************/
  410. /* This routine will be called if the user uses CTRL-BREAK */
  411. /***********************************************************/
  412. HALT:
  413. say
  414. say
  415. say MSG.26
  416. say MSG.27
  417. say
  418. signal End
  419.  
  420. /* Help panel */
  421. syntax:
  422. say
  423. say "  "Create_MSG(MSG.28,'WR06015')
  424. say
  425. say "  "MSG.29
  426. say "      "MSG.30
  427. say "         "Create_MSG(MSG.31,'\OS2\INSTALL')
  428. say "      "MSG.32
  429. say "         "Create_MSG(MSG.31,'\DBDRQLIB')
  430. say "      "MSG.34
  431. say "         "Create_MSG(MSG.35,'0.69')
  432. say "      "MSG.36
  433. say "         "MSG.37
  434. say
  435. say
  436. say "  "Create_MSG(MSG.38,'WR06015')
  437. say "      WR06015 C C 1                                                 "
  438. say "  "MSG.39
  439. say
  440. say
  441. signal End
  442.  
  443.  
  444. /*****************************************************************/
  445. /* This routine will take a message and a variable and place the */
  446. /* variable in the proper position in the string.                */
  447. /*****************************************************************/
  448. Create_MSG:
  449. parse arg MESSAGE,VARIABLE
  450. PART1 = SUBSTR(MESSAGE,1,POS('%1',MESSAGE)-1)
  451. PART2 = SUBSTR(MESSAGE,POS('%1',MESSAGE)+2)
  452. RETURN PART1 || VARIABLE || PART2
  453.  
  454.  
  455. /*********************************************************************/
  456. /* This routine will take a message and two variables and place the  */
  457. /* variables in their proper positions in the string.                */
  458. /*********************************************************************/
  459. Create_MSG2:
  460. parse arg MESSAGE,VARIABLE1,VARIABLE2
  461. POS1 = POS('%1',MESSAGE)
  462. POS2 = POS('%2',MESSAGE)
  463. PART1 = SUBSTR(MESSAGE,1,POS1-1)
  464. PART2 = SUBSTR(MESSAGE,POS1+2,POS2-POS1-2)
  465. PART3 = SUBSTR(MESSAGE,POS2+2)
  466. RETURN PART1 || VARIABLE1 || PART2 || VARIABLE2 || PART3
  467.  
  468.  
  469. /*******************************************************************/
  470. /* This routine will take a message line from the message file     */
  471. /* and parse it into a message number and a text string            */
  472. /*******************************************************************/
  473. MSG_Parse:
  474. parse arg MESSAGE
  475. TEXT = SUBSTR(MESSAGE,POS(' ',MESSAGE)+1)
  476. message_number = SUBSTR(MESSAGE,1,POS(' ',MESSAGE)-1)
  477. RETURN TEXT
  478.  
  479.  
  480. End:
  481.