home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / mb3jr12.zip / install.cmd < prev    next >
OS/2 REXX Batch file  |  1998-03-31  |  8KB  |  289 lines

  1. /*********************************************************************/
  2. /* Installation script for eM Bee 3: Junior!                                */
  3. /*  (c) 1998 Jan-Helge Bergesen                                                    */
  4. /*********************************************************************/
  5.  
  6. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  7.  
  8. call SysLoadFuncs
  9.  
  10. /*
  11.     Initiate some global vars.
  12. */
  13. GLOBVAR='Testvar'
  14.  
  15. SAY ''
  16. call SysCls
  17. SAY 'Welcome to the installation of eM Bee 3: Junior!                               '
  18. SAY '-------------------------------------------------------------------------------'
  19. SAY ' This script will perform the following tasks:'
  20. SAY '   * Copy the files to a specified location (optional)'
  21. SAY '   * Create a folder on the desktop for Junior!'
  22. SAY '   * Create program objects'
  23. SAY '   * Create a shadow of Junior!''s program object in your startup folder'
  24. SAY ' '
  25. SAY ' Do you wish to continue?( Y/N )'
  26.  
  27. PULL ans
  28.  
  29. if ans='Y' then
  30.     do
  31.         call FileCopy
  32.       call CreateFolder
  33.         Val='OBJECTID=<WP_MB3JRPRG>;EXENAME='f.1
  34.         /** Working DIR ?? */
  35.         IF SysCreateObject( 'WPProgram', 'eM Bee 3: Junior!', '<WP_MB3JR>', Val ) THEN
  36.             DO
  37.                 Val='EXENAME=VIEw.EXE;PARAMETERS='f.2
  38.                 IF SysCreateObject( 'WPProgram', 'eM Bee 3: Help!', '<WP_MB3JR>', Val ) THEN
  39.                     DO
  40.                         Val=f.3
  41.                         IF SysCreateShadow( Val, '<WP_MB3JR>' ) THEN
  42.                             DO
  43.                                 Val=f.4
  44.                                 IF SysCreateShadow( Val, '<WP_MB3JR>' ) THEN
  45.                                     IF f.5\='' THEN
  46.                                     DO
  47.                                         Val=f.5
  48.                               RC = SysCreateShadow( Val, '<WP_MB3JR>' )
  49.                                     END
  50.                             END
  51.                         ELSE
  52.                             SAY 'Failed when creating objects'
  53.                     END
  54.                 ELSE
  55.                     SAY 'Failed when creating objects'
  56.             END
  57.         ELSE
  58.             SAY 'Failed when creating objects'
  59.         
  60.         SAY 'Would you like a shadow of the program object in you startup folder? ( Y/N )'
  61.         PULL ans
  62.         IF ans = 'Y' THEN
  63.             IF SysCreateShadow( '<WP_MB3JRPRG>', '<WP_START>' ) THEN
  64.                 SAY 'Startup folder updated!'
  65.             ELSE
  66.                 SAY 'Startup folder NOT updated!'
  67.     end
  68. else
  69.     do
  70.         SAY ' '
  71.         SAY 'Oh, well... another time then maybe??'
  72.     end
  73.  
  74. /***** clean up our mess **********************************************/
  75. call SysDropFuncs
  76. EXIT
  77.  
  78.  
  79. /**********************************/
  80. /* File copy routine                  */
  81. /**********************************/
  82. FileCopy: procedure expose f.
  83. EXE_NAME = 'MB3Jr.EXE'
  84. EXE_LOC = 'C:\os2\apps'
  85. DLL_NAME = 'MB3DLL.DLL'
  86. DLL_LOC = EXE_LOC
  87. INF_NAME = 'MB3Jr.INF'
  88. INF_LOC = DLL_LOC
  89. SRC_NAME = 'Src.ZIP'
  90.  
  91.         call SysCls
  92.         SAY 'File copying                                                                   '
  93.         SAY '-------------------------------------------------------------------------------'
  94.         SAY ''
  95.         SAY 'Should the files be copied somewhere else?( Y/N )'
  96.         SAY '[ N = this is the right directory ]'
  97.         PULL Should
  98.         if Should = 'Y' then
  99.             do
  100.                 SAY ' '
  101.                 SAY 'Where would you like the program itself ('EXE_NAME') to be located?'
  102.                 SAY 'Default: 'EXE_LOC''
  103.                 SAY 'Change this? ( Y/N )'
  104.                 PULL Should
  105.                 IF Should='Y' then
  106.                 DO
  107.                     Should = 'G'
  108.                     DO WHILE Should \= 'Y'
  109.                         SAY 'Enter new location:'
  110.                         PARSE PULL EXE_LOC
  111.                         DLL_LOC = EXE_LOC
  112.                         INF_LOC = EXE_LOC
  113.                         SAY ' '
  114.                         SAY ' 'EXE_NAME'-> ' EXE_LOC
  115.                         SAY 'This correct?( Y/N )'
  116.                         PULL Should
  117.                     end
  118.                 END
  119.                 SAY ' '
  120.                 SAY 'Would you like the hook DLL ('DLL_NAME') to be placed in a separate directory?'
  121.                 SAY '(this must be listed in your LIBPATH in config.sys)'
  122.                 SAY 'Default: 'DLL_LOC''
  123.                 SAY 'Change this? ( Y/N )'
  124.                 PULL Should
  125.                 IF Should = 'Y' THEN
  126.                 DO
  127.                     Should='g'
  128.                     DO WHILE Should \= 'Y'
  129.                         SAY 'Enter new location:'
  130.                         PARSE PULL DLL_LOC
  131.                         SAY ' '
  132.                         SAY ' ' DLL_NAME ' -> ' DLL_LOC
  133.                         SAY 'This correct?( Y/N )'
  134.                         PULL Should
  135.                     end
  136.                 END
  137.                 SAY ' '
  138.                 SAY 'Would you like the help ('INF_NAME') to be placed in a separate directory?'
  139.                 SAY '(this must be listed in your BOOKSHELF in config.sys)'
  140.                 SAY 'Default: 'INF_LOC''
  141.                 SAY 'Change this? ( Y/N )'
  142.                 PULL Should
  143.                 IF Should = 'Y' THEN
  144.                 DO
  145.                     Should='g'
  146.                     DO WHILE Should \= 'Y'
  147.                         SAY 'Enter new location:'
  148.                         PARSE PULL INF_LOC
  149.                         SAY ' '
  150.                         SAY ' ' INF_NAME ' -> ' INF_LOC
  151.                         SAY 'This correct?( Y/N )'
  152.                         PULL Should
  153.                     end
  154.                 END
  155.                 call SysCls
  156.                 SAY "Performing copy                                                                "
  157.                 SAY '-------------------------------------------------------------------------------'
  158.                 call TestAllFilesPresent
  159.                 SAY 'All files in distribution accounted for!'
  160.                 call TestCreate( EXE_LOC )
  161.                 SAY 'Copy: 'EXE_NAME' to 'EXE_LOC
  162.                 ADDRESS CMD '@copy 'EXE_NAME' 'EXE_LOC
  163.                 IF DLL_LOC \= EXE_LOC THEN
  164.                     DO
  165.                         call TestCreate( DLL_LOC )
  166.                     END
  167.                 SAY 'Copy: 'DLL_NAME' to 'DLL_LOC
  168.                 ADDRESS CMD '@copy 'DLL_NAME' 'DLL_LOC
  169.                 IF INF_LOC \= EXE_LOC THEN
  170.                     DO
  171.                         call TestCreate( INF_LOC )
  172.                     END
  173.                 SAY 'Copy: 'INF_NAME' to 'INF_LOC
  174.                 ADDRESS CMD '@copy 'INF_NAME' 'INF_LOC
  175.                 SAY 'Copy: 'LICENCE.TXT' to 'EXE_LOC
  176.                 ADDRESS CMD '@COPY LICENCE.TXT 'EXE_LOC
  177.                 SAY 'Copy: 'READ.ME' to 'EXE_LOC
  178.                 ADDRESS CMD '@COPY READ.ME 'EXE_LOC
  179.                 SAY ' '
  180.                 SAY 'Should the source-code be unzipped?( Y/N ) ( req. unzip ) '
  181.                 PULL Should
  182.                 IF Should = 'Y' THEN
  183.                     DO
  184.                         SAY 'Where to?'
  185.                         PARSE PULL UzHere
  186.                         ADDRESS 'unzip src.zip -d 'UzHere
  187.                     END
  188.                 ELSE
  189.                     DO
  190.                         UzHere='NO_GO'
  191.                         SAY 'Copy the source code archive be copied somewhere?(Y/N)'
  192.                         PULL a
  193.                         IF a='Y' THEN
  194.                             DO
  195.                                 CpyHere = EXE_LOC
  196.                                 SAY 'Copy to 'CpyHere'? (Y/N)'
  197.                                 PULL a
  198.                                 IF a \= 'Y' THEN
  199.                                     PARSE PULL CpyHere
  200.                                 
  201.                                 ADDRESS CMD '@copy src.zip 'CpyHere
  202.                             END
  203.                         ELSE
  204.                             CpyHere='NO_GO'
  205.                     END
  206.                     f.1=EXE_LOC'\'EXE_NAME
  207.                     f.2=INF_LOC'\'INF_NAME
  208.                     f.3=EXE_LOC'\LICENCE.TXT'
  209.                     f.4=EXE_LOC'\Read.Me'
  210.                     IF UzHere\='NO_GO' THEN
  211.                         DO
  212.                             f.5=UzHere
  213.                             f.6='unzipped'
  214.                         END
  215.                     ELSE
  216.                         DO
  217.                             f.5=CpyHere'\Src.Zip'
  218.                             f.6='Copied'
  219.                         END
  220.                 return
  221.             end
  222.         else
  223.         do
  224.             TMP=DIRECTORY()
  225.             f.1=TMP'\'EXE_NAME
  226.             f.2=TMP'\'INF_NAME
  227.             f.3=TMP'\'LICENCE.TXT
  228.             f.4=TMP'\'Read.Me
  229.             f.5=TMP'\'src.zip
  230.             f.6='Copied'
  231.         end
  232.             return
  233.  
  234. TestCreate: procedure
  235.     arg DIR_TO_CREATE
  236.         RC = SysFileTree( DIR_TO_CREATE, EXEL, 'D' )
  237.         IF EXEL.0 = 0 THEN
  238.         DO
  239.             SAY ''DIR_TO_CREATE' doesn''t seem to exist!'
  240.             SAY 'Create 'DIR_TO_CREATE'?( Y/N)'
  241.             PULL Should
  242.             IF Should='Y' THEN
  243.                 DO
  244.                     RC=SysMkDir(DIR_TO_CREATE )
  245.                     IF RC \= 0 THEN
  246.                     DO
  247.                         SAY 'Failed to create dir..bailing out'
  248.                         Exit 2
  249.                     END
  250.                END
  251.             ELSE
  252.                 DO
  253.                     SAY 'Cannot continue..bailing out'
  254.                     Exit 2
  255.                 END
  256.         END        
  257.     return
  258.  
  259. TestAllFilesPresent: procedure
  260.     Files.1='MB3Jr.EXE'
  261.     Files.2='MB3DLL.DLL'
  262.     Files.3='MB3Jr.INF'
  263.     Files.4='LICENCE.TXT'
  264.     Files.5='SRC.zip'
  265.     Files.6='Read.Me'
  266.     
  267.     DO I=1 to 6
  268.         RC = SysFileTree( Files.I , Found , 'F' )
  269.         IF Found.0 = 0 THEN
  270.         DO
  271.             SAY 'The file 'Files.I' couldn''t be found!'
  272.             SAY 'Please obtain a proper copy of eM Bee 3:Junior!'
  273.             Exit
  274.         END
  275.     END
  276.     return
  277.  
  278. CreateFolder: procedure
  279.         IF SysCreateObject( 'WPFolder', 'eM Bee 3: Junior!', '<WP_DESKTOP>', 'OBJECTID=<WP_MB3JR>', 'replace' ) THEN
  280.             SAY 'Folder created successfully'
  281.         ELSE
  282.             DO
  283.                 SAY 'Couldn''t create folder...bailing out'
  284.                 Exit 3
  285.             END
  286.     return
  287.             
  288.  
  289.