home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 January / VPR9701B.ISO / k / millen / os2_j / install.cmd < prev    next >
OS/2 REXX Batch file  |  1996-08-14  |  9KB  |  299 lines

  1. /********************************************************************/
  2. /*         MGA OS/2 PM drivers installation batch file              */
  3. /********************************************************************/
  4.  
  5. '@ECHO OFF'
  6. say 'MATROX MGA Millennium/Mystique DBCS 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')-1)
  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 = 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. if stream(Srcdrv'MGAX64.DSC', 'C', 'query exists') \= "" then signal CheckDst
  108. Srcdrv=Srcdrv'\OS2\'
  109. if stream(Srcdrv'MGAX64.DSC', 'C', 'query exists') = "" then signal RESUME
  110.  
  111. CheckDst:
  112.  
  113. FileName=Dstdrv'\OS2KRNL'                       /* checking target      */
  114. 'attrib -r -s -h 'FileName
  115. if stream(FileName, 'C', 'query exists') = "" then signal RESUME
  116. 'attrib +h +s +r 'FileName
  117.  
  118. signal StartInstall
  119.  
  120. /********************/
  121. /* Ask the User     */
  122. /********************/
  123.  
  124. NotFoundSrcDrv:
  125. RESUME:
  126. cls
  127. say ''
  128. say ''
  129. say 'Source dir will be:' Srcdrv
  130. say 'Destination drive will be:' Dstdrv
  131. say 'Is the above information correct? (Y/N): Y'
  132. pull answer
  133. if answer = 'N' then signal askdrives
  134.  
  135. if stream(Srcdrv'MGAX64.DSC', 'C', 'query exists') \= "" then signal CheckDst1
  136. Srcdrv=Srcdrv'\OS2\'
  137. if stream(Srcdrv'MGAX64.DSC', 'C', 'query exists') = "" then signal usage0
  138.  
  139. CheckDst1:
  140. FileName=Dstdrv'\OS2KRNL'
  141. 'attrib -r -s -h 'FileName
  142. if stream(FileName, 'C', 'query exists') = "" then signal usage0
  143. 'attrib +h +s +r 'FileName
  144.  
  145. say 'Source Directory will be 'Srcdrv
  146. say 'Ready to install? (Y/N): Y'
  147. pull answer
  148. if answer \= 'N' then signal StartInstall
  149.  
  150. say 'INSTALLATION ABORT'
  151. signal end
  152.  
  153. StartInstall:
  154. say 'PLEASE WAIT ...'
  155.  
  156. NewDir=directory(Dstdrv'\')             /* go to root off OS/2 drive */
  157.  
  158. /********************************************/
  159. /* remove any MGA statement from CONFIG.SYS */
  160. /********************************************/
  161.  
  162. InnF=Dstdrv'\CONFIG.MGA'
  163. OutF=Dstdrv'\CONFIG.SYS'
  164. 'copy 'OutF' 'InnF' >nul'
  165. 'del 'OutF
  166.  
  167. do until lines(InnF) = 0
  168.     InStr = linein(InnF)
  169.     select
  170.         when pos('VVGA.SYS', InStr) > 0     then nop
  171.         when pos('VSVGA.SYS', InStr) > 0    then nop
  172.         when pos('MGAKRNL.SYS', InStr) > 0  then nop    /* Terminator       */
  173.         when pos('MGA=', InStr) > 0         then nop    /* Termin / Millen  */
  174.         when pos('MGARES=', InStr) > 0      then nop    /* Terminator < 2.0 */
  175.         when pos('VIO_MGA', InStr) > 0      then nop    /* Termin / Millen  */
  176.         when pos('RAMBIOS.SYS', InStr) > 0  then nop    /* Terminator < 2.0 */
  177.         when pos('VMGA.SYS', InStr) > 0     then nop    /* Terminator       */
  178.         when pos('KMGAX64.SYS', InStr) > 0  then nop    /* Millennium       */
  179.         when pos('VMGAX64.SYS', InStr) > 0  then nop    /* Millennium       */
  180.         otherwise
  181.         do
  182.             if pos('LIBPATH=', InStr) > 0   then        do
  183.                 itmp = pos(':\MGA\OS', InStr)
  184.                 if itmp > 0 then stmp=delstr(InStr, itmp-1, 11)
  185.                 else stmp=InStr
  186.                 call lineout OutF, stmp
  187.             end
  188.             else do
  189.                 itmp = pos(':\MGA\OS2', InStr)
  190.                 if itmp = 0 then  call lineout OutF, InStr
  191.                 end
  192.         end
  193.     end
  194. end
  195.  
  196. call stream OutF, 'c', 'close'
  197. call stream InnF, 'c', 'close'
  198.  
  199. /**********************************************/
  200. /* remove any MGA statement from autoexec.bat */
  201. /**********************************************/
  202.  
  203. 'call 'Srcdrv'FIXAUTO.CMD 'Dstdrv' ON'
  204.  
  205. /**********************************/
  206. /* Call OS/2 Installation process */
  207. /**********************************/
  208.  
  209. 'if exist 'Dstdrv'\OS2\svgadata.pmi del 'Dstdrv'\OS2\svgadata.pmi > nul'
  210. 'if exist 'Dstdrv'\OS2\video.cfg del 'Dstdrv'\OS2\video.cfg > nul'
  211.  
  212. NewDir=directory(Dstdrv'\OS2\INSTALL')
  213. 'if exist MGA8.DSC del MGA8.DSC > nul'
  214. 'copy   'Srcdrv'*.DSC .>nul'
  215.  
  216. /***************************************************/
  217. /* save OS2's Keyboard driver (ver > 2.11 is Warp) */
  218. /***************************************************/
  219. ver = SysOS2Ver()
  220.  
  221. if ver > '2.11' then do                             /* Warp */
  222.     option=' /S:'Srcdrv' /T:'Dstdrv
  223.     if AutoInstall = 1 then option=' /PD:'Srcdrv'MGAX64.DSC'option
  224.     if AutoInstall = 2 then option=' /PD:'Srcdrv'MGAX64J.DSC'option
  225.     end
  226. else do                                             /* not Warp */
  227.     option=''
  228.     end
  229.  
  230. /**************************************************/
  231. /* Call dspinstl to install drivers               */
  232. /**************************************************/
  233.  
  234. 'DSPINSTL.EXE'option
  235. IstRetCode = rc
  236.  
  237. /**************************************************************/
  238. /* restore CONFIG.SYS and AUTOEXEC.BAT in case abort or error */
  239. /**************************************************************/
  240. if IstRetCode \= 0 then do
  241.     NewDir=directory(Dstdrv'\')
  242.     'copy config.mga config.sys >nul'
  243.     'copy autoexec.mga autoexec.bat >nul'
  244.     'del  *.mga'
  245.     say 'INSTALLATION ABORT'
  246.     end
  247.  
  248. else do
  249.  
  250.     /**********************************************************************/
  251.     /* Delete obsolete files.                                             */
  252.     /* An old level mga.inf is identified by the existence of mgamon.exe. */
  253.     /**********************************************************************/
  254.     'if exist 'Dstdrv'\MGA\OS2\mgamon.exe  del 'Dstdrv'\MGA\OS2\mga.inf  > nul'
  255.     'if exist 'Dstdrv'\MGA\OS2\MGAMON.EXE  del 'Dstdrv'\MGA\OS2\MGAMON.EXE  > nul'
  256.     'if exist 'Dstdrv'\MGA\OS2\syslevel.mil  del 'Dstdrv'\MGA\OS2\syslevel.mil  > nul'
  257.  
  258.     /**********************************************************/
  259.     /* If the installation target drive is the one that's     */
  260.     /* currently booted, create the MGA objects.              */
  261.     /**********************************************************/
  262.     if DstRunning = 1
  263.     then 'call' Dstdrv'\mga\os2\mgaobj'
  264.     else do
  265.         say 'To complete installation, boot from 'Dstdrv' and run MGAOBJ'
  266.         say 'and then MGAHK, both from the 'Dstdrv'\MGA\OS2 directory.'
  267.         end
  268.     end
  269.  
  270. signal end
  271.  
  272. ASKDRIVES:
  273. say 'Enter source drive ('Srcdrv')'
  274. pull answer
  275. if   answer = "" then nop
  276. else Srcdrv = answer'\OS2'
  277. say 'Enter destination drive ('Dstdrv')'
  278. pull answer
  279. if   answer = "" then nop
  280. else Dstdrv = answer
  281. signal RESUME
  282.  
  283. USAGE0:
  284. say 'File' FileName ' does not exist'
  285. USAGE:
  286. say ''
  287. say 'Usage:'
  288. say '   install src: dst:'
  289. say '   Where src is the drive from which you are installing the driver'
  290. say '   and dst is your OS/2 boot drive.'
  291. say 'Example:'
  292. say '   b:install b: d:'
  293. say '   a:install'
  294. say '   e:\os2\install'
  295.  
  296. end:
  297. call directory CurDir
  298. exit
  299.