home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / lan / 21ripl.zip / IBMLS.ZIP / RPLUCFIT.CMD < prev    next >
OS/2 REXX Batch file  |  1993-05-28  |  21KB  |  476 lines

  1. /*******************************************************************/
  2. /* REXX procedure to update the client.FIT by making the following */
  3. /* changes to the original FIT:                                    */
  4. /*   - removes DISPLAY.DLL entries, if present.                    */
  5. /*   - If OS/2 2.1, and FIT is not at 2.1 level, it is updated to  */
  6. /*     to 2.1 level by removing VGA FON entries and some APPS      */
  7. /*     entries, and new 2.1 entries are added.                     */
  8. /*   - If not OS/2 2.1, enables/disables appropriate .FON entries. */
  9. /*   - If requested, changes the target OS2 root directory.        */
  10. /*   - If requested, changes the bus type entries.                 */
  11. /*                                                                 */
  12. /* Return codes:                                                   */
  13. /*   0 - No error                                                  */
  14. /*   2 - FIT did not need to be updated (not an error)             */
  15. /*   4 - FIT could not be updated (error)                          */
  16. /*                                                                 */
  17. /* Copyright: (C) Copyright IBM Corp. 1993                         */
  18. /*                                                                 */
  19. /*******************************************************************/
  20.  
  21.    parse arg client, rpldir, driver, Bustype, currentOS2, newOS2, changeOS2, ,
  22.              clientbootdrv, version21
  23.  
  24.    blkspace = '         '
  25.  
  26.    /* build fully qualified path names for client.fit */
  27.    fitname = rpldir'\FITS\'client'.FIT'
  28.    tmpfitname = rpldir'\FITS\'client'.TMP'
  29.    bakfitname = rpldir'\FITS\'client'.BAK'
  30.  
  31.    /* make sure temp files do not exist */
  32.    Call Delete_File tmpfitname
  33.    Call Delete_File bakfitname
  34.  
  35.    /* build a new FIT */
  36.    os2verflag = 0
  37.    newos2iniflag = 0
  38.    psfontsflag = 0
  39.    isofontsflag = 0
  40.    pre21fitflag = 1
  41.    addnewwinos2flag = 0
  42.    xgadmqsflag = 0
  43.    do until lines(fitname) = 0
  44.       data = translate(linein(fitname))
  45.       If data <> '' Then Do
  46.          /* not a null line, check line */
  47.          removeentry = 0
  48.          If substr(data, 1, 2) = '\\' Then Do
  49.             /* UNC record, get server name */
  50.             datap = pos('\', data, 3)
  51.             If datap <> 0 Then Do
  52.                servername = substr(data, 3, datap-3)
  53.             end
  54.          end
  55.  
  56.          If version21 = 1 Then Do
  57.  
  58.             /* if pre-2.1 fit, must check for enties to be removed/updated */
  59.             /* the pre21fit flag will be reset when we have encountered */
  60.             /* an entry that is 2.1 unique and we know we can skip all this */
  61.             /* for subsequence records */
  62.             If pre21fitflag = 1 Then Do
  63.                /* may be pre-OS/2 2.1 FIT, continue testing for entries */
  64.                /* to be removed/updated */
  65.                datap = pos('; VGA DISPLAY', data)
  66.                if datap <> 0 Then Do
  67.                   /* indicate entry is to be removed */
  68.                   removeentry = 1
  69.                end
  70.                else Do
  71.                   /* look for XGA/8514 comment */
  72.                   datap = pos('; XGA & 8514/A', data)
  73.                   if datap <> 0 Then Do
  74.                      /* update entry */
  75.                      newdata = '; VGA,' || substr(data, 2)
  76.                      data = newdata
  77.                   end
  78.                   else Do
  79.                      /* look for APPS\* entries to be removed */
  80.                      apps = '\APPS\'
  81.                      datap = pos(apps || 'PMSTICKY.$', data)
  82.                      If datap <> 0 Then Do
  83.                         /* indicate entry is to be removed */
  84.                         removeentry = 1
  85.                      end
  86.                      else Do
  87.                         datap = pos(apps || '*.$', data)
  88.                         If datap <> 0 Then Do
  89.                            /* check for *.$$$, keep it, remove all others */
  90.                            datap = pos(APPS || '*.$$$', data)
  91.                            If datap = 0 Then Do
  92.                               /* indicate entry is to be removed */
  93.                               removeentry = 1
  94.                            end
  95.                         end
  96.                      end
  97.                   end
  98.                end
  99.             end
  100.          end
  101.  
  102.          /* remove DISPLAY.DLL references in all cases */
  103.          datap = pos(':\OS2\DLL\DISPLAY.DLL', data)
  104.          if datap <> 0 Then Do
  105.             /* indicate entry is to be removed */
  106.             removeentry = 1
  107.          end
  108.  
  109.          If removeentry = 0 Then Do
  110.             /* entry still valid, continue testing */
  111.             If driver <> '' Then Do
  112.                /* check for .FON entry and if not OS/2 2.1, enable/disable */
  113.                /* the entry depending on the driver type */
  114.                helvp = 0
  115.                courp = 0
  116.                timesp = 0
  117.                helvp = pos(':\OS2\DLL\HELV.FON', data)
  118.                If helvp = 0 Then Do
  119.                   courp = pos(':\OS2\DLL\COURIER.FON',data)
  120.                   If courp = 0 Then Do
  121.                      timesp = pos(':\OS2\DLL\TIMES.FON',data)
  122.                   end
  123.                end
  124.                If helvp <> 0 | courp <> 0 | timesp <> 0 Then Do
  125.                   datal = length(data)
  126.                   dpos = pos('.VGA', data)
  127.                   If dpos <> 0 Then Do
  128.                      If version21 = 0 Then Do
  129.                         /* VGA font references will still be present */
  130.                         /* check for enable/disable */
  131.                         If driver = 'IBMVGA32' Then Do
  132.                            If substr(data, 1, 1) = ';' Then Do
  133.                               /* enable VGA .FON entry */
  134.                               data = substr(data, 2)
  135.                            end
  136.                         end
  137.                         else Do
  138.                            /* make sure entry is disabled */
  139.                            If substr(data, 1,1) <> ';' Then Do
  140.                               /* disable non-VGA .FON entry */
  141.                               newdata = ';'data
  142.                               data = newdata
  143.                            end
  144.                         end
  145.                      end
  146.                      else Do
  147.                         /* OS/2 2.1, remove VGA references */
  148.                         removeentry = 1
  149.                      end
  150.                   end
  151.                   else Do
  152.                      /* look for *.BGA references */
  153.                      dpos = pos('.BGA', data)
  154.                      If dpos <> 0 Then Do
  155.                         /* BGA reference */
  156.                         /* check to see if entry needs to be enabled/disabled */
  157.                         If (version21 = 1 & driver = 'IBMVGA32') Then Do
  158.                            /* make sure entry is enabled */
  159.                            If substr(data, 1, 1) = ';' Then Do
  160.                               /* enable VGA, XGA, 8514 .FON entry */
  161.                               data = substr(data, 2)
  162.                            end
  163.                         end
  164.                         else Do
  165.                            If driver = 'IBMXGA32' | driver = 'IBM8514' | ,
  166.                               driver = '8514_32' Then Do
  167.                               If substr(data, 1, 1) = ';' Then Do
  168.                                  /* enable XGA/8514 .FON entry */
  169.                                  data = substr(data, 2)
  170.                               end
  171.                            end
  172.                            else If substr(data, 1, 1) <> ';' Then Do
  173.                               /* disable non-XGA/8514 .FON entry */
  174.                               newdata = ';'data
  175.                               data = newdata
  176.                            end
  177.                         end
  178.                      end
  179.                   end
  180.                end
  181.             end
  182.  
  183.             If removeentry = 0 Then Do
  184.                /* entry still valid, continue testing */
  185.                /* check for possible operating system change */
  186.                if changeOS2 = 1 Then Do
  187.                   If substr(data, 1, 2) = '; ' Then srvfname = word(data, 3)
  188.                   else srvfname = word(data, 2)
  189.                   os2p = pos(currentOS2'\', srvfname)
  190.                   if os2p <> 0 Then Do
  191.                      /* old OS2 entry found, update it */
  192.                      os2p = pos(currentOS2, data, length(word(data,1))+1)
  193.                      newdata = substr(data, 1, os2p-1)
  194.                      newdata = newdata || newOS2
  195.                      newdata = newdata || substr(data, os2p+length(currentOS2))
  196.                      data = newdata
  197.                   end
  198.                end
  199.  
  200.                /* check for Bustype change */
  201.                If Bustype <> ' ' Then Do
  202.                   /* check for VDMA.SYS entry */
  203.                   datap = pos(':\OS2\MDOS\VDMA.SYS', data)
  204.                   If datap <> 0 Then Do
  205.                      /* this is one of the VDMA.SYS entries */
  206.                      datap2 = pos('OS2\MDOS\VDMAPS2.SYS', data)
  207.                      If datap2 <> 0 Then Do
  208.                         /* MCA entry */
  209.                         If Bustype = 'MCA' Then Do
  210.                            If substr(data, 1, 1) = ';' Then Do
  211.                               /* entry disabled, enable it */
  212.                               newdata = substr(data, datap-1)
  213.                               data = newdata
  214.                            end
  215.                         end
  216.                         else Do
  217.                            /* make sure entry is disabled */
  218.                            If substr(data, 1, 1) <> ';' Then Do
  219.                               newdata = '; ' || data
  220.                               data = newdata
  221.                            end
  222.                         end
  223.                      end
  224.                      else Do
  225.                         /* check for AT entry */
  226.                         datap2 = pos('OS2\MDOS\VDMAAT.SYS', data)
  227.                         If datap2 <> 0 Then Do
  228.                            /* ISA/EISA entry */
  229.                            If Bustype = 'ISA' | Bustype = 'EISA' Then Do
  230.                               If substr(data, 1, 1) = ';' Then Do
  231.                                  /* entry disabled, enable it */
  232.                                  newdata = substr(data, datap-1)
  233.                                  data = newdata
  234.                               end
  235.                            end
  236.                            else Do
  237.                               /* entry enabled, disable it */
  238.                               If substr(data, 1, 1) <> ';' Then Do
  239.                                  newdata = '; ' || data
  240.                                  data = newdata
  241.                               end
  242.                            end
  243.                         end
  244.                      end
  245.                   end
  246.                end
  247.             end
  248.  
  249.             ucdata = translate(data)
  250.  
  251.             If newos2iniflag = 0 Then Do
  252.                /* watch for new 2.1 INI references */
  253.                os2p = pos('\OS2.!!!', ucdata)
  254.                If os2p <> 0 Then Do
  255.                   /* if OS2.!!! is found, this is a 2.1 FIT and we can */
  256.                   /* reset the pre21fitflag to bypass some checking at the top */
  257.                   /* of the loop */
  258.                   pre21fitflag = 0
  259.                   newos2iniflag = 1
  260.  
  261.                   /* check for possible early exit */
  262.                   If Bustype = '' & changeOS2 = 0 Then Do
  263.                      /* don't really need to update FIT for this case */
  264.                      /* quit at this point */
  265.                      Call Lineout tmpfitname   /* close file */
  266.                      Call Lineout fitname      /* close file */
  267.                      Call Delete_File tmpfitname
  268.                      return 2  /* update not needed */
  269.                   end
  270.                end
  271.             end
  272.  
  273.  
  274.             If newos2appsiniflag = 0 Then Do
  275.                /* watch for new 2.1 APPS references */
  276.                os2p = pos('\APPS\*.INI', ucdata)
  277.                If os2p <> 0 Then newos2appsiniflag = 1
  278.             end
  279.  
  280.             If psfontsflag = 0 Then Do
  281.                /* watch for PSFONTS reference */
  282.                os2p = pos('\PSFONTS', ucdata)
  283.                If os2p <> 0 Then psfontsflag = 1
  284.             end
  285.  
  286.             If os2verflag = 0 Then Do
  287.                /* watch for OS2VER reference, set flag if found */
  288.                os2p = pos(':\OS2VER ', ucdata)
  289.                If os2p <> 0 Then os2verflag = 1
  290.             end
  291.  
  292.             If isofontsflag = 0 Then Do
  293.                /* watch for ISO font reference */
  294.                os2p = pos('\HELVI.FON', ucdata)
  295.                If os2p <> 0 Then isofontsflag = 1
  296.                else Do
  297.                   /* watch for EGA font comment line, if we see it then */
  298.                   /* the new ISO font entries need to be added */
  299.                   datap = pos('; EGA DISPLAY ', data)
  300.                   if datap <> 0 Then Do
  301.                      /* add ISO entries */
  302.                      trg = newOS2'\OS2\DLL\'
  303.                      src = clientbootdrv':\OS2\DLL\'
  304.                      newdata = '; XGA-2 ISO font support'
  305.                      Call Lineout tmpfitname, newdata
  306.                      newdata = src || 'HELVI.FON' || '      ' || trg || 'HELVI.XGA'
  307.                      Call Lineout tmpfitname, newdata
  308.                      newdata = src || 'COURIERI.FON' || '   ' || trg || 'COURIERI.XGA'
  309.                      Call Lineout tmpfitname, newdata
  310.                      newdata = src || 'TIMESI.FON' || '     ' || trg || 'TIMESI.XGA'
  311.                      Call Lineout tmpfitname, newdata
  312.                      isofontsflag = 1
  313.                      Call Lineout tmpfitname, ''
  314.                   end
  315.                end
  316.             end
  317.  
  318.             If xgadmqsflag = 0 Then Do
  319.                /* watch for XGA$DMQS reference */
  320.                os2p = pos(':\XGA$DMQS', ucdata)
  321.                If os2p <> 0 Then xgadmqsflag = 1
  322.                else Do
  323.                   /* XGA$DMQS entry will be before Remote Install comment if */
  324.                   /* it is present */
  325.                   os2p = pos('; OS/2 REMOTE INSTALL', ucdata)
  326.                   If os2p <> 0 Then Do
  327.                      /* add XGA$DMQS entry */
  328.                      trg = newOS2'\XGA$DMQS'
  329.                      src = clientbootdrv':\XGA$DMQS'
  330.                      newdata = src || blkspace || trg
  331.                      Call Lineout tmpfitname, newdata
  332.                      xgadmqsflag = 1
  333.                      Call Lineout tmpfitname, ''
  334.                   end
  335.                end
  336.             end
  337.  
  338.             /* if  OS/2 2.1, check to see if new references need to be added */
  339.             If version21 = 1 Then Do
  340.                os2p = pos('\OS2.DTP', ucdata)
  341.                If os2p <> 0 Then Do
  342.                   /* OS2.DTP found, must be pre-2.1 FIT, indicate  */
  343.                   /* OS2.DTP record is to be removed, add new INI references */
  344.                   removeentry = 1
  345.  
  346.                   If newos2iniflag <> 1 Then Do
  347.                      /* need to add new INI references */
  348.                      trg = '\\'servername'\WRKFILES\'client'\OS2\'
  349.                      src = clientbootdrv':\OS2\'
  350.                      newdata = src'OS2.!!!' || '   ' || blkspace || trg || 'OS2INI.!!!'
  351.                      Call Lineout tmpfitname, newdata
  352.                      newdata = src'OS2SYS.!!!' || blkspace || trg || 'OS2SYINI.!!!'
  353.                      Call Lineout tmpfitname, newdata
  354.                      newdata = src'OS2.###' || '   ' || blkspace || trg || 'OS2INI.###'
  355.                      Call Lineout tmpfitname, newdata
  356.                      newdata = src'OS2SYS.###' || blkspace || trg || 'OS2SYINI.###'
  357.                      Call Lineout tmpfitname, newdata
  358.                      newos2iniflag = 1
  359.                   end
  360.                end
  361.                else Do
  362.                   /* look for \APPS\*.TMP entry */
  363.                   os2p = pos('\APPS\*.TMP', ucdata)
  364.                   If os2p <> 0 Then Do
  365.                      /* check to see if new APPS entries have already been */
  366.                      /* encountered.  If not, insert new references prior to */
  367.                      /* *.TMP */
  368.                      If newos2appsiniflag <> 1 Then Do
  369.                         /* need to add new APPS references */
  370.                         trg = '\\'servername'\WRKFILES\'client'\OS2'
  371.                         src = clientbootdrv':\OS2\APPS\'
  372.                         newdata = src'*.INI' || blkspace || trg
  373.                         Call Lineout tmpfitname, newdata
  374.                         newdata = src'*.!!!' || blkspace || trg
  375.                         Call Lineout tmpfitname, newdata
  376.                         newdata = src'*.###' || blkspace || trg
  377.                         Call Lineout tmpfitname, newdata
  378.                         newos2appsiniflag = 1
  379.                      end
  380.                   end
  381.                   else Do
  382.                      /* watch for OS2KRNL reference */
  383.                      os2p = pos('\OS2KRNL', ucdata)
  384.                      If os2p <> 0 Then Do
  385.                         /* if PSFONTS have not been encountered, add it prior to */
  386.                         /* OS2KRNL reference */
  387.                         If psfontsflag = 0 Then Do
  388.                            /* add PSFONTS reference */
  389.                            newdata = clientbootdrv':\PSFONTS' || blkspace || newOS2'\PSFONTS'
  390.                            Call Lineout tmpfitname, newdata
  391.                            psfontsflag = 1
  392.                         end
  393.                      end
  394.                      else Do
  395.                         /* watch for APPS\*.$$$ reference */
  396.                         os2p = pos('\APPS\*.$$$', ucdata)
  397.                         If os2p <> 0 Then Do
  398.                            /* replace with new type reference */
  399.                            newdata = substr(data, 1, os2p+8) || '??' ||,
  400.                                      substr(data, os2p+11)
  401.                            data = newdata
  402.                         end
  403.                         else Do
  404.                            /* watch for WINOS2\*.GRP reference */
  405.                            os2p = pos('\WINOS2\*.GRP', ucdata)
  406.                            If os2p <> 0 Then Do
  407.                               /* set flag to cause new WINOS2 entries to be */
  408.                               /* added AFTER *.GRP */
  409.                               addnewwinos2flag = 1
  410.                            end
  411.                         end
  412.                      end
  413.                   end
  414.                end
  415.             end
  416.          end
  417.       end
  418.  
  419.       If removeentry = 0 Then Do
  420.          /* write data record to new FIT */
  421.          Call Lineout tmpfitname, data
  422.  
  423.          If addnewwinos2flag = 1 Then Do
  424.             /* add new WINOS2 entries.  They must be after *.GRP */
  425.             trg = '\\'servername'\WRKFILES\'client'\OS2\MDOS\WINOS2'
  426.             src = clientbootdrv':\OS2\MDOS\WINOS2\'
  427.             newdata = src'*.TMP' || '  ' || trg
  428.             Call Lineout tmpfitname, newdata
  429.             newdata = src'*.CAL' || '  ' || trg
  430.             Call Lineout tmpfitname, newdata
  431.             newdata = src'*.CRD' || '  ' || trg
  432.             Call Lineout tmpfitname, newdata
  433.             newdata = src'*.WRI' || '  ' || trg
  434.             Call Lineout tmpfitname, newdata
  435.             addnewwinos2flag = 0
  436.          end
  437.       end
  438.    end
  439.  
  440.    /* does os2ver statment need to be added? */
  441.    If version21 = 1  &  os2verflag = 0 Then Do
  442.       /* add os2ver statement to end of file */
  443.       Call lineout tmpfitname, '  '
  444.       data = clientbootdrv':\OS2VER' || blkspace || newOS2'\OS2VER'
  445.       Call Lineout tmpfitname, data
  446.    end
  447.  
  448.    Call Lineout tmpfitname   /* close file */
  449.    Call Lineout fitname      /* close file */
  450.  
  451.    /* rename original client.FIT */
  452.    '@rename 'fitname' 'client'.BAK'
  453.    if rc = 0 Then Do
  454.       /* rename client.TMP to be client.FIT */
  455.       '@rename 'tmpfitname' 'client'.FIT'
  456.       if rc = 0 Then Do
  457.          /* delete orginal client.FIT */
  458.          Call Delete_File bakfitname
  459.       end
  460.       else Do
  461.          /* rename error, try to restore original */
  462.          '@rename 'bakfitname'  'client'.FIT'
  463.          return 4
  464.       end
  465.    end
  466.    return 0
  467.  
  468.  
  469. /* subroutine to delete a file */
  470. Delete_File:
  471.    arg delfilename
  472.    If stream(delfilename, C, 'query exists') <> '' Then Do
  473.       '@DEL 'delfilename
  474.    end
  475.    return 0
  476.