home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 27 Fixes20 / 27-Fixes20.zip / XR0F048.2DK / unc.dsk / RPLSETD.CMD < prev    next >
OS/2 REXX Batch file  |  1994-01-14  |  27KB  |  836 lines

  1. /* RPLSETD.CMD - REXX program to convert an existing OS/2 Remote IPL client  */
  2. /*               to use one of the 32 bit graphics engine device drivers.    */
  3. /*                                                                           */
  4. /*    Copyright: (C) Copyright IBM Corp. 1992                                */
  5. /*                                                                           */
  6. /*               Note 1: All the variables are global to all subroutines.    */
  7. /*               Note 2: This command procedure will only run on OS/2 2.0.   */
  8. driver = ''
  9. client = ''
  10. logfile = ''
  11. currentOS2 = 'OS2.20'
  12. newOS2 = 'OS2.20a'
  13. changeOS2 = 0
  14. msg.0 = 0
  15. msg.1 = ''
  16. msg.2 = ''
  17. ddbootdrv = ''
  18. dd_data.0 = 0
  19.  
  20. Parse Arg  p1 p2 p3 p4 p5 .
  21. /* Check for help request (p1 = ? or '') */
  22. If p1 = '?' | p1 = '' Then Call Syntax_Help
  23.  
  24. parm.1 = p1
  25. parm.2 = p2
  26. parm.3 = p3
  27. parm.4 = p4
  28. parm.5 = p5
  29.  
  30. Do i = 1 to 5
  31.    If parm.i = '' Then Leave
  32.    parmtype = translate(substr(parm.i,1,2))
  33.    select
  34.       when parmtype = '/D' Then Do
  35.          if substr(parm.i, 3, 1) = ':' Then driver = substr(parm.i, 4)
  36.          else driver = substr(parm.i, 3)
  37.          driver = translate(driver)
  38.       end
  39.  
  40.       when parmtype = '/C' Then Do
  41.          if substr(parm.i, 3, 1) = ':' Then client = substr(parm.i, 4)
  42.          else client = substr(parm.i, 3)
  43.          client = translate(client)
  44.       end
  45.  
  46.       when parmtype = '/O' Then Do
  47.          if substr(parm.i, 3, 1) = ':' Then currentOS2 = substr(parm.i, 4)
  48.          else currentOS2 = substr(parm.i, 3)
  49.          changeOS2 = 1
  50.       end
  51.  
  52.       when parmtype = '/N' Then Do
  53.          if substr(parm.i, 3, 1) = ':' Then newOS2 = substr(parm.i, 4)
  54.          else newOS2 = substr(parm.i, 3)
  55.          changeOS2 = 1
  56.       end
  57.  
  58.       when parmtype = '/L' Then Do
  59.          if substr(parm.i, 3, 1) = ':' Then logfile = substr(parm.i, 4)
  60.          else logfile = substr(parm.i, 3)
  61.       end
  62.  
  63.       otherwise Do
  64.         msg.0 = 1
  65.         msg.1 = 'The option 'parm.i' is not a valid option.'
  66.         Call Display_Log_Msg
  67.         Call Error_Exit
  68.       end
  69.    end
  70. end
  71.  
  72. /* ensure that the REXXUTIL functions are registered. */
  73. Call RxFuncAdd 'SysLoadFuncs','RexxUtil','SysLoadFuncs'
  74. Call SysLoadFuncs
  75.  
  76. /* if logfile specified, delete old log file (if it exists) */
  77. If logfile <> '' Then Call SysFileDelete logfile
  78.  
  79. /* were required parameters  entered ?*/
  80. If driver = '' | client = '' Then Call Syntax_Help
  81.  
  82. /* Initialize INI variables. */
  83. key.1  = 'CURRENTDRIVER'
  84. key.2  = 'DEFAULTDRIVER'
  85. key.3  = 'IBMVGA'
  86. key.4  = 'IBMVGA32'
  87. key.5  = 'IBMXGA32'
  88. key.6  = 'IBM8514'
  89. keydata.1  = 'IBMVGA'||'00'x
  90. keydata.2  = 'IBMVGA'||'00'x
  91. keydata.3  = 'IBMVGA'||'00'x
  92. keydata.4  = 'IBMVGA32'||'00'x
  93. keydata.5  = 'IBMXGA32'||'00'x
  94. keydata.6  = 'IBM8514'||'00'x
  95. max = 6
  96. fontkey.1 = 'COURIER'
  97. fontkey.2 = 'HELV'
  98. fontkey.3 = 'TIMES'
  99. fontkeydata.1 = 'COURIER.FON'||'00'x
  100. fontkeydata.2 = 'HELV.FON'||'00'x
  101. fontkeydata.3 = 'TIMES.FON'||'00'x
  102. fontapp.1 = 'PM_Fonts'
  103. fontapp.2 = 'PM_Fonts'
  104. fontapp.3 = 'PM_Fonts'
  105. keys = 3
  106.  
  107. /* validate driver parameter */
  108. flag = 0
  109. Do i=3 to max
  110.    If driver=key.i Then Do
  111.       flag = 1
  112.       leave
  113.    end
  114. end
  115. if flag = 0 Then Call Syntax_Help
  116.  
  117. /* determine the bootdrive id */
  118. fspec = SysSearchPath('PATH', 'CMD.EXE')
  119. bootdrv = substr(fspec, 1, 1)
  120.  
  121. /* get path to IBMLAN directory */
  122. ibmlvlp = bootdrv':\IBMLVL.INI'
  123. laninip = SysIni(ibmlvlp, 'IBM_LS', 'PATH')
  124. If laninip = '' Then Do
  125.    msg.0 = 1
  126.    msg.1 = 'LAN Server is not installed.'
  127.    Call Display_Log_Msg
  128.    Call Error_Exit
  129. end
  130. if substr(laninip, length(laninip), 1) = '00'x Then Do
  131.    /* get rid of x00 at end of string */
  132.    laninip = substr(laninip, 1, length(laninip)-1)
  133. end
  134.  
  135. /* get rpldir parameter from IBMLAN.INI */
  136. Call SysFileSearch 'rpldir', laninip'\IBMLAN.INI', 'rpldirl.'
  137. if rpldirl.0 = 0 | rpldirl.0 = 'RPLDIRL.0' Then Do
  138.    msg.0 = 1
  139.    msg.1 = 'OS/2 Remote IPL support is not installed'
  140.    Call Display_Log_Msg
  141.    Call Error_Exit
  142. end
  143. position = pos('=', rpldirl.1)
  144. rpldir = substr(rpldirl.1, position+1)
  145. rpldir = strip(rpldir)
  146.  
  147. /* determine if desired device driver is installed */
  148. If changeOS2 = 1 Then ddpath = rpldir'\'newOS2'\OS2\DLL\'
  149. else  ddpath = rpldir'\'currentOS2'\OS2\DLL\'
  150. Call SysFileTree ddpath||driver||'.DLL', 'devdrv', 'S'
  151. if result = 'ERROR:' Then Do
  152.    msg.0 = 1
  153.    msg.= 'Error 'rc'occurred while trying to locate 'ddpath
  154.    Call Display_Log_Msg
  155.    Call Error_Exit
  156. end
  157. if devdrv.0 = 0 Then Do
  158.    msg.0 = 2
  159.    msg.1 = 'The display driver 'driver'.DLL is not installed in the Remote IPL'
  160.    msg.2 = 'directory 'ddpath'.'
  161.    Call Display_Log_Msg
  162.    Call Error_Exit
  163. end
  164.  
  165. /* get LAN Server version */
  166. Call Get_LAN_Server_Version
  167. if result <> 0 Then Exit
  168.  
  169. /* determine if client is a single name or list of names */
  170. /* assume it is a client name to start with */
  171. cltlst.0 = 0
  172. if length(client) > 8 | lines(rpldir'\FITS\'client'.FIT') = 0 Then Do
  173.    Call SysFileTree client, 'cltlst', 'S'
  174.    if result = 'ERROR:' | cltlst.0 = 0 Then Do
  175.       msg.0 = 1
  176.       msg.1 = client' is not valid client name or list file.'
  177.       Call Display_Log_Msg
  178.       Call Error_Exit
  179.    end
  180. end
  181.  
  182. if cltlst.0 = 0 Then Do
  183.    /* single client specified */
  184.    Call Update_Client_Files
  185. end
  186. else Do
  187.    /* a list of client names was provided in a list file */
  188.    clientlist = client
  189.    do until lines(clientlist) = 0
  190.       client = translate(linein(clientlist))
  191.       Call Update_Client_Files
  192.    end
  193. end
  194. If logfile <> '' Then Call Lineout logfile
  195. exit
  196. /* end of main routine */
  197.  
  198.  
  199. /*************** Start of subroutines ***************************/
  200. /* Subroutine Syntax_Help */
  201. /* This subroutine displays the syntax help panel. */
  202. Syntax_Help:
  203.   If logfile = '' Then Do
  204.      Say 'RPLSETD  /D:driver  /C:client  [/O:current_OS2]  [/N:new_OS2]  [/L:logfile]'
  205.      Say '    where driver is the new display type for the client definition.'
  206.      Say '                 The following display types are valid:'
  207.      Say '                   IBMVGA32  - 32 bit VGA display driver'
  208.      Say '                   IBMXGA32  - 32 bit XGA display driver'
  209.      Say '                   IBM8514   - 32 bit 8514 display driver'
  210.      Say '          client is the name of the OS/2 Remote IPL client workstation'
  211.      Say '                 or it is the fully qualified name of a file containing'
  212.      Say '                 a list of client workstations.'
  213.      Say '          current_OS2 (optional) is the root directory for the current OS/2 2.0'
  214.      Say '                      operating system the client is booting.  This parameter'
  215.      Say '                      is case sensitive.  The default is OS2.20'.
  216.      Say '          new_OS2 (optional) is the root directory for the OS/2 2.0 operating'
  217.      Say '                  system that the client is to be switched to.  This parameter'
  218.      Say '                  is case sensitive.  The default is OS2.20a.'
  219.      Say '          logfile (optional) is the name of a file to which all messages and'
  220.      Say '                  errors are to be logged.  If logfile is specified, no'
  221.      Say '                  messages or errors will be displayed on the screen.'
  222.      exit
  223.   end
  224.   else Do
  225.      msg.0 = 2
  226.      msg.1 = 'An error was detect in the following RPLSETD command syntax:'
  227.      msg.2 = '  RPLSETD' p1  p2  p3  p4  p5
  228.      Call Display_Log_Msg
  229.      Call Error_Exit
  230.   end
  231.  
  232.  
  233.  
  234. /* Subroutine Error_Exit */
  235. /* This subroutine cleans up on an error exit. */
  236. Error_Exit:
  237. If logfile <> '' Then Do
  238.    Call Lineout logfile
  239.    Say 'Error detected.  Check log file: 'logfile
  240. end
  241. exit 4
  242.  
  243.  
  244. /* Subroutine Display_Log_Msg */
  245. /* This subroutine displays messages to the screen or logs them to the */
  246. /* log file. */
  247. Display_Log_Msg:
  248. Do i = 1 to msg.0
  249.    If logfile = '' Then Say msg.i
  250.    else Call Lineout logfile, msg.i
  251. end
  252. msg.0 = 0
  253. return 0
  254.  
  255.  
  256.  
  257. /* Subroutine Get_LAN_Server_Version */
  258. /* This subroutine determine the version of LAN Server installed in  */
  259. /* the Remote IPL directory. */
  260. Get_LAN_Server_Version:
  261. /* get path to IBMLAN directory */
  262. ibmlvlp = bootdrv':\IBMLVL.INI'
  263. LS_version = ''
  264. lanrel = SysIni(ibmlvlp, 'IBM_LS', 'RELEASE')
  265. If result <> 'ERROR:' Then Do
  266.    lanver = SysIni(ibmlvlp, 'IBM_LS', 'VERSION')
  267.    If result <> 'ERROR:' Then Do
  268.       if substr(lanrel, length(lanrel), 1) = '00'x Then Do
  269.          /* get rid of x00 at end of string */
  270.          lanrel = substr(lanrel, 1, length(lanrel)-1)
  271.       end
  272.       if substr(lanver, length(lanver), 1) = '00'x Then Do
  273.          /* get rid of x00 at end of string */
  274.          lanver = substr(lanver, 1, length(lanver)-1)
  275.       end
  276.       LS_version = lanrel || lanver
  277.    end
  278. end
  279. If LS_version = '' Then Do
  280.    msg.0 = 1
  281.    msg.1 = 'Unable to determine the version of LAN Server in the Remote IPL directory.'
  282.    Call Display_Log_Msg
  283.    return 4
  284. end
  285. return 0
  286.  
  287.  
  288.  
  289. /* Subroutine Update_Client_Files */
  290. /* This subroutine calls the subroutines to update each client file. */
  291. Update_Client_Files:
  292. /* update the client copy of OS2INI.20 */
  293. Call Update_Client_Ini
  294. If result = 0 Then Do
  295.    msg.0 = 1
  296.    msg.1 = client' copy of OS2INI.20 was updated.'
  297.    Call Display_Log_Msg
  298. end
  299. else Do
  300.    msg.0 = 1
  301.    msg.1 = client' copy of OS2INI.20 was not updated.'
  302.    Call Display_Log_Msg
  303. end
  304.  
  305. /* update the client CONFIG.20 file.  If the client is DEFALT20, then */
  306. /* there is special processing to update each of the master CONFIG.20 */
  307. /* files in the RPL\IBMCOM tree. */
  308. if client = 'DEFALT20' Then Do
  309.    /* get list of directories in RPL\IBMCOM */
  310.    Call SysFileTree rpldir'\IBMCOM\*.*', 'lanlist', D
  311.  
  312.    /* for DEFALT20 update each of the lantype CONFIG.20 files */
  313.    Do lli = 1 to lanlist.0
  314.       lanpath = word(lanlist.lli, 5)
  315.       lanpos = lastpos('\', lanpath)
  316.       lantype = translate(substr(lanpath, lanpos + 1))
  317.       /* exclude the normal IBMCOM directories, process only the special */
  318.       /* RPL directories. */
  319.       If (lantype <> 'DLL' & lantype <> 'INCLUDE' & lantype <> 'MACS' & lantype <> 'PROTOCOL') Then Do
  320.          If lines(rpldir'\IBMCOM\'lantype'\CONFIG.20') Then Do
  321.             /* a CONFIG.20 file is present, update it */
  322.             Call Update_Client_Config_20
  323.             If result = 0 Then Do
  324.                msg.0 = 1
  325.                msg.1 = client lantype 'copy of CONFIG.20 was updated.'
  326.                Call Display_Log_Msg
  327.             end
  328.             else Do
  329.                msg.0 = 1
  330.                msg.1 = client lantype 'copy of CONFIG.20 was not updated.'
  331.                Call Display_Log_Msg
  332.             end
  333.          end
  334.       end
  335.    end
  336. end
  337. else Do
  338.    /* not the DEFALT20 client */
  339.    Call Update_Client_Config_20
  340.    If result = 0 Then Do
  341.       msg.0 = 1
  342.       msg.1 = client' copy of CONFIG.20 was updated.'
  343.       Call Display_Log_Msg
  344.    end
  345.    else Do
  346.       msg.0 = 1
  347.       msg.1 = client' copy of CONFIG.20 was not updated.'
  348.       Call Display_Log_Msg
  349.    end
  350. end
  351.  
  352. /* Update the client.FIT file */
  353. Call Update_Client_Fit
  354. If result = 0 Then Do
  355.    msg.0 = 1
  356.    msg.1 = client'.FIT was updated.'
  357.    Call Display_Log_Msg
  358. end
  359. else Do
  360.    msg.0 = 1
  361.    msg.1 = client'.FIT was not updated.'
  362.    Call Display_Log_Msg
  363. end
  364. msg.0 = 1
  365. msg.1 = '  '
  366. Call Display_Log_Msg
  367. return 0
  368.  
  369.  
  370.  
  371. /* Subroutine Update_Client_Ini */
  372. /* This subroutine updates the OS2INI.20 file for a client workstation */
  373. /* to add the required profile data to support the specified device driver. */
  374. Update_Client_Ini:
  375.  
  376. /* build fully qualified path name for OS2INI.20 */
  377. ininame = rpldir'USER\'client'\OS2\OS2INI.20'
  378.  
  379. /* Update client copy of OS2.INI (OS2INI.20) */
  380. error = 4
  381. Do i=1 to max
  382.    If 'ERROR:' = SysIni(ininame,'PM_DISPLAYDRIVERS',key.i,keydata.i) Then Do
  383.       msg.0 = 1
  384.       msg.1 = client 'Error setting key "'key.i'" in OS2INI.20.'
  385.       Call Display_Log_Msg
  386.       return 4
  387.    End  /* Do */
  388. End /* do */
  389.  
  390. If driver <> '' Then Do
  391.    Do i=3 to max
  392.       If driver=key.i Then Do
  393.          Call SysIni ininame,'PM_DISPLAYDRIVERS',key.1,keydata.i
  394.          Call SysIni ininame,'PM_DISPLAYDRIVERS',key.2,keydata.i
  395.          If driver='IBMXGA32' Then Do j=1 to keys
  396.             Call SysIni ininame,fontapp.j,fontkey.j,'\OS2\DLL\'fontkeydata.j
  397.          End
  398.       End  /* Do */
  399.    End /* do */
  400. End  /* Do */
  401. return 0
  402.  
  403.  
  404.  
  405.  
  406. /* Subroutine Update_Client_Fit */
  407. /* This subroutine creates a new client.FIT by making the following */
  408. /* changes to the original FIT: */
  409. /*   - Comment out the DISPLAY.DLL entries. */
  410. /*   - Enables the correct .FON entries for the specified display driver. */
  411. /*   - If requested, changes the target OS2 root directory. */
  412. Update_Client_Fit:
  413.  
  414. /* build fully qualified path names for client.??? */
  415. fitname = rpldir'\FITS\'client'.FIT'
  416. tmpfitname = rpldir'\FITS\'client'.TMP'
  417. bakfitname = rpldir'\FITS\'client'.BAK'
  418. Call SysFileDelete tmpfitname
  419. Call SysFileDelete bakfitname
  420.  
  421. If lines(fitname) Then Do
  422.    /* client.FIT does exists, build a new FIT */
  423.    do until lines(fitname) = 0
  424.       data = linein(fitname)
  425.       If data <> '' & substr(data, 1, 2) <> '\\' Then Do
  426.          /* not a null line or a UNC line, check line */
  427.          datap = pos(':\OS2\DLL\DISPLAY.DLL', data)
  428.          if datap <> 0 Then Do
  429.             if substr(data,1,1) <> ';' Then Do
  430.                /* comment out DISPLAY.DLL entry */
  431.                newdata = ';'data
  432.                data = newdata
  433.             end
  434.          end
  435.          else Do
  436.             /* check for .FON entry and enable/disable the entry */
  437.             /* depending on the driver type */
  438.             helvp = 0
  439.             courp = 0
  440.             timesp = 0
  441.             helvp = pos(':\OS2\DLL\HELV.FON', data)
  442.             If helvp = 0 Then Do
  443.                courp = pos(':\OS2\DLL\COURIER.FON',data)
  444.                If courp = 0 Then Do
  445.                   timesp = pos(':\OS2\DLL\TIMES.FON',data)
  446.                end
  447.             end
  448.             If helvp <> 0 | courp <> 0 | timesp <> 0 Then Do
  449.               datal = length(data)
  450.               If driver = 'IBMVGA32' | DRIVER = 'IBMVGA' Then Do
  451.                  If substr(data, datal-2, 3) <> 'VGA' Then Do
  452.                     If substr(data, 1,1) <> ';' Then Do
  453.                        /* disable non-VGA .FON entry */
  454.                        newdata = ';'data
  455.                        data = newdata
  456.                     end
  457.                  end
  458.                  else If substr(data, 1, 1) = ';' Then Do
  459.                     /* enable VGA .FON entry */
  460.                     data = substr(data, 2)
  461.                  end
  462.               end
  463.               else If driver = 'IBMXGA32' | driver = 'IBM8514' Then Do
  464.                  If substr(data, datal-2, 3) <> 'BGA' Then Do
  465.                     If substr(data, 1, 1) <> ';' Then Do
  466.                        /* disable non-XGA/8514 .FON entry */
  467.                        newdata = ';'data
  468.                        data = newdata
  469.                     end
  470.                  end
  471.                  else If substr(data, 1, 1) = ';' Then Do
  472.                     /* enable XGA/8514 .FON entry */
  473.                     data = substr(data, 2)
  474.                  end
  475.               end
  476.             end
  477.          end
  478.          /* check for possible operating system change */
  479.          if changeOS2 = 1 Then Do
  480.             If substr(data, 1, 2) = '; ' Then srvfname = word(data, 3)
  481.             else srvfname = word(data, 2)
  482.             os2p = pos(currentOS2'\', srvfname)
  483.             if os2p <> 0 Then Do
  484.                /* old OS2 entry found, update it */
  485.                os2p = pos(currentOS2, data, length(word(data,1))+1)
  486.                newdata = substr(data, 1, os2p-1)
  487.                newdata = newdata || newOS2
  488.                newdata = newdata || substr(data, os2p+length(currentOS2))
  489.                data = newdata
  490.             end
  491.          end
  492.       end
  493.       /* write data record to new FIT */
  494.       Call Lineout tmpfitname, data
  495.    end
  496.    Call Lineout tmpfitname   /* close file */
  497.    Call Lineout fitname      /* close file */
  498.  
  499.    /* rename original client.FIT */
  500.    cmdstr = '@rename 'fitname' 'client'.BAK'
  501.    address CMD cmdstr
  502.    if rc = 0 Then Do
  503.       /* rename client.TMP to be client.FIT */
  504.       cmdstr = '@rename 'tmpfitname' 'client'.FIT'
  505.       address CMD cmdstr
  506.       if rc = 0 Then Do
  507.          /* delete orginal client.FIT */
  508.          Call SysFileDelete bakfitname
  509.       end
  510.       else Do
  511.          /* rename error, try to restore original */
  512.          cmdstr = '@rename 'bakfitname'  'client'.FIT'
  513.          address CMD cmdstr
  514.    end
  515. end
  516. else return 4
  517. return 0
  518.  
  519.  
  520.  
  521. /* Subroutine Update_Client_Config_20 */
  522. /* This subroutine creates a new CONFIG.20 for the client that has the */
  523. /* appropriate display device drivers enabled. */
  524. Update_Client_Config_20:
  525.  
  526. /* if LS 2.0 file, convert it to new format */
  527. If LS_version = '200' Then Call Update_LS20_Config_20
  528. If result <> 0 Then Do
  529.    msg.0 = 1
  530.    msg.1 = 'An error occurred while updating the file 'rpldir'\IBMCOM\'lantype'\CONFIG.20'
  531.    Call Display_Log_Msg
  532.    return 4
  533. end
  534.  
  535. /* build fully qualified path names for client CONFIG.20 */
  536. If client = 'DEFALT20' Then Do
  537.    /* DEFALT20 is special case, it must be called for each lantype */
  538.    configname = rpldir'\IBMCOM\'lantype'\CONFIG.20'
  539.    tmpconfigname = rpldir'\IBMCOM\'lantype'\CONFIG.20T'
  540.    bakconfigname = rpldir'\IBMCOM\'lantype'\CONFIG.20B'
  541. end
  542. else Do
  543.    configname = rpldir'\MACHINES\'client'\CONFIG.20'
  544.    tmpconfigname = rpldir'\MACHINES\'client'\CONFIG.20T'
  545.    bakconfigname = rpldir'\MACHINES\'client'\CONFIG.20B'
  546. end
  547. Call SysFileDelete tmpconfigname
  548. Call SysFileDelete bakconfigname
  549.  
  550. If lines(configname) Then Do
  551.    /* copy records to first DEVINFO (XGA) */
  552.    flag = 0
  553.    do until lines(configname) = 0
  554.       data = linein(configname)
  555.       If pos('DEVINFO=', data) <> 0 Then Leave
  556.       xgacomp = pos('ing 6 state', data)
  557.       If xgacomp <> 0 & driver = 'IBMXGA32' Then Do
  558.          /* update XGA comment statement */
  559.          newdata = substr(data, 1, xgacomp+3)||'7'||substr(data, xgacomp+5)
  560.          data = newdata
  561.       end
  562.       Call Lineout tmpconfigname, data
  563.    end
  564.  
  565.    /* process XGA statements */
  566.    position = pos(':\OS2\', data)
  567.    bootdrv2 = substr(data, position-1, 1)
  568.    flag = 0
  569.    Do while flag = 0
  570.       If driver = 'IBMXGA32' Then Do
  571.          If translate(substr(data, 1, 4)) = 'REM ' Then Do
  572.             data = substr(data, 5)
  573.          end
  574.          if pos('\OS2\MDOS\VVGA.SYS', data) <> 0 Then Do
  575.             If pos('\OS2\XGA.SYS', lastrecord) = 0 Then Do
  576.                /* insert the XGA.SYS record */
  577.                newdata = 'DEVICE='bootdrv2':\OS2\XGA.SYS'
  578.                Call Lineout tmpconfigname, newdata
  579.             end
  580.          end
  581.       end
  582.       else Do
  583.          /* make sure records are REMed out */
  584.          if substr(data, 1, 4) <> 'REM ' Then Do
  585.             newdata = 'REM '||data
  586.             data = newdata
  587.          end
  588.       end
  589.       Call lineout tmpconfigname, data
  590.       lastrecord = data
  591.       if pos('SET VIO_XGA=', data) <> 0 Then flag = 1
  592.       else data = linein(configname)
  593.    end
  594.  
  595.    /* copy records to next DEVINFO (8514) */
  596.    flag = 0
  597.    do until lines(configname) = 0
  598.       data = linein(configname)
  599.       If pos('DEVINFO=', data) <> 0 Then Leave
  600.       Call Lineout tmpconfigname, data
  601.    end
  602.  
  603.    /* process 8514 statements */
  604.    flag = 0
  605.    Do while flag = 0
  606.       If driver = 'IBM8514' Then Do
  607.          If translate(substr(data, 1, 4)) = 'REM ' Then Do
  608.             data = substr(data, 5)
  609.          end
  610.       end
  611.       else Do
  612.          /* make sure records are REMed out */
  613.          if substr(data, 1, 4) <> 'REM ' Then Do
  614.             newdata = 'REM '||data
  615.             data = newdata
  616.          end
  617.       end
  618.       Call lineout tmpconfigname, data
  619.       lastrecord = data
  620.       if pos('\V8514A.SYS', data) <> 0 Then flag = 1
  621.       else data = linein(configname)
  622.    end
  623.  
  624.    /* copy records to the VGA DEVINFO */
  625.    do until lines(configname) = 0
  626.       data = linein(configname)
  627.       newdata = translate(data)
  628.       If pos('DEVINFO=SCR,VGA', newdata) <> 0 Then Leave
  629.       Call Lineout tmpconfigname, data
  630.    end
  631.    newdata = ''
  632.  
  633.    /* process VGA statements */
  634.    flag = 0
  635.    Do while flag = 0
  636.       If driver = 'IBMVGA' | driver = 'IBMVGA32' Then Do
  637.          If translate(substr(data, 1, 4)) = 'REM ' Then Do
  638.             data = substr(data, 5)
  639.          end
  640.       end
  641.       else Do
  642.          /* make sure records are REMed out */
  643.          if substr(data, 1, 4) <> 'REM ' Then Do
  644.             newdata = 'REM '||data
  645.             data = newdata
  646.          end
  647.       end
  648.       Call lineout tmpconfigname, data
  649.       lastrecord = data
  650.       if pos('\VVGA.SYS', data) <> 0 Then flag = 1
  651.       else data = linein(configname)
  652.    end
  653.  
  654.    /* copy remaining records */
  655.    do until lines(configname) = 0
  656.       data = linein(configname)
  657.       Call Lineout tmpconfigname, data
  658.    end
  659.  
  660.    Call Lineout tmpconfigname   /* close file */
  661.    Call Lineout configname      /* close file */
  662.  
  663.    /* rename original CONFIG.20 */
  664.    cmdstr = '@rename 'configname' CONFIG.20B'
  665.    address CMD cmdstr
  666.    if rc = 0 Then Do
  667.       /* rename CONFIG.20T to be CONFIG.20 */
  668.       cmdstr = '@rename 'tmpconfigname' CONFIG.20'
  669.       address CMD cmdstr
  670.       if rc = 0 Then Do
  671.          /* delete orginal CONFIG.20 */
  672.          Call SysFileDelete bakconfigname
  673.       end
  674.       else Do
  675.          /* rename error, try to restore original */
  676.          cmdstr = '@rename 'bakconfigname' CONFIG.20'
  677.          address CMD cmdstr
  678.       end
  679.    end
  680. end
  681. else return 4   /* file not found */
  682. return 0
  683.  
  684.  
  685.  
  686. /* Subroutine Update_LS20_Config_20 */
  687. /* This subroutine converts a LAN Server 2.0 CONFIG.20 file to the new format */
  688. Update_LS20_Config_20:
  689.  
  690. /* build fully qualified path names for client CONFIG.20 */
  691. If client = 'DEFALT20' Then Do
  692.    /* DEFALT20 is special case, it must be called for each lantype */
  693.    configname = rpldir'\IBMCOM\'lantype'\CONFIG.20'
  694.    tmpconfigname = rpldir'\IBMCOM\'lantype'\CONFIG.20T'
  695.    bakconfigname = rpldir'\IBMCOM\'lantype'\CONFIG20.BAK'
  696. end
  697. else Do
  698.    configname = rpldir'\MACHINES\'client'\CONFIG.20'
  699.    tmpconfigname = rpldir'\MACHINES\'client'\CONFIG.20T'
  700.    bakconfigname = rpldir'\MACHINES\'client'\CONFIG20.BAK'
  701. end
  702. Call SysFileDelete tmpconfigname
  703. Call SysFileDelete bakconfigname
  704.  
  705. /* determine bootdrive id from PROTSHELL statement */
  706. do until lines(configname) = 0
  707.    data = translate(linein(configname))
  708.    If substr(data, 1, 9) = 'PROTSHELL' Then Do
  709.       ddi = pos(':\', data)
  710.       newbootdrv = substr(data,ddi - 1, 1)
  711.       Leave
  712.    end
  713. end
  714. Call Lineout configname     /* close file */
  715. if newbootdrv = '' Then return 4
  716.  
  717. /* check to see if file has already been updated with new device driver */
  718. /* statements */
  719. Call SysFileSearch '\OS2\XGA.SYS', configname, 'xgasys.'
  720. If xgasys.0 = 0 Then Do
  721.    /* file has not been updated, update it */
  722.  
  723.    /* check to see if dd_data needs to be initialized */
  724.    If ddbootdrv <> newbootdrv Then Do
  725.       dd_data.0 = 0
  726.       ddbootdrv = newbootdrv
  727.    end
  728.    If dd_data.0 = 0 Then Do
  729.       /* initialize dd_data */
  730.       dd_data.0 = 21
  731.       dd_data.1 = 'REM Use the following 7 statements for workstations with XGA displays:'
  732.       dd_data.2 = 'REM DEVINFO=SCR,BGA,'ddbootdrv':\OS2\VIOTBL.DCP'
  733.       dd_data.3 = 'REM DEVICE='ddbootdrv':\OS2\XGARING0.SYS'
  734.       dd_data.4 = 'REM DEVICE='ddbootdrv':\OS2\XGA.SYS'
  735.       dd_data.5 = 'REM DEVICE='ddbootdrv':\OS2\MDOS\VVGA.SYS'
  736.       dd_data.6 = 'REM DEVICE='ddbootdrv':\OS2\MDOS\VXGA.SYS '
  737.       dd_data.7 = 'REM SET VIDEO_DEVICES=VIO_XGA'
  738.       dd_data.8 = 'REM SET VIO_XGA=DEVICE(BVHVGA,BVHXGA)'
  739.       dd_data.9 = ' '
  740.       dd_data.10 = 'REM Use the following 5 statements for workstations with 8514/A adapters:'
  741.       dd_data.11 = 'REM DEVINFO=SCR,BGA,'ddbootdrv':\OS2\VIOTBL.DCP'
  742.       dd_data.12 = 'REM SET VIDEO_DEVICES=VIO_8514A'
  743.       dd_data.13 = 'REM SET VIO_8514A=DEVICE(BVHVGA,BVH8514A)'
  744.       dd_data.14 = 'REM DEVICE='ddbootdrv':\OS2\MDOS\VVGA.SYS'
  745.       dd_data.15 = 'REM DEVICE='ddbootdrv':\OS2\MDOS\V8514A.SYS'
  746.       dd_data.16 = ' '
  747.       dd_data.17 = 'REM Use the following 4 statements for workstations with VGA displays:'
  748.       dd_data.18 = 'DEVINFO=SCR,VGA,'ddbootdrv':\OS2\VIOTBL.DCP'
  749.       dd_data.19 = 'SET VIDEO_DEVICES=VIO_VGA'
  750.       dd_data.20 = 'SET VIO_VGA=DEVICE(BVHVGA)'
  751.       dd_data.21 = 'DEVICE='ddbootdrv':\OS2\MDOS\VVGA.SYS'
  752.    end
  753.  
  754.    If lines(configname) Then Do
  755.       /* copy records until the DEVINFO=SCR,.. statement */
  756.       do until lines(configname) = 0
  757.          data = translate(linein(configname))
  758.          If substr(data, 1, 12) = 'DEVINFO=SCR,' Then Leave
  759.          Call Lineout tmpconfigname,data
  760.       end
  761.  
  762.       Call Lineout tmpconfigname, ' '   /* blank line */
  763.  
  764.       /* write new device driver statements to file */
  765.       do ddi= 1 to dd_data.0
  766.         Call lineout tmpconfigname, dd_data.ddi
  767.       end
  768.  
  769.       Call Lineout tmpconfigname, ' '   /* blank line */
  770.  
  771.       /* skip display records until POINTDD.SYS statement */
  772.       do until lines(configname) = 0
  773.          data = translate(linein(configname))
  774.          skip = 0
  775.          ddp1 = pos('XGARING0.SYS', data)
  776.          If ddp1 <> 0 Then skip = 1
  777.          else Do
  778.             ddp1 = pos('VXGA.SYS', data)
  779.             if ddp1 <> 0 Then skip = 1
  780.             else Do
  781.                ddp1 = pos('VIO_XGA', data)
  782.                if ddp1 <> 0 Then skip = 1
  783.                else Do
  784.                   ddp1 = pos('VIO_VGA', data)
  785.                   if ddp1 <> 0 Then skip = 1
  786.                   else Do
  787.                      ddp1 = pos('VVGA.SYS', data)
  788.                      if ddp1 <> 0 Then skip = 1
  789.                      else Do
  790.                         ddp1 = pos('VGA DISPLAYS:', data)
  791.                         if ddp1 <> 0 Then skip = 1
  792.                         else Do
  793.                            ddp1 = pos('XGA DISPLAYS:', data)
  794.                            if ddp1 <> 0 Then skip = 1
  795.                         end
  796.                      end
  797.                   end
  798.                end
  799.             end
  800.          end
  801.          If substr(data, 15, 11) = 'POINTDD.SYS' Then Leave
  802.          If skip = 0 Then Do
  803.            If data <> '' Then Call Lineout tmpconfigname, data
  804.          end
  805.       end
  806.  
  807.       Call Lineout tmpconfigname, data  /* write pointdd.sys */
  808.  
  809.       /* copy remaining records */
  810.       do until lines(configname) = 0
  811.          data = linein(configname)
  812.          Call Lineout tmpconfigname, data
  813.       end
  814.  
  815.       Call Lineout configname
  816.       Call Lineout tmpconfigname
  817.  
  818.       /* rename original CONFIG.20 */
  819.       cmdstr = '@rename 'configname' CONFIG20.BAK'
  820.       address CMD cmdstr
  821.       if rc = 0 Then Do
  822.          /* rename CONFIG.20T to be CONFIG.20 */
  823.          cmdstr = '@rename 'tmpconfigname' CONFIG.20'
  824.          address CMD cmdstr
  825.          if rc <> 0 Then Do
  826.             /* rename error, try to restore original */
  827.             cmdstr = '@rename 'bakconfigname' CONFIG.20'
  828.             address CMD cmdstr
  829.             return 4
  830.          end
  831.       end
  832.       else return 4
  833.    end
  834. end
  835. return 0
  836.