home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 29 Fixes_o / 29-Fixes_o.zip / ip7005.zip / SRV.CMD < prev   
OS/2 REXX Batch file  |  1993-10-29  |  37KB  |  998 lines

  1. /****************************************************************************
  2.  
  3.         Module Name             = SRV.CMD
  4.  
  5.         Descriptive Name        = Select Pak IP07005 ( LAN Server )
  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 Select Pak
  17.  
  18.         Operating System        = OS/2 2.x
  19.  
  20. ****************************************************************************/
  21.  
  22. signal on halt          /* call HALT: routine on CTRL-BREAK */
  23. "echo off"
  24. final_rc = 0            /* preset return code */
  25. /*************************************************/
  26. /* Set the following variables to substitute the */
  27. /* correct SelectPak data                        */
  28. /*************************************************/
  29. Prod_id.1 = "SRV"             /* extension for syslevel files        */
  30. Prod_dir = "IBMLAN"
  31. Prod_title = "MSG.86"
  32. SPak = "IP07005"
  33. Backup_size = '170k'
  34. subdirs.0 = '2'                  /* number of subdirectories in product */
  35. subdirs.1 = 'IBMLAN'          /* subdirectories in product */
  36. subdirs.2 = 'SERVICES'
  37. subdirs.3 = 'IBMLAN\SERVICES'
  38. syslvl_prefix.0 = '1'         /* number of syslevels to be updated */
  39. syslvl_prefix.1 = 'IP0'       /* syslevel prefix  for prereqs      */
  40. /***********************************************************/
  41.  
  42. /*************************************************/
  43. /* Read in command line arguments if they exist  */
  44. /*************************************************/
  45. parse upper arg var1 var2 var3 var4 var5 var6 rest
  46.  
  47. /***********************************************************/
  48. /*     Verify that the Select Pak message file exists      */
  49. /***********************************************************/
  50. MSG_FILE = stream('SELPAK.MSG' , 'c' , 'query exists')
  51. if MSG_FILE = "" then
  52.   do
  53.   say " ERROR: could not find message file SELPAK.MSG "
  54.   signal End
  55.   end
  56.  
  57. /***************************************************/
  58. /* Read the message file into an array of messages */
  59. /***************************************************/
  60. do while lines(MSG_FILE) \= 0    /* While not at EOF  */
  61.         Message = linein(MSG_FILE)
  62.         parse var Message message_number text_of_message
  63.         MSG.message_number = text_of_message
  64.  
  65. end                              /* End of While loop */
  66.  
  67.  
  68. /**************************************/
  69. /*  Close the message file            */
  70. /**************************************/
  71. RC = stream('SELPAK.MSG' , 'c' , 'close')
  72.  
  73.  
  74. /****************************************/
  75. /*  One possible input parameter is '?' */
  76. /*  Display the help panel in this case */
  77. /****************************************/
  78. backup_dir = '\'prod_id.1'_BAK'
  79. if var1 = "?" then signal syntax
  80.  "cls"
  81.  
  82. /*************************/
  83. /*  Introductory panel   */
  84. /*************************/
  85. say
  86. say
  87. say center(value(prod_title),80)
  88. say center(Create_MSG(MSG.01,SPak),80)
  89. say center(Create_MSG(MSG.02,prod_id.1),80)
  90. say
  91. say        " Please shut down LAN Server before applying this SelectPak "
  92. say        " ( Ctrl_Break, then Enter to exit ) "
  93. say
  94. say
  95.  
  96. Source_path = ""
  97. Base_Drive = ""
  98. Update_Drive = ""
  99. RPL_Drive = ""
  100. Log_File = ""
  101. Verified = ""
  102. Backup_dir = ""
  103. Backed = ""
  104. First_lock = "1"
  105. Filename. = "aaa"
  106. Prod_msg = value(prod_title)
  107. result=0
  108. token.1 = var1
  109. token.2 = var2
  110. token.3 = var3
  111. token.4 = var4
  112. token.5 = var5
  113. token.6 = var6
  114. token.7 = rest
  115. do i = 1 to 7 until token.i = ""
  116.    select
  117.        when substr(token.i,1,3) = "/B:" then
  118.          Base_Drive = substr(token.i,4,,)
  119.       when substr(token.i,1,3) = "/T:" then
  120.          Update_drive = substr(token.i,4,,)
  121.       when substr(token.i,1,3) = "/D:" then
  122.          RPL_drive = substr(token.i,4,,)
  123.       when substr(token.i,1,3) = "/K:" then
  124.          Backed = substr(token.i,4,,)
  125.       when substr(token.i,1,3) = "/S:" then
  126.          Source_path = substr(token.i,4,,)
  127.       when substr(token.i,1,3) = "/V:" then
  128.          Verified = substr(token.i,4,,)
  129.       otherwise
  130.    end       /* end select */
  131. end          /* do loop */
  132.  
  133. start:
  134.  
  135. /***************************************************/
  136. /* The Base Drive letter is the Drive letter that  */
  137. /* contains the Base Operating System.             */
  138. /***************************************************/
  139. if Base_Drive \= "" then signal got_Base_Drive
  140. get_Base_Drive:
  141. call charout ,"  "MSG.03"  "
  142. parse upper linein Base_Drive
  143. got_Base_Drive:
  144. Base_Drive = strip(Base_drive,T,':')   /* remove trailing colon */
  145.  
  146. /*************************************************/
  147. /* Verify that the \OS2\INSTALL directory exists */
  148. /* on the drive specified by the user            */
  149. /*************************************************/
  150.  
  151. "dir "Base_Drive":\OS2\INSTALL > NUL  2>>&1"
  152. if RC \= 0 then
  153.    do
  154.    say
  155.    say "  "Create_MSG(MSG.05,Base_Drive':\OS2\INSTALL')"  "
  156.    Base_Drive = ""
  157.    signal get_Base_Drive
  158.    end
  159. Base_done:
  160. /***************************************************/
  161. /* The log varible will contain the full path name */
  162. /* of the output log.  The output log will contain */
  163. /* any error messages from this installation       */
  164. /***************************************************/
  165. log_file = ""Base_drive":\OS2\INSTALL\"SPak".LOG"
  166. /******************************************************/
  167. /* The Update Drive letter is the letter of the Drive */
  168. /* containing the Database system directory that      */
  169. /* you wish to upgrade.                               */
  170. /******************************************************/
  171. get_Update_Drive:
  172. if Update_Drive \= "" then signal got_Update_Drive
  173. call charout ,"  "MSG.09"   "
  174. parse upper linein Update_Drive
  175. got_Update_Drive:
  176. Update_drive = STRIP(Update_drive,T,':')     /* remove trailing colon */
  177.  
  178. /*************************************************/
  179. /* Verify that the Product directory exists      */
  180. /* on the drive specified by the user            */
  181. /*************************************************/
  182. "dir "Update_Drive":\"Prod_dir" > NUL  2>>&1"
  183. if RC \= 0 then
  184.   do
  185.   say
  186.   say "  "Create_MSG(MSG.05,Update_Drive':\'Prod_dir)"  "
  187.   Update_Drive = ""
  188.   signal get_Update_Drive
  189.   end
  190.  
  191. /******************************************************/
  192. /* The Source path is the path where the updates      */
  193. /* reside.                                            */
  194. /******************************************************/
  195. get_Source_Path:
  196. if Source_Path \= "" then signal got_Source_Path
  197. call charout,"  "Create_MSG(MSG.10,SPak'.SPK')" "
  198. parse upper linein Source_Path
  199. got_Source_Path:
  200. /*************************************************/
  201. /* Verify that the zip file exists               */
  202. /* on the path specified by the user             */
  203. /*************************************************/
  204. if length(Source_Path) = 1 then     /* allow user to enter */
  205.    Source_Path = Source_Path':'     /* drive letter only   */
  206. source_file = stream(source_path'\'SPak'.SPK','c','query exists')
  207. if source_file = "" then
  208.   do
  209.   say
  210.   say "  "Create_MSG(MSG.11,source_path'\'SPak'.SPK')" "
  211.   Source_Path = ""
  212.   signal get_Source_Path
  213.   end
  214.  
  215. /******************************************************/
  216. /* The RPL Drive letter is the letter of the Drive                   */
  217. /* containing the RPL directory to be upgraded                      */
  218. /******************************************************/
  219. get_RPL_Drive:
  220. if RPL_Drive \= "" then signal got_RPL_Drive
  221. call charout ,"  "MSG.75"   "
  222. parse upper linein RPL_Drive
  223. got_RPL_Drive:
  224. if RPL_Drive = 0 then signal Get_Backup
  225. if RPL_Drive = "" then signal get_RPL_Drive
  226. RPL_drive = STRIP(RPL_drive,T,':')     /* remove trailing colon */
  227.  
  228. /*************************************************/
  229. /* Verify that the Product directory exists      */
  230. /* on the drive specified by the user            */
  231. /*************************************************/
  232. RPL_Path = RPL_drive':\IBMLAN\RPL\'subdirs.3
  233. "dir "RPL_Path" > NUL  2>>&1"
  234. if RC \= 0 then
  235.   do
  236.   say
  237.   say "  "Create_MSG(MSG.05,RPL_Path)"  "
  238.   RPL_Drive = ""
  239.   signal get_RPL_Drive
  240.   end
  241.  
  242. /*************************************************/
  243. /* Set up backup directory for verification      */
  244. /*************************************************/
  245. Get_backup:
  246. backup_dir = Update_drive':\'prod_id.1'_BAK'
  247. if Backed \= "" then signal got_Backup
  248. /***********************************************************/
  249. /* Ask the user if they would like the old files to be     */
  250. /* backed up to the default directory or specify their own */
  251. /***********************************************************/
  252. say
  253. say "  "Create_MSG(MSG.13,Backup_size)
  254. ask_Backup:
  255. say "  "MSG.14
  256. /* call charout , "  "Create_MSG(MSG.35,Backup_dir) */
  257. say "        "Create_MSG(MSG.35,Backup_dir)"            "
  258. say "        "MSG.72
  259. parse linein Backed
  260. if Backed = "" then signal ask_Backup
  261. got_Backup:
  262. if backed \= '0' & backed \= '1' then
  263.   do
  264.   backup_dir = backed
  265.     end
  266.  
  267. start_verify:
  268. /***********************************************************/
  269. /* Display the log file name                                                                         */
  270. /***********************************************************/
  271. say
  272. say "  "Create_MSG(MSG.08,log_file)"  "
  273. /***********************************************************/
  274. /* Display the directory that will be updated                                                */
  275. /***********************************************************/
  276. say "  "Create_MSG(MSG.12,Update_Drive':\'Prod_dir)"  "
  277. /***********************************************************/
  278. /***********************************************************/
  279. /* Display the RPL path for update data                    */
  280. /***********************************************************/
  281. if RPL_Drive = 0 | RPL_Drive = "" then
  282. say "  RIPL is not installed.    "
  283. else
  284. say "  RPL_Path is" RPL_Path
  285. /***********************************************************/
  286. /* Display the source path for update data                 */
  287. /***********************************************************/
  288. say "  "Create_MSG(MSG.63,Source_Path'\'SPak'.SPK')"  "
  289. /***********************************************************/
  290. /* Display the backup path                                                                          */
  291. /***********************************************************/
  292. if backed = '0' then
  293.   say "  "msg.60
  294. else
  295.   say "  "Create_MSG(msg.61,Backup_dir)"  "
  296. say
  297. /*************************************************/
  298. /* Ask for verification of the input parameters.                        */
  299. /*************************************************/
  300. ask_verify:
  301. if Verified \= "" then signal got_verify
  302. call charout ,"  "MSG.16"  "
  303. parse upper linein Verified
  304. got_verify:
  305. if Verified  = "0" then             /* If the user answers NO to verification */
  306.    do                               /* then reset all of the input parameters */
  307.    Base_Drive= ""                   /* and go back to the start.              */
  308.    Update_Drive = ""
  309.    Source_Path = ""
  310.    RPL_Drive = ""
  311.    Verified = ""
  312.    Backed = ""
  313.    "cls"
  314.    signal start
  315.    end
  316.  
  317. if Verified \= "1" then                   /* only 0 and 1 are acceptable inputs */
  318.   do
  319.   say
  320.   say "  "MSG.15"  "
  321.   Verified = ""
  322.   signal ask_verify
  323.   end
  324. say
  325. say
  326.  
  327. /***********************************************************/
  328. /*   Set up pertinent variables                            */
  329. /***********************************************************/
  330. PROD_ID_PATH = Update_Drive":\"Prod_dir
  331. do k = 1 to syslvl_prefix.0
  332. syslvl.k = Update_Drive":\"Prod_dir"\SYSLEVEL."Prod_id.k
  333. 'dir 'syslvl.k' >> NUL 2>>&1 '
  334. if rc \= 0 then        /* skip this syslevel if not present */
  335.   do
  336.   syslvl.k = ''
  337.   say " This Selectpak has a prereq to "
  338.   say " LS3.0 Server with server level 7001 "
  339.   say " which is not installed ... Quitting "
  340.   signal end
  341.   end
  342.  
  343. /***********************************************************/
  344. /* Check to see that the customer has IP07001   */
  345. /* installed by reading the syslevel file.                 */
  346. /***********************************************************/
  347. firstline.k = linein(syslvl.k)   /* firstline used in later loop */
  348. /***********************************************************/
  349. /* Close the syslevel file so that it can be updated       */
  350. /***********************************************************/
  351. RC = stream(syslvl.k,'c','close')
  352.  
  353. /************************************************************/
  354. /* CSD_LEVEL will contain the current level of service      */
  355. /************************************************************/
  356. csd_level = substr(firstline.k,48,4)
  357.  
  358. /**************************************************************/
  359. /* Only allow this installation if the users current CSD      */
  360. /* level is IP07001 ( LS 3.0 )  */
  361. /**************************************************************/
  362. if csd_level < 7001 | csd_level > 7005 then
  363. do
  364.         say
  365.         say "  "MSG.17
  366.         say "  "create_msg(msg.18,prod_msg)
  367.         say "  "MSG.19
  368.         say
  369.         signal End
  370. end
  371. end                   /* syslevel loop */
  372. /* put CSD header in the log file */
  373. "echo.                                                           >> "Log_file" 2>>&1"
  374. "echo " center(prod_msg,80)                                     "  >> "Log_file" 2>>&1"
  375. "echo " center(Create_MSG(MSG.01,SPak),80)                   "  >> "Log_file" 2>>&1"
  376. "echo " center(date('L') time(),80)                           "  >> "Log_file" 2>>&1"
  377. "echo.                                                           >> "Log_file" 2>>&1"
  378. "echo.                                                           >> "Log_file" 2>>&1"
  379.  
  380.  
  381. Backup:
  382. if backed = '0' then signal skip_backup
  383. /***********************************************************/
  384. /* Backup the files!                                       */
  385. /***********************************************************/
  386.    "dir "backup_dir"  > NUL 2>>&1"
  387.    if RC \= 0 then            /* if not found */
  388.       do
  389.          'MD 'backup_dir' >>NUL 2>>&1'
  390.          if rc \= 0 then
  391.           do
  392.           failed_RC = rc
  393.           signal error
  394.           end
  395.       end  /* Do RC \= 0 */
  396.  
  397.    dirname=""
  398.       do i = 1 to subdirs.0                   /* subdirs.0 = num dirs found */
  399.          dirname = dirname||'\'subdirs.i      /* skip c:\ */
  400.          'MD 'Backup_dir'\'dirname' >> NUL 2>>&1 '
  401.          end                               /* do dir loop */
  402. say
  403. say Create_msg(MSG.20,backup_dir)
  404. say
  405. "echo "    Create_msg(msg.20,backup_dir)    "  >>"log_file"  2>>&1"
  406.  
  407. SPAK_vew = update_drive':\'prod_dir'\'SPAK'.vew'
  408. "PKUNZIP2 -v "Source_Path"\"SPak".SPK  *.exe  >> "SPak_vew"  "
  409. if RC \= 0 then
  410.    do
  411.    failed_RC = RC
  412.    signal error
  413.    end /* do */
  414. call find_filename spak_vew filename.
  415. file_count = RESULT
  416. rc = stream(SPak_vew,'c','close')        /* close view file */
  417. do file = 1 to file_count
  418.   "copy "Update_Drive":\"filename.file"  "Backup_dir"\"filename.file" >> NUL"
  419.   copy_rc = rc
  420.   if copy_rc = 1 then iterate                 /* new file */
  421.   if copy_rc = 0  then
  422.     do
  423.      say  create_msg(MSG.69,filename.file)
  424.     "echo "create_msg(MSG.69,filename.file)" >> "log_file" 2>>&1"
  425.     end
  426.   else do
  427.      say   create_msg(msg.70,filename.file)
  428.     "echo "create_msg(MSG.70,filename.file)" >> "log_file" 2>>&1"
  429.     failed_rc = copy_RC
  430.     signal backup_err
  431.     end  /* backup error */
  432. copy_end:
  433.   end /* do backups */
  434. skip_Backup:
  435.  
  436. /***********************************************************/
  437. /* Unzip the files!                                        */
  438. /***********************************************************/
  439. say
  440. say MSG.62
  441. say
  442. Prod_id_tmp = Update_drive":\"Prod_dir"\"SPak".tmp"
  443. /*"PKUNZIP2 -o -d "Source_Path"\"SPak".SPK "Update_Drive":\  >> "Prod_id_tmp"   "*/
  444. "PKUNZIP2 -o -d "Source_Path"\"SPak".SPK "Update_Drive":\  "subdirs.3"\*.* >> "Prod_id_tmp"   "
  445. zip_rc = RC
  446. "echo.                                       >> "Log_file" 2>>&1"
  447. "echo "create_msg(MSG.64,Update_drive":\"Prod_dir) "        >> "Log_file" 2>>&1"
  448. "copy "Log_file" + "Prod_ID_tmp"  "Log_file"  >> NUL "              /* append to log file */
  449. if RC \= 0 then
  450.   do
  451.   failed_RC = RC
  452.   signal error
  453.   end
  454. /* two places for PKUNZIP output to avoid confusion when there is */
  455. /* more than one SelectPak in the log_file                        */
  456. select
  457.    when Zip_RC = 11 then
  458.      do
  459.      say
  460.      say "  "Create_MSG(MSG.21,Prod_id_Path)" "
  461.      signal Unzip_RPL
  462.      end
  463.    when Zip_RC = 10 then
  464.      do
  465.      failed_RC = Zip_RC
  466.      signal error
  467.      end
  468.    when Zip_RC = 1 then
  469.       do
  470.       Lock_lines. = ""
  471.       SPak_fnd = update_drive':\'prod_dir'\'SPak'.fnd'
  472.       'find  "can''t create" 'Prod_ID_tmp' >>'SPak_fnd' '
  473.       if RC \= 0 then
  474.          do
  475.          failed_RC = RC
  476.          signal error
  477.          end
  478.       if lines(SPak_fnd) \= 0 then
  479.          do
  480.          say
  481.          say MSG.71         /* warning message */
  482.          say create_MSG(MSG.23,Log_file)
  483.          do j = 1 to 4                        /* skip 4 line header    */
  484.            trash = linein(SPak_fnd)           /* generated by find cmd */
  485.            end /* do */
  486.          j = 0
  487.          do while lines(SPak_fnd) \= 0
  488.              j = j + 1                                                /* create what SysFileSearch                  */
  489.              lock_lines.j = linein(SPak_fnd)        /* would have created                                 */
  490.              end
  491.          lock_lines.0 = j
  492.          rc = stream(SPak_fnd,'c','close')          /* close find file */
  493.          signal files_locked
  494.          end                     /* end lines \= 0 */
  495.     end                       /* end zip_rc = 1 */
  496.  
  497.    when Zip_RC = 0 then signal Unzip_RPL
  498.    otherwise
  499.       do
  500. /****************************************************************************/
  501. /* If there were any errors then tell the user that there were problems.    */
  502. /****************************************************************************/
  503.       say " PKUNZIP failure. Return code = " Zip_RC
  504.       say MSG.22
  505.       say Create_MSG(MSG.23,LOG_file)
  506.       say
  507.       end
  508. end  /* select */
  509.  
  510. Done:
  511. /**********************************************************************/
  512. /* Update SYSLEVEL files to indicate a select pak has been applied    */
  513. /**********************************************************************/
  514. do k = 1 to syslvl_prefix.0
  515. if syslvl.k = '' then iterate      /* skip unapplied syslevel */
  516. "echo.                                                           >> "Log_file" 2>>&1"
  517.  say create_msg(MSG.24,prod_id.k)
  518. "echo "create_msg(MSG.24,prod_id.k)"                               >> "Log_file" 2>>&1"
  519. "attrib -r "syslvl.k"                     >  NUL  2>>&1"
  520. parse var firstline.k 1 before 48 csd_num 52 more
  521. csd_num = '7005'
  522. new_first = before||csd_num||more
  523. sys_rc = lineout(syslvl.k,new_first,1)
  524. "attrib +r "syslvl.k"                    >  NUL  2>>&1"
  525. if sys_rc \= 0 then
  526.   do
  527.   failed_rc = sys_rc
  528.   signal error
  529.   end
  530. end /* do */
  531.  
  532. if RPL_Drive = 0 | RPL_Drive = "" then signal Donesrv
  533. else do
  534.  
  535. syslvl.k = Rpl_Drive":\IBMLAN\RPL\IBMLAN\SYSLEVEL.SRV"
  536. "attrib -r "syslvl.k"                     >  NUL  2>>&1"
  537. sys_rc = lineout(syslvl.k,new_first,1)
  538. "attrib +r "syslvl.k"                    >  NUL  2>>&1"
  539.  
  540. if sys_rc \= 0 then
  541.   do
  542.   failed_rc = sys_rc
  543.   signal error
  544.   end
  545. end /* do */
  546.  
  547. Donesrv:
  548. /* The installation is now complete, inform the user and exit */
  549. say
  550. say center(Create_MSG(MSG.88,SPak),80)
  551. say
  552. "echo "create_msg(MSG.88,SPak)" >> "log_file" 2>>&1"
  553. say
  554. call charout ,"  "MSG.89"   "
  555. say
  556. final_rc = 0
  557. signal End
  558.  
  559. /***********************************************************/
  560. /* This routine will be called if the user uses CTRL-BREAK */
  561. /***********************************************************/
  562. HALT:
  563. say
  564. say
  565. say MSG.26
  566. say MSG.27
  567. say
  568. final_RC = '9999'
  569. signal END
  570.  
  571.  
  572. /*****************************************************************/
  573. /* This routine will be called when there is a failure when      */
  574. /* backing up the files to be replaced.                          */
  575. /*****************************************************************/
  576. Backup_err:
  577. Error:
  578. say
  579. say SPak" install cannot continue.  See "LOG_file" for more info "
  580. say "  Return Code" Failed_RC "from line "sigl
  581. say
  582. "echo "create_msg(MSG.73,SPak)" >> "log_file" 2>>&1"
  583. "echo "create_msg2(MSG.74,Failed_RC,sigl)" >> "log_file" 2>>&1"
  584. final_rc = "0804"
  585. signal END
  586.  
  587.  
  588. Unzip_RPL:
  589.  
  590. if RPL_Drive = 0 | RPL_Drive = "" then signal Done
  591. else do
  592.    /***********************************************************/
  593.    /* Unzip the files into RPL directory                                        */
  594.    /***********************************************************/
  595.    say
  596.    Prod_id_tmp2 = Update_drive":\"Prod_dir"\"SPak".tm2"
  597.    "PKUNZIP2 -o -d "Source_Path"\"SPak".SPK "RPL_Drive":\IBMLAN\RPL\  "subdirs.3"\*.*  >> "Prod_id_tmp2"   "
  598.    zip_rc2 = RC
  599.    "echo.                                    >> "Log_file" 2>>&1"
  600.    "echo "create_msg(MSG.64,RPL_Path) "        >> "Log_file" 2>>&1"
  601.    "copy "Log_file" + "Prod_ID_tmp2"  "Log_file"  >> NUL "  /* append to log file */
  602.    if RC \= 0 then
  603.      do
  604.      failed_RC = RC
  605.      signal error
  606.      end
  607.    select
  608.       when Zip_RC2 = 11 then
  609.         do
  610.         say
  611.         say "  "Create_MSG(MSG.21,RPL_path)" "
  612.         signal Done
  613.         end
  614.       when Zip_RC2 = 10 then
  615.         do
  616.         failed_RC = Zip_RC2
  617.         signal error
  618.         end
  619.       when Zip_RC2 = 0 then signal Done
  620.       Otherwise
  621.         do
  622.         /****************************************************************************/
  623.         /* If there were any errors then tell the user that there were problems.    */
  624.         /****************************************************************************/
  625.         say " PKUNZIP failure. Return code = " Zip_RC2
  626.         say MSG.22
  627.         say Create_MSG(MSG.23,LOG_file)
  628.         say
  629.         end
  630.    end  /* select */
  631.    signal DONE
  632.    end  /* Do UNZIP for RPL */
  633.  
  634. /*****************************************************************/
  635. /* this routine reads a redirected pkunzip view file             */
  636. /* and parses for the filename. It returns the number of         */
  637. /* filenames found in RESULT.                                    */
  638. /*****************************************************************/
  639. find_filename:
  640. parse upper arg zipfile filename.
  641. do while first \= "Length"
  642.    data = linein(zipfile)
  643.    parse var data first rest
  644. end /* do */
  645. name_token = wordpos("Name",data)
  646. data = linein(zipfile)  /* throw away dashed line */
  647. count = 1
  648. data = linein(zipfile)  /* get first data line */
  649. token1 = word(data,1)
  650. do until token1 = "------"
  651.    filename.count = word(data,name_token)
  652.    filename.count = translate(filename.count,"\","/")
  653.    count = count + 1
  654.    data = linein(zipfile)
  655.    token1 = word(data,1)
  656.    end /* do */
  657. return count - 1
  658.  
  659. /*****************************************************************/
  660. /* this routine copies locked files to the IBMLANLK subdirectory */
  661. /* and creates the locked file list for use in the file          */
  662. /* replacement after reboot                                      */
  663. /*****************************************************************/
  664. files_locked:
  665. If first_lock = "1" then
  666.    do
  667.    first_lock = "0"
  668.    /* query existence of IBMLANLK subdirectory on the update drive */
  669.    "dir "Update_drive":\IBMLANLK  > NUL 2>>&1"
  670.    if RC \= 0 then            /* if not found */
  671.       do
  672.       'MD 'Update_drive':\IBMLANLK'
  673.       if rc \= 0 then
  674.         do
  675.         say "error " RC " creating IBMLANLK subdirectory"
  676.         failed_RC = RC
  677.         signal error
  678.         end
  679.       end  /* Do RC 18 */
  680.    LanLock = Update_drive":\IBMLANLK"
  681. /*    query existence of OS2\INSTALL\LOCK subdirectory on base drive */
  682. /*   "dir "Base_drive":\OS2\INSTALL\LOCK  > NUL 2>>&1"               */
  683. /*   if RC \= 0 then                                                 */
  684. /*     do                                                            */
  685. /*     lock_path = Base_drive":\OS2\INSTALL"                         */
  686. /*     end                         end not found                     */
  687. /*   else                                                            */
  688. /*      do                                                           */
  689. /*      lock_path = Base_drive":\OS2\INSTALL\LOCK"                   */
  690. /*      end                         end not found                    */
  691.    /* query existence of SPKLOCK subdirectory on the update drive */
  692.    "dir "Update_drive":\SPKLOCK >> NUL 2>>&1"
  693.    if RC \= 0 then            /* if not found */
  694.       do
  695.       'MD 'Update_drive':\SPKLOCK'
  696.       if rc \= 0 then
  697.         do
  698.         say "error " RC " creating SPKLOCK subdirectory"
  699.         failed_RC = RC
  700.         signal error
  701.         end
  702.       end  /* Do RC 18 */
  703.     /* unzip the locked file handler to the SPKLOCK subdirectory  */
  704.     lock_path = Update_drive":\SPKLOCK"
  705.     "echo.                                       >> "Log_file" 2>>&1"
  706.     "pkunzip2 -n "Source_path"\SPKLOCK.ZIP "lock_path" >> "Log_file" 2>>&1"
  707.    end     /* end First_lock */
  708. lock_list = lock_path"\IBMLANLK.LST"
  709. EOF = x2c(1A)
  710. out_file = stream(lock_list,'c',"open write")
  711. if out_file \= "READY:" then
  712.    do
  713.    failed_RC = out_file
  714.    signal error
  715.    end
  716. write_pos = stream(lock_list,'C','seek <1')         /* set to overlay eof if present */
  717. Remove_text = "RMTREE "Update_drive":\IBMLANLK"
  718. RC = lineout(lock_list,Remove_text)
  719. "echo.   >> "Log_file" 2>>&1"
  720. "echo "create_msg(MSG.65,LanLock"\"Prod_dir)"   >> "Log_file" 2>>&1"
  721. lock_string = "can't create: "
  722. do i = 1 to Lock_lines.0
  723.    parse var Lock_lines.i junk (lock_string) Locked_filespec.i
  724.    locked_filespec.i = translate(locked_filespec.i,"\","/")
  725.    locked_file_path.i = substr(locked_filespec.i,4)   /* after drive: */
  726. /* write the locked file move stmt to update_drive:\spklock\ibmlanlk.lst */
  727.    list_text = "move "LanLock"\"locked_file_path.i" "locked_filespec.i" "
  728.    Call LINEOUT lock_list,list_text
  729.    if RESULT \= 0 then
  730.       do
  731.       failed_RC = RESULT
  732.       signal error
  733.       end
  734. /* copy the locked file replacement to the IBMLANLK directory */
  735.    "echo "Locked_file_path.i" >> "Log_file" 2>>&1 "
  736.    "pkunzip2 -o -d "Source_Path"\"SPak".SPK "LanLock" "Locked_file_path.i" >> NUL 2>>&1  "
  737.    if RC \= 0 then
  738.      do
  739.      failed_RC = RC
  740.      signal error
  741.      end
  742. end           /* end locked file loop */
  743. /* write eof and close file */
  744. call charout lock_list,eof
  745. if RESULT \= 0 then
  746.    do
  747.    failed_rc = RESULT
  748.    signal error
  749.    end
  750. out_file = stream(lock_list,'c','close')
  751. if out_file \= "READY:" then
  752.    do
  753.    failed_RC = out_file
  754.    signal error
  755.    end
  756. /* Update Config.sys with IBMLANLK.SYS and RUN IBMLANLK.EXE stmts */
  757. call ecfg config.sys
  758. if RESULT \= 0 then
  759.     do
  760.     failed_RC = RESULT
  761.     signal error
  762.     end
  763. Reboot_required = "FE00"
  764. final_rc = Reboot_required
  765. say
  766. say MSG.67
  767. say
  768. "echo "msg.67" >> "log_file" 2>>&1"
  769. signal Unzip_RPL
  770.  
  771. /*****************************************************************/
  772. /* This routine will take a message and a variable and place the */
  773. /* variable in the proper position in the string.                */
  774. /*****************************************************************/
  775. Create_MSG:
  776. parse arg MESSAGE,VARIABLE
  777. PART1 = SUBSTR(MESSAGE,1,POS('%1',MESSAGE)-1)
  778. PART2 = SUBSTR(MESSAGE,POS('%1',MESSAGE)+2)
  779. RETURN PART1 || VARIABLE || PART2
  780.  
  781. /*********************************************************************/
  782. /* This routine will take a message and two variables and place the  */
  783. /* variables in their proper positions in the string.                */
  784. /*********************************************************************/
  785. Create_MSG2:
  786. parse arg MESSAGE,VARIABLE.1,VARIABLE.2
  787. percent = "%"
  788. parse var message part1 (percent) part2 (percent) part3
  789. parse var part2 part2n 2 part2t
  790. parse var part3 part3n 2 part3t
  791. RETURN PART1 || VARIABLE.part2n || PART2T || VARIABLE.part3n || PART3T
  792.  
  793. /*********************************************************************/
  794. /* Help panel                                                        */
  795. /*********************************************************************/
  796. syntax:
  797. say "                                                    "
  798. say "  "Create_MSG(MSG.28,Prod_id.1)"                         "
  799. say "                                                    "
  800. say "  "MSG.29"                                          "
  801. say "                                                    "
  802. say "      "MSG.30"                                      "
  803. say "         "Create_MSG(MSG.31,'\OS2\INSTALL')"        "
  804. say "                                                    "
  805. say "      "MSG.32"                                      "
  806. say "         "Create_MSG(MSG.31,'\'Prod_dir)"           "
  807. say "                                                    "
  808. say "      "MSG.76"                                      "
  809. say "         "Create_MSG(MSG.31,'\IBMLAN\RPL\'Prod_dir)""
  810. say "         "MSG.77"                                   "
  811. say "                                                    "
  812. say "      "Create_MSG(MSG.33,SPak'.SPK')"               "
  813. say "         "Create_MSG(MSG.10,SPak'.SPK')"            "
  814. say "                                                    "
  815. say "      "MSG.34"                                      "
  816. say "         "Create_MSG(MSG.35,Backup_dir)"            "
  817. say "         "MSG.72"                                    "
  818. say "         "Create_MSG(MSG.13,Backup_size)"           "
  819. say "                                                    "
  820. say "      "MSG.36"                                      "
  821. say "         "MSG.37"                                   "
  822. say "                                                    "
  823. say "                                                    "
  824. say "  "MSG.38"                                          "
  825. say "      "Prod_id.1" /S:C:\service\"SPak" /T:c /D:c /B:c /K:c:\"prod_dir"\bak /V:1"
  826. say "  "MSG.68"                                          "
  827. say "  "MSG.39"                                          "
  828. say "                                                    "
  829. say "                                                    "
  830. signal END
  831.  
  832. ecfg:
  833. /******************************************************************/
  834. /* This routine will update CONFIG.SYS                            */
  835. /* with IBMLANLK.SYS and RUN IBMLANLK.EXE stmts                   */
  836. /******************************************************************/
  837. parse arg file_in
  838.  
  839. Source_config = Base_drive":\"file_in
  840. found = '1'
  841. /* determine number for Config.sys backup                         */
  842. do num = 0 to 999 until found = '0'
  843.    if num < 10 then
  844.      config_name = Base_drive':\CONFIG.00'||num
  845.    else if num > 100 then
  846.       config_name = Base_drive':\CONFIG.'||num
  847.       else config_name = Base_drive':\CONFIG.0'||num
  848.    "dir "config_name" >> NUL 2>>&1"
  849.    if rc \= 0 then
  850.      found = '0'
  851. end /* do */
  852. 'copy 'Source_config' 'config_name' >>NUL 2>>&1 '
  853. if rc = 0 then
  854.    do
  855.    say
  856.    say create_msg2(MSG.66,Source_config,config_name)
  857.    say
  858.    "echo.   >> "Log_file" 2>>&1"
  859.    "echo "create_msg2(MSG.66,Source_config,config_name) " >> "Log_file" 2>>&1"
  860.    end
  861. else
  862.    do
  863.    failed_rc = rc
  864.    signal error
  865.    end
  866.  
  867. /* read in target file */
  868. i = 0
  869. do while lines(Source_config)                   /* for all lines of Config.sys */
  870.    i = i + 1                                    /*   get line in               */
  871.    Target.i = linein(Source_config)             /*   Target. stem              */
  872.    end
  873. Target.0 = i                                    /*     Target.0 = # of lines   */
  874. rc = stream(Source_config,'C','CLOSE')
  875.  
  876. /* is new line already there?  */
  877. Line1 = "DEVICE="lock_path"\IBMLANLK.SYS "lock_list" "
  878. exist1 = Whereis(Line1,'F')                      /* If this line exists and */
  879. Line2 = "RUN="lock_path"\IBMLANLK.EXE "lock_list" "
  880. exist2 = Whereis(Line2,'F')                      /* If this line exists and */
  881.  
  882. /* add locked file device driver after 1st IFS stmt or before 1st device stmt */
  883. if exist1 \= '' then
  884.   do
  885.   after = exist1
  886.   signal Process_run
  887.   end
  888. bstr = "IFS="
  889. after = Whereis(bstr,'F')                    /*    else get # of 1st    */
  890. parse var after after .                      /*    line with this id.   */
  891.  
  892. if after = '' then                           /*    no IFS= found        */
  893.   do
  894.   bstr = "DEVICE="                           /*    search for DEVICE=   */
  895.   after = Whereis(bstr,'F')                  /*    get # of 1st         */
  896.   parse var after after .                    /*    line with this id.   */
  897.   if after ='' then                          /*    no Device= found     */
  898.     do
  899.     after=0                                   /*      else add to top    */
  900.     end
  901.   else
  902.      do                                              /*  Device stmt found  */
  903.      after=max(0,after-1)                  /*  Device= found in"after"*/
  904.      if after \= -1 then
  905.        do
  906.        call insert after Line1                  /*    add the line before  */
  907.        after = after + 1                        /*    for run after device */
  908.        end
  909.      else signal error
  910.      end                                           /*  end Device stmt found  */
  911.   end                                        /*    end no IFS= found    */
  912.  
  913. else
  914.   do                                            /*  IFS stmt found           */
  915.   after=max(0,after)                      /*    IFS= found in"after" */
  916.   if after \= -1 then
  917.     do
  918.     call insert after Line1                    /*    add the line after   */
  919.     after = after + 1                          /*    for run after device */
  920.     end
  921.   else signal error
  922.   end                                              /* end IFS stmt found   */
  923.  
  924. /* add run statement following Device statement */
  925. Process_run:
  926. if exist2 \= '' then signal END_ECFG
  927. call insert after Line2                      /*   add run after device */
  928. signal END_ECFG
  929.  
  930. /******************************************************************/
  931. /*     Insert a line in Target file (stem) after line number i.   */
  932. /******************************************************************/
  933. Insert: procedure  expose Target.
  934.  parse arg i string
  935.  if i = Target.0 then k = Target.0 + 1
  936.  else do                    /* move lines below insert down 1 */
  937.    do j = Target.0 to i+1 by -1
  938.      k = j + 1
  939.      Target.k = Target.j
  940.    end
  941.    k = i + 1
  942.  end
  943.  Target.k = string
  944.  Target.0 = Target.0 + 1
  945. /* say 'Inserted line' k ': "'Target.k'"'   */
  946.  return
  947.  
  948. /******************************************************************/
  949. /*     Searches All or First or Last lines in Target starting     */
  950. /*     with string.  Returns the line number(s) found.            */
  951. /******************************************************************/
  952. Whereis: procedure expose Target.
  953.  parse arg string,direction
  954.  stringlength=length(string)
  955.  ret = ''
  956.  do i = 1 to Target.0 by 1
  957.    T = translate(Target.i)
  958.    S = translate(string)
  959.    if left(T,stringlength)=S then
  960.     do
  961.     ret = ret i
  962.     if direction \= 'A' then leave
  963.     end
  964.  end
  965.  return ret
  966.  
  967.  
  968. /******************************************************************/
  969. /*     Update Target file from Target. stem.                      */
  970. /******************************************************************/
  971. SaveFile:
  972.  'erase' Source_config
  973.  src = rc
  974.  if src = 0 then do
  975.    do i = 1 to Target.0
  976.      out = lineout(Source_config,Target.i)
  977.      end
  978.    rc = stream(Source_config,'C','CLOSE')
  979.    end
  980.  return src
  981.  
  982. /******************************************************************/
  983. /*            Save and return                                     */
  984. /******************************************************************/
  985. END_ECFG:
  986.  src = SaveFile()
  987.  Return src
  988.  
  989. END:
  990. 'erase 'Prod_id_tmp' >>NUL 2>>&1'
  991. 'erase 'Prod_id_tmp2' >>NUL 2>>&1'
  992. 'erase 'SPak_vew' >>NUL 2>>&1'
  993. 'erase 'SPak_fnd' >>NUL 2>>&1'
  994. EXIT x2d(final_rc)
  995.  
  996.  
  997.  
  998.