home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 17 Fixes30 / 17-Fixes30.zip / xr_w029.zip / XR_W029Q.DSK / SYSZMPM.CMD < prev    next >
OS/2 REXX Batch file  |  1997-03-13  |  10KB  |  222 lines

  1. /*****************************************************************************/
  2. /*            (C) Copyright IBM Corp 1996; All rights reserved.              */
  3. /*****************************************************************************/
  4. /* REXX cmd file to restore SYSLEVEL.MPM to correct vlalues for various      */
  5. /* versions of OS/2 Warp.                                                    */
  6. /*                                                                           */
  7. /* Do the following:                                                         */
  8. /* 1. Verify SYSLEVEL.OS2 and SYSLEVEL.MPM both exist.                       */
  9. /* 2. Locate MMPM via SET MMBASE= entry in CONFIG.SYS. If not found exit,    */
  10. /*    nothing to do.                                                         */
  11. /* 3. Get CSD level and COMPID from SYSLEVEL.OS2 in OS2\INSTALL directory of */
  12. /*    boot drive.                                                            */
  13. /* 4. Get CSD level and COMPID from SYSLEVEL.MPM in MMOS2\INSTALL directory. */
  14. /* 5. If either value does not match, backup existing SYSLEVEL.MPM as        */
  15. /*    SYSLGA.MPM (if it exists then DO NOT backup).                          */
  16. /* 6. Update CSD level and/or COMPID of SYSLEVEL.MPM with data from          */
  17. /*    SYSLEVEL.OS2 file.                                                     */
  18. /* 7. Write out new SYSLEVEL.MPM file.                                       */
  19. /*                                                                           */
  20. /* For XR?3000, COMPID of 562137400 is correct for MMPM even though different*/
  21. /* from SYSLEVEL.OS2 value. Was a separate product at that time.             */
  22. /*                                                                           */
  23. /* Preserve the R/O attribute if it is on for the current file.              */
  24. /*                                                                           */
  25. /* DEFECT 162197 - For Denmark Warp Server, make version of SYSLEVEL.MPM     */
  26. /*                 same as SYSLEVEL.OS2 to prevent Fixtool from changing     */
  27. /*                 SYSLEVEL.MPM CSD level to fixpak name.                    */
  28. /*                                                                           */
  29. /* DEFECT 172532 - For German fullpack and fullpack connect, change version  */
  30. /*                 from 3001 to 3000.                                        */
  31. /*                 (same as SYSLEVEL.OS2).                                   */
  32. /*                                                                           */
  33. /* Remove restriction on running on a US system so will correct bad Current  */
  34. /* CSD level of SYSLEVEL.MPM for Warp Server SMP (US).                       */
  35. /*****************************************************************************/
  36. '@Echo off'
  37. 'CLS'
  38.  
  39. /*****************************************************************************/
  40. /* Register all REXXUTIL functions                                           */
  41. /*****************************************************************************/
  42. rc=RxFuncAdd('SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs')
  43. If rc>1 then
  44.   Do
  45.     Say 'Unable to register REXXUTIL functions, cannot continue.'
  46.     Signal Done
  47.   End
  48. Call SysLoadFuncs
  49.  
  50. /*************************************************/
  51. /* Use environment variables to locate following */
  52. /*************************************************/
  53. env='OS2ENVIRONMENT'                                     /* Environment name */
  54. boot=Filespec('DRIVE',value('COMSPEC',,env))              /* Find Boot drive */
  55. If boot='' | length(boot)<>2 | right(boot,1)<>':' then
  56.   Do
  57.     Say 'Unable to locate your boot drive via the COMSPEC environment'
  58.     Say 'variable. Cannot continue.'
  59.     Signal Done
  60.   End
  61. Say 'Boot drive is 'boot
  62. /******************/
  63. /* Locate MMBASE. */
  64. /******************/
  65. mmos2=value('MMBASE',,env)                            /* Find MMBASE setting */
  66. If mmos2='' then
  67.   Do
  68.     Say 'Multimedia is not installed on this system, nothing to do.'
  69.     Signal Done
  70.   End
  71. If right(mmos2,1)=';' then
  72.   mmos2=left(mmos2,length(mmos2)-1)
  73. Say 'Multimedia is installed in 'mmos2
  74.  
  75. /*************************************************/
  76. /* Make sure SYSLEVEL files exist and are valid. */
  77. /*************************************************/
  78. os2file=boot||'\OS2\INSTALL\SYSLEVEL.OS2'
  79. mpmfile=mmos2||'\INSTALL\SYSLEVEL.MPM'
  80. Parse value 0 0 with os2found mpmfound .
  81. If stream(os2file,'c','Query Exists')='' then
  82.   Say os2file' not found, required.'
  83. Else
  84.   os2found=1
  85. If stream(mpmfile,'c','Query Exists')='' then
  86.   Say mpmfile' not found, required.'
  87. Else
  88.   mpmfound=1
  89. If os2found+mpmfound<>2 then
  90.   Signal Done
  91.  
  92. /****************************************/
  93. /* Read SYSLEVEL.OS2 into rexx variable */
  94. /****************************************/
  95. Say 'Checking 'os2file
  96. sig='FFFF'x||'SYSLEVEL'                                /* SYSLEVEL signature */
  97. size=stream(os2file,'C','Query Size')
  98. Call stream os2file,'C','Open Read'
  99. os2line=charin(os2file,1,size)
  100. Call stream os2file,'C','Close'
  101. If left(os2line,10)<>sig then
  102.   Do
  103.     Say os2file' is not a valid SYSLEVEL file.'
  104.     Say 'Does not start with "FFFFSYSLEVEL" (FFFF is HEX).'
  105.     Signal Done
  106.   End
  107. os2ver=substr(os2line,41,2)                                /* Version in hex */
  108. os2csd=substr(os2line,45,8)                             /* Current CSD level */
  109. os2cid=substr(os2line,141,9)                                       /* COMPID */
  110. Say '  Current CSD level: 'os2csd' COMPID: 'os2cid' Version: 'c2x(os2ver)
  111.  
  112. /****************************************/
  113. /* Read SYSLEVEL.MPM into rexx variable */
  114. /****************************************/
  115. Say 'Checking 'mpmfile
  116. mpmsave=mmos2||'\INSTALL\SYSLGA.MPM'
  117. size=stream(mpmfile,'C','Query Size')
  118. Call stream mpmfile,'C','Open Read'
  119. mpmline=charin(mpmfile,1,size)
  120. Call stream mpmfile,'C','Close'
  121. If left(mpmline,10)<>sig then
  122.   Do
  123.     Say mpmfile' is not a valid SYSLEVEL file.'
  124.     Say 'Does not start with "FFFFSYSLEVEL" (FFFF is HEX).'
  125.     Signal Done
  126.   End
  127. mpmver=substr(mpmline,41,2)                                /* Version in hex */
  128. mpmcsd=substr(mpmline,45,8)                             /* Current CSD level */
  129. mpmcid=substr(mpmline,141,9)                                       /* COMPID */
  130. Say '  Current CSD level: 'mpmcsd' COMPID: 'mpmcid' Version: 'c2x(mpmver)
  131.  
  132. /************************************************************/
  133. /* Check CSD level and COMPID against OS2. Replace if diff. */
  134. /* For XR?3000, COMPID of 562137400 is correct even though  */
  135. /* different from SYSLEVEL.OS2 value.                       */
  136. /************************************************************/
  137. update=0                                               /* No update done yet */
  138. cid3000='562137400'                               /* MMPM COMPID for Warp GA */
  139. If os2csd=mpmcsd&(os2cid=mpmcid | (substr(os2csd,4,4)='3000'&mpmcid=cid3000)) then
  140.   Do
  141.    Say 'CSD level and COMPID of SYSLEVEL.MPM are correct.'
  142.    Signal ChkDK
  143.   End
  144. If os2csd<>mpmcsd then
  145.   mpmline=overlay(os2csd,mpmline,45,8)
  146. If os2cid<>mpmcid then
  147.   If substr(os2csd,4,4)='3000' then                              /* Warp GA? */
  148.     mpmline=overlay(cid3000,mpmline,141,9)
  149.   Else                                                                 /* No */
  150.     mpmline=overlay(os2cid,mpmline,141,9)
  151. update=1                                        /* Remember we made a change */
  152.  
  153. /*****************************************************/
  154. /* If Denmark OS/2 version=3.01 and MPM version=3.00 */
  155. /* make MPM version=OS/2 version.                    */
  156. /*****************************************************/
  157. ChkDK:
  158. If substr(os2csd,3,1)='D' then                             /* Danish system? */
  159.   Do
  160.     If c2x(os2ver)='3001' & c2x(mpmver)='3000' then
  161.       Do
  162.         mpmline=overlay(os2ver,mpmline,41)
  163.         update=1                                /* Remember we made a change */
  164.       End
  165.     Else
  166.       Say 'Version is correct.'
  167.   End
  168.  
  169. /*****************************************************/
  170. /* German Fullpack or Fullpack Connect.              */
  171. /*****************************************************/
  172. /* If German OS/2 version=3.00 and MPM version=3.01  */
  173. /* make MPM version=OS/2 version.                    */
  174. /*****************************************************/
  175. If substr(os2csd,1,7)='XRG3001'|substr(os2csd,1,7)='XRG3003' then                 /* German Warp Connect? */
  176.   Do
  177.     If c2x(os2ver)='3000' & c2x(mpmver)='3001' then
  178.       Do
  179.         mpmline=overlay(os2ver,mpmline,41)
  180.         update=1                                /* Remember we made a change */
  181.       End
  182.     Else
  183.       Say 'Version is correct.'
  184.   End
  185.  
  186. If \update then
  187.   Signal Done
  188.  
  189. /****************************************************/
  190. /* If we get here then we changed some value in the */
  191. /* SYSLEVEL.MPM data so need to backup the file and */
  192. /* create a new one with the updated data. Don't    */
  193. /* overlay existing backup if it exists.            */
  194. /****************************************************/
  195. mpmver=substr(mpmline,41,2)
  196. mpmcsd=substr(mpmline,45,8)
  197. mpmcid=substr(mpmline,141,9)
  198. Say '      New CSD level: 'mpmcsd' COMPID: 'mpmcid' Version: 'c2x(mpmver)
  199.  
  200. If Stream(mpmsave,'C','Query Exists')='' then  /* Backup file already exist? */
  201.   '@COPY 'mpmfile mpmsave' > NUL'                     /* No, back it up then */
  202. Call SysFileTree mpmfile,'SFILE','F'                       /* Get file specs */
  203. Parse value sfile.1 with . . . atts .                     /* Just attributes */
  204. mpmro=pos('R',atts)>0 then                              /* Get Read Only bit */
  205. If mpmro then                                                 /* Was it set? */
  206.   '@ATTRIB -R' mpmfile                         /* Yes, turn of so can delete */
  207. '@DEL 'mpmfile' >NUL'
  208. Call Stream mpmfile,'C','Open Write'
  209. Call charout mpmfile,mpmline                           /* Write updated file */
  210. Call Stream mpmfile,'C','Close'
  211. If mpmro then                                /* Turn on R/O bit if on before */
  212.   'ATTRIB +R' mpmfile
  213.  
  214. Say mpmfile' update complete.'
  215. Say 'Original 'mpmfile' saved as 'mpmsave'.'
  216.  
  217. /*******************************/
  218. /* Only exit from this program */
  219. /*******************************/
  220. Done:
  221. Exit
  222.