home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1999 November / PCONLINE_11_99.ISO / filesbbs / OS2 / CDR18A24.ZIP / Cdcopy / install.cmd < prev   
Encoding:
Text File  |  1999-07-25  |  4.0 KB  |  122 lines

  1. /*********************************************************************/
  2. /*                                                                   */
  3. /* Instalation program for CDCOPY package                            */
  4. /*                                                                   */
  5. /* Author: Michel SUCH, Email: msuch@ibm.net                         */
  6. /*                                                                   */
  7. /* OS2ASPI.DMD handling added by C. Wohlgemuth                       */
  8. /*                                                                   */
  9. /*********************************************************************/
  10.  
  11.    call init_prog
  12.    call update_config
  13. exit
  14.  
  15.  
  16. init_prog:
  17.  
  18.    say "Installation program for CDCOPY Version 1.0"
  19.    say "Author: Michel SUCH. Email: msuch@ibm.net"
  20.    say ""
  21.  parse source . . progname .
  22.  x = pos( filespec('n', progname), progname) - 2
  23.  rundir = substr(progname, 1, x)
  24.  
  25.  bootdrv = translate(value('PATH', , 'os2environment'))
  26.  parse var bootdrv bootdrv':\OS2;'rest
  27.  bootdrv = substr(bootdrv, length(bootdrv))
  28. /*------------------- Init Rexxutil-----------------------------------*/
  29.  If RXFUNCQUERY('SysLoadFuncs') Then Do
  30.     Call rxfuncadd 'SysLoadFuncs', 'REXXUTIL', 'SYSLOADFUNCS'
  31.     Call sysloadfuncs
  32.  End
  33.  configsys = bootdrv':\config.sys'
  34.  configbak = bootdrv':\config.cdc'
  35. return /* init_prog */
  36.  
  37.  
  38. update_config:
  39.  
  40.    changed = 0
  41.    driverfound = 0
  42.    dmdfound = 0
  43.    i = 1
  44.    do while lines(configsys) <> 0
  45.       config.i = translate(linein(configsys))
  46.       line = strip(config.i)
  47.       select
  48.          when substr(line, 1, 8) = "SET PATH" then do
  49.             if pos( translate(rundir), line) = 0 then do
  50.                changed = 1
  51.                if substr(config.i, length(config.i)) = ';' then
  52.                   config.i = config.i || rundir';'
  53.                else
  54.                   config.i = config.i || ';' || rundir';'
  55.                say "Path variable updated."
  56.             end
  57.          end
  58.          when substr(line, 1, 7) = "DEVICE=" then do
  59.             if pos("ASPIROUT.SYS", line) <> 0 then do
  60.                if line = "DEVICE=" || translate(rundir)"\ASPIROUT.SYS" then do
  61.                   driverfound = 1
  62.                end
  63.                else do
  64.                   config.i = "device="rundir"\aspirout.sys"
  65.                   say "Line:" config.i "updated in file" configsys
  66.                   changed = 1
  67.                   driverfound = 1
  68.                end
  69.             end
  70.          end
  71.          when substr(line, 1, 8) = "BASEDEV=" then do
  72.             if pos("OS2ASPI.DMD", line) <> 0 then do
  73.                 config.i = "BASEDEV=OS2ASPI.DMD /ALL"
  74.                 say "Line:" config.i "updated in file" configsys 
  75.                 dmdfound = 1
  76.             end
  77.  
  78.          end
  79.          otherwise nop
  80.       end
  81.       i = i + 1
  82.    end
  83.    call stream configsys, 'c', 'close'
  84.    if driverfound = 0 then do
  85.       changed = 1
  86.       config.i = "device="rundir"\aspirout.sys"
  87.       config.0 = i
  88.       say "Line:" config.i "added to file" configsys
  89.    end
  90.    else config.0 = i-1
  91.    if dmdfound = 0 then do
  92.       changed = 1
  93.       i=i+1
  94.       config.i = "BASEDEV=OS2ASPI.DMD /ALL"
  95.       config.0 = i
  96.       say "Line:" config.i "added to file" configsys  
  97.    end
  98.    if changed = 1 then do
  99.       "@COPY" configsys configbak ">nul 2>nul"
  100.       if rc <> 0 then do
  101.          say "Cannot backup file" configsys','
  102.          say "program stopped."
  103.          exit
  104.       end
  105.       else say "Original file" configsys "saved as" configbak
  106.       ret = sysfiledelete(configsys)
  107.       if ret <> 0 then do
  108.          say "Cannot replace file" configsys","
  109.          say "program stopped"
  110.          exit
  111.       end
  112.       do i = 1 to config.0
  113.          call lineout configsys, config.i
  114.       end
  115.       call stream configsys, 'c', 'close'
  116.       say "Please reboot your system to finish installation."
  117.    end
  118.    else do
  119.       say "Program CDCOPY already installed, no need to reboot."
  120.    end
  121. return /* update_config */
  122.