home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1998 January (DVD) / VPR980100.ISO / K / MILLEN / OS2_J / INSTALL.CMD < prev    next >
OS/2 REXX Batch file  |  1997-05-06  |  9KB  |  304 lines

  1. /********************************************************************/
  2. /*         MGA OS/2 PM drivers installation batch file              */
  3. /********************************************************************/
  4.  
  5. '@ECHO OFF'
  6. say 'Matrox Millennium/Mystique Driver'
  7.  
  8. call rxfuncadd sysloadfuncs, rexxutil, sysloadfuncs
  9. call sysloadfuncs
  10.  
  11.  
  12. CurDir = Directory()
  13. parse SOURCE cmdd
  14. cmdd = word(cmdd,3)
  15. SrcDrv = left(cmdd, length(cmdd) - length('install.cmd'))
  16. Dstdrv = 'C:'           /* default value */
  17. AutoInstall = 0         /* default value */
  18.  
  19. /********************************************************************/
  20. /* Get arguments if any                                             */
  21. /********************************************************************/
  22.  
  23. Parse Arg all
  24.  
  25. ArgCount=words(all)
  26. if ArgCount > 4 then ArgCount = 4
  27. srcset=0
  28. dstset=0
  29. If ArgCount > 0 then do i=1 to ArgCount
  30.     ntmp = translate(word(all,i))
  31.     select /* ntmp */
  32.     when ntmp ='/U'  then AutoInstall = 1
  33.     when ntmp ='/UJ' then AutoInstall = 2
  34.  
  35.     otherwise do
  36.         if srcset=0 then do
  37.         Srcdrv=ntmp
  38.         srcset=1
  39.         end
  40.         else do
  41.         Dstdrv=ntmp
  42.         dstset=1
  43.         end
  44.     end /* otherwise */
  45.     end /* select ntmp */
  46. end /* do i=1 to ArgCount */
  47.  
  48. if srcset=1 then signal FoundSrcDrv
  49.  
  50. SearchRep = 0
  51. SearchAgain:
  52. if stream(Srcdrv'MGAX64.DSC','C','query exists') \= "" then signal FoundSrcDrv
  53. Srcdrv=Srcdrv'\OS2\'
  54. if stream(Srcdrv'MGAX64.DSC','C','query exists') \= "" then signal FoundSrcDrv
  55.  
  56. SearchRep = SearchRep + 1
  57.  
  58. select
  59.    when SearchRep=1 then do
  60.         Srcdrv = CurDir
  61.         signal SearchAgain
  62.         end
  63.    when SearchRep=2 then do
  64.         DrvLetter = 'A'
  65.         Srcdrv = DrvLetter':'
  66.         signal SearchAgain
  67.         end
  68.     otherwise nop
  69. end
  70.  
  71. if DrvLetter \= 'Z' then do
  72.     DrvLetter= D2C(C2D(DrvLetter)+1)
  73.     Srcdrv = DrvLetter':'
  74.     signal SearchAgain
  75. end
  76.  
  77. Srcdrv='A:'
  78. signal NotFoundSrcDrv
  79.  
  80. FoundSrcDrv:
  81. say 'Install from 'Srcdrv
  82.  
  83. /* if dstset=1 then signal FoundDstDrv */
  84.  
  85. /********************************************************************/
  86. /* Search for OS2 system path in PATH environment                   */
  87. /********************************************************************/
  88.  
  89. Path = translate(value('PATH',,'OS2ENVIRONMENT'))
  90. if Path = '' then signal ENDSEARCH
  91.  
  92. ntmp = pos(':\OS2;', Path)
  93. if ntmp = 0 then signal ENDSEARCH
  94.  
  95. BootedDrv = substr(Path, ntmp - 1, 2)
  96. if dstset = 0 then Dstdrv = BootedDrv
  97. if BootedDrv = Dstdrv then DstRunning = 1
  98.  
  99. FoundDstDrv:
  100. say 'Install to   'Dstdrv
  101.  
  102. /*****************************************************************************/
  103. /*                 Checking the default values                               */
  104. /*****************************************************************************/
  105.  
  106.                                                /* checking source      */
  107. lastChar = right(Srcdrv, 1)
  108. if lastChar \= ":" & lastChar \= '\' then Srcdrv = Srcdrv'\'
  109. if stream(Srcdrv'MGAX64.DSC', 'C', 'query exists') \= "" then signal CheckDst
  110. Srcdrv=Srcdrv'OS2\'
  111. if stream(Srcdrv'MGAX64.DSC', 'C', 'query exists') = "" then signal RESUME
  112.  
  113. CheckDst:
  114.  
  115. FileName=Dstdrv'\OS2KRNL'                       /* checking target      */
  116. 'attrib -r -s -h 'FileName
  117. if stream(FileName, 'C', 'query exists') = "" then signal RESUME
  118. 'attrib +h +s +r 'FileName
  119.  
  120. signal StartInstall
  121.  
  122. /********************/
  123. /* Ask the User     */
  124. /********************/
  125.  
  126. NotFoundSrcDrv:
  127. RESUME:
  128. cls
  129. say ''
  130. say ''
  131. say 'Source dir will be:' Srcdrv
  132. say 'Destination drive will be:' Dstdrv
  133. say 'Is the above information correct? (Y/N): Y'
  134. pull answer
  135. if answer = 'N' then signal askdrives
  136.  
  137. if stream(Srcdrv'MGAX64.DSC', 'C', 'query exists') \= "" then signal CheckDst1
  138. FileName = Srcdrv'MGAX64.DSC'
  139. Srcdrv=Srcdrv'\OS2\'
  140. if stream(Srcdrv'MGAX64.DSC', 'C', 'query exists') = "" then signal usage0
  141.  
  142. CheckDst1:
  143. FileName=Dstdrv'\OS2KRNL'
  144. 'attrib -r -s -h 'FileName
  145. if stream(FileName, 'C', 'query exists') = "" then signal usage0
  146. 'attrib +h +s +r 'FileName
  147.  
  148. say 'Source Directory will be 'Srcdrv
  149. say 'Ready to install? (Y/N): Y'
  150. pull answer
  151. if answer \= 'N' then signal StartInstall
  152.  
  153. say 'INSTALLATION ABORT'
  154. signal end
  155.  
  156. StartInstall:
  157. say 'PLEASE WAIT ...'
  158.  
  159. NewDir=directory(Dstdrv'\')             /* go to root off OS/2 drive */
  160.  
  161. /********************************************/
  162. /* remove any MGA statement from CONFIG.SYS */
  163. /********************************************/
  164.  
  165. InnF=Dstdrv'\CONFIG.MGA'
  166. OutF=Dstdrv'\CONFIG.SYS'
  167. 'copy 'OutF' 'InnF' >nul'
  168. 'del 'OutF
  169.  
  170. do until lines(InnF) = 0
  171.     InStr = linein(InnF)
  172.     select
  173.         when pos('VVGA.SYS', InStr) > 0     then nop
  174.         when pos('VSVGA.SYS', InStr) > 0    then nop
  175.         when pos('MGAKRNL.SYS', InStr) > 0  then nop    /* Terminator       */
  176.         when pos('MGA=', InStr) > 0         then nop    /* Termin / Millen  */
  177.         when pos('MGARES=', InStr) > 0      then nop    /* Terminator < 2.0 */
  178.         when pos('VIO_MGA', InStr) > 0      then nop    /* Termin / Millen  */
  179.         when pos('RAMBIOS.SYS', InStr) > 0  then nop    /* Terminator < 2.0 */
  180.         when pos('VMGA.SYS', InStr) > 0     then nop    /* Terminator       */
  181.         when pos('KMGAX64.SYS', InStr) > 0  then nop    /* Millennium       */
  182.         when pos('VMGAX64.SYS', InStr) > 0  then nop    /* Millennium       */
  183.         otherwise
  184.         do
  185.             if pos('LIBPATH=', InStr) > 0   then        do
  186.                 itmp = pos(':\MGA\OS', InStr)
  187.                 if itmp > 0 then stmp=delstr(InStr, itmp-1, 11)
  188.                 else stmp=InStr
  189.                 call lineout OutF, stmp
  190.             end
  191.             else do
  192.                 itmp = pos(':\MGA\OS2', InStr)
  193.                 if itmp = 0 then  call lineout OutF, InStr
  194.                 end
  195.         end
  196.     end
  197. end
  198.  
  199. call stream OutF, 'c', 'close'
  200. call stream InnF, 'c', 'close'
  201.  
  202. /**********************************/
  203. /* Call OS/2 Installation process */
  204. /**********************************/
  205.  
  206. 'if exist 'Dstdrv'\OS2\svgadata.pmi del 'Dstdrv'\OS2\svgadata.pmi > nul'
  207. 'if exist 'Dstdrv'\OS2\video.cfg del 'Dstdrv'\OS2\video.cfg > nul'
  208.  
  209. NewDir=directory(Dstdrv'\OS2\INSTALL')
  210. 'if exist MGA8.DSC del MGA8.DSC > nul'
  211. 'copy   'Srcdrv'*.DSC .>nul'
  212.  
  213.  
  214. ver = SysOS2Ver()
  215. option=''
  216.  
  217. if ver > '2.11' then do                             /* Warp 3 = 2.30 */
  218.                                                     /* Merlin = 2.40 */
  219.     if AutoInstall = 1
  220.         then option=' /PD:'Srcdrv'MGAX64.DSC'
  221.     if AutoInstall = 2
  222.         then option=' /PD:'Srcdrv'MGAX64J.DSC'
  223.     if right(Srcdrv, 1) = '\'
  224.         then Srcdrv = left(Srcdrv, length(Srcdrv) - 1)
  225.     option = option' /S:'Srcdrv' /T:'Dstdrv'\'
  226. end
  227.  
  228. /**************************************************/
  229. /* Call dspinstl to install drivers               */
  230. /**************************************************/
  231.  
  232. 'DSPINSTL'option
  233. IstRetCode = rc
  234.  
  235. /**************************************************************/
  236. /* restore CONFIG.SYS and AUTOEXEC.BAT in case abort or error */
  237. /**************************************************************/
  238. if IstRetCode \= 0 then do
  239.     NewDir=directory(Dstdrv'\')
  240.     'copy config.mga config.sys >nul'
  241.     'copy autoexec.mga autoexec.bat >nul 2>nul'
  242.     'del  *.mga'
  243.     say 'INSTALLATION ABORT'
  244.     end
  245.  
  246. else do
  247.  
  248.     /**********************************************************************/
  249.     /* Save a copy of the Matrox vvga.sys in \mga\os2 to copy to          */
  250.     /* \os2\mdos in case dspinstl is used to reinstall the driver.        */
  251.     /**********************************************************************/
  252.     'copy 'Dstdrv'\os2\mdos\vvga.sys 'Dstdrv'\mga\os2 >nul'
  253.  
  254.     /**********************************************************************/
  255.     /* Delete obsolete files.                                             */
  256.     /* An old level mga.inf is identified by the existence of mgamon.exe. */
  257.     /**********************************************************************/
  258.     'if exist 'Dstdrv'\MGA\OS2\mgamon.exe    del 'Dstdrv'\MGA\OS2\mga.inf     2>nul'
  259.     'if exist 'Dstdrv'\MGA\OS2\MGAMON.EXE    del 'Dstdrv'\MGA\OS2\MGAMON.EXE   >nul'
  260.     'if exist 'Dstdrv'\MGA\OS2\syslevel.mil  del 'Dstdrv'\MGA\OS2\syslevel.mil >nul'
  261.  
  262.     /**********************************************************/
  263.     /* If the installation target drive is the one that's     */
  264.     /* currently booted, create the MGA objects.              */
  265.     /**********************************************************/
  266.     if DstRunning = 1
  267.     then 'call' Dstdrv'\mga\os2\mgaobj'
  268.     else do
  269.         say 'To complete installation, boot from 'Dstdrv' and run MGAOBJ'
  270.         say 'and then MGAHK, both from the 'Dstdrv'\MGA\OS2 directory.'
  271.         end
  272.     end
  273.  
  274. signal end
  275.  
  276. ASKDRIVES:
  277. say 'Enter source drive ('Srcdrv')'
  278. pull answer
  279. if   answer = "" then nop
  280. else Srcdrv = answer'\OS2'
  281. say 'Enter destination drive ('Dstdrv')'
  282. pull answer
  283. if   answer = "" then nop
  284. else Dstdrv = answer
  285. signal RESUME
  286.  
  287. USAGE0:
  288. say
  289. say 'File' FileName 'does not exist.'
  290. USAGE:
  291. say ''
  292. say 'Usage:'
  293. say '   install [source path [destination path]] [/u]'
  294. say
  295. say 'Examples:'
  296. say '   a:install'
  297. say '   b:install b: d:'
  298. say '   c:\temp\install c:\temp'
  299. say '   e:\os2\install'
  300.  
  301. end:
  302. call directory CurDir
  303. exit x2d('FE00')
  304.