home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / sfp09b59.zip / install.cmd < prev    next >
OS/2 REXX Batch file  |  1999-12-21  |  5KB  |  250 lines

  1. /*
  2. ** Module   :INSTALL.CMD
  3. ** Abstract :
  4. **
  5. ** Copyright (C) 1999 Link Guard Solutions Ltd.
  6. **
  7. ** Log: Tue  21/12/1999 Created
  8. **
  9. */
  10.  
  11. '@echo off'
  12.  
  13. rc=RxFuncAdd('BootDrive', 'bootdrv', 'BootDrive')
  14. rc=RxFuncAdd('SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs')
  15. call SysLoadFuncs
  16.  
  17. signal on halt name bad_inst;
  18.  
  19. if RxFuncQuery('SysTempFileName') then
  20. do
  21.     say 'Unable to load REXXUTIL.DLL. Aborting installation'
  22.     exit
  23. end
  24.  
  25. if RxFuncQuery('BootDrive') then
  26. do
  27.     say 'Unable to load BOOTDRV.DLL. Aborting installation'
  28.     exit
  29. end
  30.  
  31. lgspath=BootDrive()':\SafeFire'
  32. replace_config='N'
  33. continue='N'
  34. wps='Y'
  35.  
  36. say ''
  37. say 'SafeFire PPP Install, Copyright (C) 1999 Link Guard Solutions Ltd.'
  38. say ''
  39. say 'This program will install SafeFire PPP to your PC.'
  40.  
  41. do while continue<>'Y'
  42.     call ask_inst_dir
  43.     call ask_mk_dir
  44.     call ask_config
  45.     call ask_wps
  46.  
  47.     say ''
  48.     say '■■■ Installation directory ■■■>'lgspath
  49.     say '■■■ Update CONFIG.SYS      ■■■>'replace_config
  50.     say '■■■ Create program objects ■■■>'wps
  51.     say ''
  52.  
  53.     say 'Are these parameters correct?'
  54.     say 'Enter '"'Y'" 'followed by Enter key to begin installation.'
  55.     say 'Press Ctrl+Break to abort installation.'
  56.  
  57.     parse upper pull answer
  58.  
  59.     if answer='Y' then continue='Y'
  60. end
  61.  
  62. /* Extract files */
  63.  
  64. if fileexist(lgspath, 'D') <> 1 then
  65. do
  66.     say 'Installation directory does no exists. Aborting'
  67.     exit
  68. end
  69.  
  70. if fileexist('PACKAGE.EXE', 'F') <> 1 then
  71. do
  72.     say 'Missing software package. Aborting'
  73.     exit
  74. end
  75.  
  76. parse value lgspath with drive':'path
  77.  
  78. '@dir /f PACKAGE.EXE | rxqueue'
  79.  
  80. parse pull package
  81.  
  82. '@'drive':'
  83. 'cd "'path'"'
  84.  
  85. 'cd'
  86.  
  87. '@'package '-d -o'
  88.  
  89. if wps = 'Y' & fileexist('objects.lst', 'F') = 1 then
  90. do
  91.     call mkobjects 'objects.lst'
  92. end
  93.  
  94. /* prepare CONFIG.SYS */
  95.  
  96. /* save a copy of CONFIG.SYS */
  97.  
  98. config=BootDrive()':\CONFIG.SYS'
  99.  
  100. if fileexist(config, 'F') = 1 then
  101. do
  102.     'copy 'config '.\CONFIG.ORG'
  103.  
  104.     if fileexist('CONFIG.ORG', 'F') <> 1 then
  105.     do
  106.         say 'Unable to save a copy of CONFIG.SYS.'
  107.         say 'CONFIG.SYS will not be updated.'
  108.     end
  109.     else do
  110.         fin='CONFIG.ORG'
  111.         fout='CONFIG.SYS'
  112.         path_ready=0
  113.  
  114.         call SysFileDelete fout
  115.  
  116.         do while lines(fin) > 0
  117.  
  118.             str=linein(fin)
  119.  
  120.             if left(translate(str),7) = 'LIBPATH' then
  121.             do
  122.                 str=str';'lgspath'\bin'
  123.             end
  124.  
  125.             if left(translate(str),10) = 'SET LGSDIR' then
  126.             do
  127.                 path_ready=1
  128.                 'SET LGSDIR='lgspath
  129.             end
  130.  
  131.             call lineout fout, str
  132.         end
  133.  
  134.         if path_ready=0 then
  135.         do
  136.             call lineout fout, 'SET LGSDIR='lgspath
  137.         end
  138.  
  139.         call stream fin , 'c', 'close'
  140.         call stream fout, 'c', 'close'
  141.  
  142.         if replace_config = 'Y' then
  143.         do
  144.             'copy 'fout config
  145.  
  146.             say ''
  147.             say 'Original CONFIG.SYS is saved as 'lgspath'\CONFIG.ORG'
  148.             say ''
  149.         end
  150.     end
  151. end
  152.  
  153.  
  154. exit
  155.  
  156. /*----------------------------------------------------------------------*/
  157. /* Utility routines                                                     */
  158. /*----------------------------------------------------------------------*/
  159.  
  160. ask_inst_dir:
  161.  
  162.     say ''
  163.     say 'Please, enter directory where SafeFire PPP should be installed'
  164.     say 'or press Enter for installation to 'lgspath
  165.  
  166.     parse pull answer
  167.  
  168.     if answer<>'' then lgspath=answer
  169.  
  170. return
  171.  
  172. ask_config:
  173.  
  174.     say ''
  175.     say 'Installer will to make changes in CONFIG.SYS.'
  176.     say 'These changes are adding of LGSDIR environment variable'
  177.     say 'and adding of path where SafeFire PPP will be installed'
  178.     say 'to LIBPATH statement.'
  179.     say ''
  180.     say 'Press '"'Y'"' to allow Installer to make changes'
  181.     say 'Press '"'N'"' and changed CONFIG.SYS will be placed in 'lgspath
  182.  
  183.     pull answer
  184.  
  185.     if answer='Y' then replace_config='Y';
  186.  
  187. return
  188.  
  189. ask_wps:
  190.  
  191.     say ''
  192.     say 'Create program objects on the desktop ? [Y/N]'
  193.     say ''
  194.     pull answer
  195.  
  196.     if answer<>'Y' then wps='N' else wps ='Y';
  197.  
  198. return
  199.  
  200.  
  201. ask_mk_dir:
  202.  
  203.     if fileexist(lgspath, 'D') <> 1 then
  204.     do
  205.         say ''
  206.         say 'Directory 'lgspath' does no exists.'
  207.         say 'Create this directory ? [Y/N]'
  208.  
  209.         pull answer
  210.  
  211.         if answer='Y' then
  212.         do
  213.             rc=SysMkDir(lgspath)
  214.         end
  215.     end
  216.  
  217. return
  218.  
  219. fileexist: procedure
  220.     call SysFileTree ARG(1), stem, ARG(2)
  221. return stem.0;
  222.  
  223. bad_inst:
  224.     say 'Installation aborter. Exiting'
  225.     exit
  226. return
  227.  
  228. mkobjects:
  229.     fin=arg(1)
  230.  
  231.     do while lines(fin) > 0
  232.         str=linein(fin)
  233.  
  234.         if left(str,1)<>';' & strip(str)<>'' then
  235.         do
  236.             do while pos('%1',str) > 0
  237.                 parse value str with beg'%1'rest
  238.                 str=beg||lgspath||rest
  239.             end
  240.  
  241.             parse value str with class '|' title '|' location '|' setup '|' option
  242.  
  243.             say 'Creating' str
  244.             call SysCreateObject class, title, location, setup, option
  245.         end
  246.     end
  247.  
  248.     call stream fin, 'c', 'close'
  249. return
  250.