home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 29 Fixes_o / 29-Fixes_o.zip / dlrcsd30.dsk / IP07003.CMD < prev    next >
OS/2 REXX Batch file  |  1993-06-03  |  33KB  |  884 lines

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