home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 4 Drivers / 04-Drivers.zip / 72xxos2.zip / INSTALL.CMD < prev    next >
OS/2 REXX Batch file  |  1995-10-26  |  8KB  |  242 lines

  1. /* REXX script */
  2. /*      MPF  12/23/93   */
  3. /*
  4. trace ?r                        /* For debugging */
  5. */
  6. /* revised for Cirrus ADIO210.ADD ejc 10/3/95  */
  7. /* revised to support 2.1 and Warp ejc 10/26/95 */
  8. /*         also changed to preserve command line parameters */
  9.  
  10. '@echo off'
  11.  
  12. call RxFuncAdd 'SysOS2Ver', 'RexxUtil', 'SysOS2Ver'
  13. call RxFuncAdd 'SysFileTree', 'RexxUtil', 'SysFileTree'
  14. /* get the version of OS2 running.  Warp is 2.30  */
  15. version = SysOS2Ver()
  16.  
  17. bootdrive = GetBootDrive()            /* Get boot drive from env */
  18.  
  19. targetdir = bootdrive || ':\OS2'
  20. OSver = 'OS/2 version '|| version
  21. if version = 2.30 then 
  22.     do
  23.          targetdir = bootdrive || ':\OS2\BOOT'
  24.          OSver = 'OS/2 Warp'
  25.     end
  26. if version > 2.30 then 
  27.     do
  28.          targetdir = bootdrive || ':\OS2\BOOT'
  29.          OSver = 'OS/2 trans-Warp (???)'
  30.     end
  31.  
  32.  
  33. /* find all of the appropriate drivers in this directory */
  34.  
  35.     rc = SysFileTree( 'ADI*.ADD',drivers, O )         /* get only the file names */
  36.     NewDriver = drivers.1
  37.     if drivers.0 > 1 then
  38.     do
  39.          do i = 1 to drivers.0
  40.               drivers.i = translate( drivers.i )      /* uppercase it */
  41.               drivers.i = substr( drivers.i, lastpos( '\', drivers.i)+1 )
  42.               /* trim off the leading path */
  43.          end
  44.          
  45.          do i=0 to drivers.0
  46.               if drivers.i > NewDriver then Newdriver = drivers.i
  47.          end
  48.     end
  49.  
  50.  
  51.  
  52.  
  53. /*adiver = '210'*/
  54. ofile = 'TMP.CIR'
  55. OldDriver = 'IBM1S506.ADD'
  56. /*NewDriver = ADIO || adiver || '.ADD'*/
  57. /* NewDev = 'BASEDEV=' || NewDriver */
  58.  
  59.  
  60. say '      ╔═══════════════════════════════════════════════════════════════╗'
  61. say '      ║  Cirrus Logic Device Driver install for OS/2 2.x and Warp     ║'
  62. say '      ╟───────────────────────────────────────────────────────────────╢'
  63. say '      ║   This program will copy the device driver from the current   ║'
  64. say '      ║   disk to your OS/2 directory and modify your CONFIG.SYS.     ║'
  65. say '      ║                                                               ║'
  66. say overlay( OSver, '      ║   Your system is running                                      ║', 34 )
  67. say overlay( NewDriver,'      ║   The newest driver found on this disk is:                    ║', 52)
  68. /*                say overlay( targetdir,'      ║   The target for your version of OS/2 is:                     ║',51) */
  69. say overlay( OSver || ' is: '||targetdir,'      ║   The target directory for                                    ║',36)
  70. say '      ║                                                               ║'
  71. say '      ║       (For more information see the file README.OS2)          ║'
  72. say '      ╚═══════════════════════════════════════════════════════════════╝'
  73.  
  74.    do
  75.     ifile = 'CONFIG.SYS'
  76.     ipath = ':\'
  77.     opath = ':\'
  78.     BackupName = 'CONFIG.CIR'
  79. end /* do */
  80.             
  81. parse source OSName HowCalled WhereFrom        /* Get ARGV[0] */
  82. /*
  83. InstallDrive = substr(strip(WhereFrom), 1, 1)    /* Get drive of install */
  84. */
  85. /* Get the path component */
  86. temp = reverse(translate(WhereFrom))
  87. InstallPath = reverse(substr(temp, (pos('\', temp))))
  88.  
  89.  
  90. /* The AZ in front of a file name stands for ASCIIZ which means */
  91. /*  that it is a full path name of the form: "drive:\path\file" */
  92. AZinfile = bootdrive || ipath || ifile
  93. AZoutfile = bootdrive || opath || ofile
  94. AZBackupFile = bootdrive || ipath || BackupName
  95. /* AZDriverFile = InstallDrive || ipath || NewDriver */
  96. AZDriverFile = InstallPath || NewDriver
  97.  
  98. arg CmdLineArgs                    /* Get command line args */
  99. CmdLineArgs = strip(CmdLineArgs)        /* Strip leading blanks */
  100. if CmdLineArgs <> '' then do
  101.     if (CmdLineArgs = '/U') | (CmdLineArgs = 'U') then do
  102.         say '        WARNING: Currently the uninstall option just'
  103.         say '        copies CONFIG.CIR to CONFIG.SYS. Any changes'
  104.         say '        you have made to CONFIG.SYS since you installed'
  105.         say '        the PD-72xx driver will be lost.'
  106.         say 'Do you want to uninstall the PD-72xx driver? (Y/N)'
  107.         pull answer
  108.         rc = abbrev('YES',strip(answer),1)
  109.  
  110.         if rc = 0 then do
  111.             say "You chose to Abort"
  112.             exit
  113.         end /* If */
  114.  
  115.         rc = stream(AZBackupFile, 'c', 'query exists')
  116.  
  117.         if rc = '' then do
  118.             say AZBackupFile 'does not exist'
  119.             exit
  120.         end /* If */
  121.  
  122.         say 'COPYING' AZBackupFile 'TO' AZinfile
  123.         copy AZBackupFile AZinfile
  124.         say 'Uninstall complete'
  125.         exit
  126.     end /* If */
  127.  
  128.     else do
  129.         say 'I do not understand' CmdLineArgs
  130.         exit
  131.     end /* Else */
  132.  
  133. end /* If */
  134.  
  135. say 'Do you wish to continue? (Y/N)'
  136. pull answer
  137. rc = abbrev('YES',strip(answer),1)
  138. if rc = 0 then do
  139.     say "You chose to Abort"
  140.     exit
  141. end /* If */
  142.  
  143. say "Proceeding with the installation"
  144. rc = stream(AZinfile, 'c', 'query exists') /* Returns NUL if doesn't exist */
  145. if rc = '' then do
  146.     say 'INSTALL: Can not find' AZinfile
  147.     signal ErrorExit
  148. end /* If */
  149.  
  150. /* Make a backup of CONFIG.SYS only if it doesn't already exist. */
  151. rc = stream(AZBackupFile, 'c', 'query exists') /* Returns NUL if doesn't exist*/
  152. if rc = '' then do
  153.     say 'COPYING' AZinfile 'TO' AZBackupFile
  154.     copy AZinfile AZBackupFile        /* Save original file */
  155. end /* If */
  156.  
  157. rc = stream(AZDriverFile, 'c', 'query exists') /* Returns NUL if doesn't exist*/
  158. if rc = '' then do
  159.     say 'INSTALL: Can not find' AZDriverFile
  160.     signal ErrorExit
  161. end /* If */
  162.  
  163. /* say 'COPYING' AZDriverFile 'TO' bootdrive || ':\OS2'  */
  164. /* copy AZDriverFile bootdrive || ':\OS2'                */
  165.  
  166.     say 'COPYING' AZDriverFile 'TO' targetdir
  167.     copy AZDriverFile targetdir
  168.  
  169. rc = stream(AZinfile, c, 'open read')
  170. if  rc <> 'READY:' then do
  171.     say 'INSTALL: Could not open ' infile
  172.     signal ErrorExit
  173. end /* If */
  174.  
  175. rc = stream(AZoutfile, c, 'open write')
  176. if  rc <> 'READY:' then do
  177.     say 'INSTALL: Could not open ' outfile
  178.     signal ErrorExit
  179. end /* If */
  180.  
  181. do until lines(AZinfile) = 0            /* Loop until no lines */
  182.                                        /* remain in file...  */
  183.     buffer = linein(AZinfile)        /* Get a line into buffer */
  184.     buffer2 = translate(buffer)        /* Convert line to upper case */
  185.  
  186.     if pos('ADI2', buffer2) <> 0        /* Are there old ADI2 statements */
  187.         then iterate            /* don't copy them to outfile */
  188.  
  189.     if pos('ADIO', buffer2) <> 0        /* Are there old 'new' ADIO statements */
  190.         then iterate            /* don't copy them to outfile */
  191.  
  192.     if pos(OldDriver, buffer2) = 0        /* Look for current driver */
  193.         then rc = lineout(AZoutfile, buffer) /* No match */
  194.         else                /* Match */
  195.  
  196.     /* Found the old driver, now see if it is already commented out */
  197.     /* If first word is REM just write the line out */
  198.         if pos('REM', strip(buffer2)) = 1
  199.         then do
  200.                    rc = lineout(AZoutfile, buffer)
  201.                    rc = lineout(AZoutfile, NewDev)
  202.               end /* do */
  203.     /* Otherwise, Add REM statement */
  204.         else do
  205.               rc = lineout(AZoutfile, 'rem ' || buffer)
  206. /* rework the new line to use the old line while replacing the IBM1S506.ADD
  207.    with the current driver name in order to preserve any command line
  208.    parameters that the user may have added    */
  209.  
  210. /*              rc = lineout(AZoutfile, NewDev)   */
  211.               /* overwrite the IBM1S506.ADD with ADI0xxx.ADD, with
  212.                  blank padding to ensure that we conpletely overwrite 
  213.                  the old driver's name   */
  214.               buffer2 = overlay( NewDriver, buffer, pos( OldDriver, buffer ),length( OldDriver ) )
  215.               rc = lineout(AZoutfile, buffer2)
  216.  
  217.          end  /* do */
  218.  
  219. end  /* Do */
  220.  
  221. /* ejc - move so we put adio right after commented out ibm1s506 */
  222. /* rc = lineout(AZoutfile, NewDev) */
  223.  
  224. rc = stream(AZinfile, c, 'close')
  225. rc = stream(AZoutfile, c, 'close')
  226.  
  227. del AZinfile
  228. ren AZoutfile ifile
  229. say 'You must Shutdown then ReBoot for the changes to take effect!'
  230. pause
  231.  
  232. ErrorExit:
  233. exit                        /* end the program */
  234.  
  235. /* Subroutines */
  236.  
  237. GetBootDrive:            /* Returns boot drive from environment */
  238. env = 'OS2ENVIRONMENT'
  239. temp = value('COMSPEC',,env)
  240. return substr(strip(temp),1,1)
  241.  
  242.