home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 4 Drivers / 04-Drivers.zip / s2kv201.zip / INSTALL.CMD < prev    next >
OS/2 REXX Batch file  |  2001-10-15  |  12KB  |  322 lines

  1. /*╔════════════════════════════════════════════════════════════════════════╗
  2.   ║ INSTALL.CMD - a REXX script to install sio2k and associated files      ║
  3.   ║ Author:  Ray Gwinn 09/01/01                                            ║
  4.   ╚════════════════════════════════════════════════════════════════════════╝
  5.   ╔════════════════════════════════════════════════════════════════════════╗
  6.   ║ Several routines in this script were taken from REXX Tips & Tricks by  ║
  7.   ║ Bernd Schemmer, but I cannot remember where I downloaded it from.      ║
  8.   ╚════════════════════════════════════════════════════════════════════════╝
  9.   ╔════════════════════════════════════════════════════════════════════════╗
  10.   ║ The script RGCUBE.CMD (used by this script) is a hack of CUBE.CMD      ║
  11.   ║ which I found on LEO at http://archiv.leo.org/pub/comp/os/os2/leo/rexx/║
  12.   ║ I modified CUBE.CMD so that it would not comment out a line that was   ║
  13.   ║ already a comment and renamed it to RGCUBE.CMD to avoid confusion.     ║
  14.   ║                                                                        ║
  15.   ║ The author of CUBE.CMD is not identified well, but may be Didier LAFON.║
  16.   ╚════════════════════════════════════════════════════════════════════════╝
  17.   ╔════════════════════════════════════════════════════════════════════════╗
  18.   ║ Feel free to use any part(s) of this script in your own projects.      ║
  19.   ║ However, please give credit to ALL those mentioned above for their     ║
  20.   ║ contribution(s) to your project.                                       ║
  21.   ╚════════════════════════════════════════════════════════════════════════╝*/
  22.  
  23. '@echo off'
  24.  
  25. signal on halt name UserAbort
  26.  
  27. call RxFuncAdd "SysLoadFuncs", "RexxUtil", "SysLoadFuncs"
  28. call SysLoadFuncs
  29.  
  30. say ""
  31.  
  32. debug = 0
  33.  
  34. InstallOkay()
  35. CopyFiles()
  36. call FixConfigSys
  37. say "    Installation Done"
  38.  
  39. exit
  40.  
  41. /*╔═══════════════════════════════════════════════════════════════════════╗
  42.   ║ Routine to create a list of files to copy to the sio2k directory      ║
  43.   ╚═══════════════════════════════════════════════════════════════════════╝*/
  44. Manifest: procedure
  45.  
  46.     files = ''
  47.     files = files || 'logger.exe '
  48.     files = files || 'modes.exe '
  49.     files = files || 'pci.exe '
  50.     files = files || 'vmodem.exe '
  51.     files = files || 'pmlm.exe '
  52.     files = files || 'viewpmlm.exe '
  53.     files = files || 'help.me '
  54.     files = files || 'read.me '
  55.     files = files || 'esp.sys '
  56.     files = files || 'sio2k.sys '
  57.     files = files || 'uart.sys '
  58.     files = files || 'vmodem.sys '
  59.     files = files || 'vsio2k.sys '
  60.     files = files || 'vx00.sys '
  61.     files = files || 'sample.cfg '
  62.     files = files || 'vmodem.ico '
  63.     files = files || 'pci.inc '
  64.     files = files || 'design.txt '
  65.     files = files || 'faq.txt '
  66.     files = files || 'history.txt '
  67.     files = files || 'install.txt '
  68.     files = files || 'logger.txt '
  69.     files = files || 'modes.txt '
  70.     files = files || 'pmlm.txt '
  71.     files = files || 'techtalk.txt '
  72.     files = files || 'vmodem.txt '
  73.  
  74.     return files
  75.  
  76. /*╔═══════════════════════════════════════════════════════════════════════╗
  77.   ║ Routine to build a list of files required to do an install            ║
  78.   ╚═══════════════════════════════════════════════════════════════════════╝*/
  79. RequiredFiles: procedure
  80.  
  81.     files = ''
  82.     files = files || 'rgcube.cmd '
  83.     files = files || 'sio2k.sys '
  84.     files = files || 'uart.sys '
  85.     files = files || 'vsio2k.sys '
  86.     files = files || 'modes.exe '
  87.     files = files || 'pci.inc '
  88.  
  89.     return files
  90.  
  91. /*╔═══════════════════════════════════════════════════════════════════════╗
  92.   ║ Routine to insure we can do an install                                ║
  93.   ╚═══════════════════════════════════════════════════════════════════════╝*/
  94. InstallOkay: procedure
  95.  
  96.     files = RequiredFiles()
  97.  
  98.     missing = (files = '')
  99.     if files \= '' then do until files = ''
  100.         parse var files file files
  101.  
  102.         if FileExist(file) = 0 then do
  103.             say "    The file " || file || " is missing"
  104.             missing = 1
  105.         end
  106.     end
  107.  
  108.     if missing then do
  109.         say ''
  110.         say '    Note: You MUST change to the disk and directory containing the'
  111.         say '    sio2k distribution files and execute Install.cmd from there.'
  112.         say ''
  113.         say '    Installation was NOT completed'
  114.  
  115.         exit
  116.     end
  117.  
  118.     return ''
  119.  
  120. /*╔═══════════════════════════════════════════════════════════════════════╗
  121.   ║Simple procedure to concatenate strings togather to form a comment     ║
  122.   ║command line for RgCUBE.CMD and to execute the command                 ║
  123.   ╚═══════════════════════════════════════════════════════════════════════╝*/
  124. CommentCommand: procedure
  125.  parse arg string,FileName
  126.  
  127.     command = 'call RgCUBE {commentline "' || string || '" with'
  128.     command = command || '"rem" (*ID} ' || FileName
  129.     command = command || '>nul'
  130.     command
  131.  
  132.     return ''
  133.  
  134. /*╔═══════════════════════════════════════════════════════════════════════╗
  135.   ║Simple procedure to concatenate strings togather to form an ADDLINE    ║
  136.   ║command line for RgCUBE.CMD and to execute the command                 ║
  137.   ╚═══════════════════════════════════════════════════════════════════════╝*/
  138. AddLineCommand: procedure
  139.  parse arg line,driver,FileName
  140.  
  141.     command = 'call RgCUBE {AddLine "' || line || '" (*ID IFNOT "\sio2k\'
  142.     command = command || driver || '"} '
  143.     command = command || FileName || '>nul'
  144.  
  145.     command
  146.     return ''
  147.  
  148. /*╔═══════════════════════════════════════════════════════════════════════╗
  149.   ║Fix up config.sys to use sio2k                                         ║
  150.   ╚═══════════════════════════════════════════════════════════════════════╝*/
  151. FixConfigSys: procedure expose debug bootdrive
  152.  
  153.     if (debug) then BootDrive = '';
  154.  
  155.     say "    Commenting out com.sys and sio.sys if they exist in config.sys"
  156.  
  157.     ConfigName = bootdrive || '\config.sys'
  158.     BackupName = bootdrive || '\config.s2k'
  159.  
  160.     SaveCommand = 'copy ' || ConfigName || ' ' || BackupName || ' /v >nul'
  161.     SaveCommand
  162.  
  163.     CommentCommand('COM.SYS',ConfigName)
  164.     CommentCommand('VCOM.SYS',ConfigName)
  165.     CommentCommand('SIO.SYS',ConfigName)
  166.     CommentCommand('VSIO.SYS',ConfigName)
  167.  
  168.     say "    Adding commands to config.sys to load the sio2k drivers"
  169.  
  170.     line = 'rem device=' || bootdrive || '\sio2k\esp.sys logfile='
  171.     line = line || bootdrive || '\sio2k\sio2k.log NoPause'
  172.     AddLineCommand(line, 'esp.sys',ConfigName)
  173.  
  174.     line = 'rem device=' || bootdrive || '\sio2k\vmodem.sys logfile='
  175.     line = line || bootdrive || '\sio2k\sio2k.log NoPause nPorts=2'
  176.     AddLineCommand(line, 'vmodem.sys',ConfigName)
  177.  
  178.     line = 'device=' || bootdrive || '\sio2k\uart.sys logfile='
  179.     line = line || bootdrive || '\sio2k\sio2k.log'
  180.     AddLineCommand(line, 'uart.sys',ConfigName)
  181.  
  182.     line = 'device=' || bootdrive || '\sio2k\sio2k.sys logfile='
  183.     line = line || bootdrive || '\sio2k\sio2k.log'
  184.     AddLineCommand(line, 'sio2k.sys',ConfigName)
  185.  
  186.     line = 'device=' || bootdrive || '\sio2k\vsio2k.sys logfile='
  187.     line = line || bootdrive || '\sio2k\vsio2k.log vIrqList(3,4)'
  188.     AddLineCommand(line, 'vsio2k.sys',ConfigName)
  189.  
  190.     line = 'rem device=' || bootdrive || '\sio2k\vx00.sys'
  191.     AddLineCommand(line, 'vx00.sys',ConfigName)
  192.  
  193.     return ''
  194.  
  195. /*╔═══════════════════════════════════════════════════════════════════════╗
  196.   ║Copy the distribution files to the sio2k home directory                ║
  197.   ╚═══════════════════════════════════════════════════════════════════════╝*/
  198. CopyFiles: procedure expose debug bootdrive
  199.  
  200.     Destination = GetBootDrive() || '\sio2k'
  201.  
  202.     if DirExist( Destination ) = "" then do
  203.         say "    Creating directory " || Destination
  204.         'md ' || Destination || '>nul'
  205.     end
  206.  
  207.     say "    Copying files to " || Destination
  208.  
  209.     files = Manifest()
  210.     if files \= '' then do until files = ''
  211.         parse var files file files
  212.  
  213.         if FileExist(file) \= 0 then 'copy' file Destination '/v > nul'
  214.     end
  215. return ''
  216.  
  217. /*╔═══════════════════════════════════════════════════════════════════════╗
  218.   ║ Routine to get the boot (installiation) drive                         ║
  219.   ╚═══════════════════════════════════════════════════════════════════════╝*/
  220. GetBootDrive: procedure expose BootDrive debug
  221.  
  222.     /* install a local error handler */
  223.     signal on syntax name BootDriveNotFound
  224.     BootDrive = SysBootDrive()
  225.  
  226. BootDriveNotFound:
  227.   if symbol( 'BootDrive' ) <> 'VAR' then do
  228.         BootDrive = SysSearchPath('PATH', 'OS2.INI')
  229.         if BootDrive = '' then
  230.             BootDrive = substr( value('RUNWORKPLACE',,'OS2ENVIRONMENT'),1,2)
  231.  
  232.         if BootDrive = '' then
  233.             BootDrive = substr( value( 'COMSPEC' ,, 'OS2ENVIRONMENT' ), 1,2 )
  234.  
  235.         if BootDrive = '' then
  236.           BootDrive = 'C'
  237.     end
  238.  
  239.     BootLetter = left(BootDrive, 1)
  240.     BootDrive = BootLetter || ':'
  241.     if (debug) then BootDrive = '.';
  242.  
  243.     return BootDrive
  244.  
  245. /*╔═══════════════════════════════════════════════════════════════════════╗
  246.   ║ Get typed input from the user                                         ║
  247.   ║                                                                       ║
  248.   ╚═══════════════════════════════════════════════════════════════════════╝*/
  249. Input: procedure
  250.     parse arg prompt
  251.  
  252.     call CharOut, "1b"x || "[7l"
  253.     call charOut, prompt || " "
  254.     result = lineIn()
  255.     call CharOut, "1b"x || "[7h"
  256.  
  257.     return result
  258.  
  259.  
  260.  
  261. /*╔═══════════════════════════════════════════════════════════════════════╗
  262.   ║ Taken from the install.cmd script of REXX tips and tricks             ║
  263.   ║                                                                       ║
  264.   ║ Error handler (called if the DLL REXXUTIL is not found)               ║
  265.   ╚═══════════════════════════════════════════════════════════════════════╝*/
  266. RexxUtilNotFound:
  267.     say ''
  268.     say 'Error: REXXUTIL.DLL not found!'
  269. exit 255
  270.  
  271. /*╔═══════════════════════════════════════════════════════════════════════╗
  272.   ║ Taken from the install.cmd script of REXX tips and tricks             ║
  273.   ║                                                                       ║
  274.   ║ Error handler (called if the user presses CTRL-BREAK)                 ║
  275.   ╚═══════════════════════════════════════════════════════════════════════╝*/
  276. UserAbort:
  277.     say ''
  278.     say ' Installation aborted by the user.'
  279. exit 254
  280.  
  281. /*╔═══════════════════════════════════════════════════════════════════════╗
  282.   ║ function: Check if a directory exists                                 ║
  283.   ║                                                                       ║
  284.   ║ call:     DirExist( testDir )                                         ║
  285.   ║                                                                       ║
  286.   ║ where:    testDir - name of the directory to test                     ║
  287.   ║                                                                       ║
  288.   ║ returns:  full name of the directory or "" if the directory           ║
  289.   ║           don't exist                                                 ║
  290.   ╚═══════════════════════════════════════════════════════════════════════╝*/
  291. DirExist: PROCEDURE
  292.     parse arg testDir .
  293.  
  294.     thisRC = ""
  295.     testDir = strip( testDir )
  296.     if testDir = "" then signal DirDoesNotExist
  297.  
  298.     if right( testDir, 1 ) = '\' then testDir = dbrright( testDir,1 )
  299.     testDir = testDir || '\.'
  300.  
  301.     SIGNAL ON NOTREADY NAME DirDoesNotExist
  302.  
  303.     call stream testDir || "\*", "D"
  304.     curDir = directory()
  305.     curDir1 = directory( fileSpec( "drive", testDir ) )
  306.     thisRC = directory( testDir )
  307.     call directory curDir1
  308.     call directory curDir
  309.  
  310.     DirDoesNotExist:
  311.     return thisRC
  312.  
  313. /*╔═══════════════════════════════════════════════════════════════════════╗
  314.   ║ Returns true if the passed file exists, otherwise false is returned   ║
  315.   ╚═══════════════════════════════════════════════════════════════════════╝*/
  316. FileExist: procedure
  317.     parse arg fileName
  318.  
  319.     if stream( fileName, "c", "QUERY EXISTS" ) <> "" then return 1
  320.     return 0
  321.  
  322.