home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / makedce1.zip / INSTALL.CMD next >
OS/2 REXX Batch file  |  1995-04-19  |  13KB  |  405 lines

  1. /* INSTALL.CMD */
  2. '@ECHO OFF'
  3.  
  4. REQSPACE = 2000000   /* Required space on installation drive 2.0 Mb */
  5. env='OS2ENVIRONMENT'
  6.  
  7.  
  8. SAY 
  9. SAY "Installing MakeDCE Version 1.0"
  10. SAY
  11.  
  12. /* Add RexxUtill functions */
  13. /***************************/
  14. Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  15. Call SysLoadFuncs
  16.  
  17. /* Verify OS/2 Version 2.0 and Higher */
  18. /***************************/
  19. Call SysOS2Ver
  20. if (RESULT < "2.0") then
  21. do
  22.      SAY "OS/2 Version 2.0 and higher is required."
  23.      exit
  24. end /* do */
  25.  
  26. /* Verify that DCE is properly installed */
  27. /******************************************/
  28. rc = checkdce()
  29. IF (rc = 0) THEN
  30. DO
  31.    SAY "ERROR: DCE is not properly installed."
  32.    SAY
  33.    SAY "EXPLANATION: MakeDCE requires a prior installation of DCE."
  34.    SAY
  35.    SAY "ACTION: Verify that during DCE installation you have set properly,"
  36.    SAY "  and added to CONFIG.SYS, the two environment variables: DCELOCAL"
  37.    SAY "  and NIDLDIR. If not, add them and reboot."
  38.    SAY
  39.    SAY "ACTION: Verify that DCE is properly installed in your system,"
  40.    SAY  "   before running MakeDCE examples"
  41.    SAY
  42.    SAY "Do you want to continue with MakeDCE installation ? (Y/N)"
  43.    PARSE PULL cont
  44.    IF (cont \= 'Y') & (cont \= 'y') then EXIT
  45. END /* do */
  46.  
  47. /* Verify that MPTN is properly installed */
  48. /*********************************************/
  49. rc = checkmptn()
  50. SAY
  51. IF (rc = 0) THEN
  52. DO
  53.    SAY "WARNING: MPTN is not properly installed."
  54.    SAY
  55.    SAY "EXPLANATION: MakeDCE examples would not work without MPTN ."
  56.    SAY "    OS/2 MPTN driver provides a socket library driver over local IPC."
  57.    SAY 
  58.    SAY "ACTION: Verify that MPTN is properly installed in your system,"
  59.    SAY  "   before running MakeDCE examples"
  60.    SAY
  61.    SAY "Do you want to continue with MakeDCE installation ? (Y/N)"
  62.    PARSE PULL cont
  63.    IF (cont \= 'Y') & (cont \= 'y') then EXIT
  64.  END /* do */
  65.  
  66.  
  67. /* Parse Command Arguments:   install -r -d <dir>   */
  68. /*******************/
  69. R_FLAG = 0
  70. D_FLAG = 0
  71. PARSE ARG OPTIONS
  72. IF (wordpos('-r' , OPTIONS, 1) \= 0 ) THEN
  73.     R_Flag = 1
  74.  
  75. IF (wordpos('-d' , OPTIONS, 1 ) \= 0 ) THEN
  76. DO 
  77.     D_Flag = 1
  78.     PARSE VAR OPTIONS '-d'Dir .
  79.     IF (Dir = '') THEN
  80.        DO
  81.            SAY "ERROR: Unspecified directory path"
  82.            SAY
  83.            SAY "EXPLANATION: command has the form:  install -d <directory path>"
  84.            SAY "EXAMPLE: install -d D:\MAKEDCE"
  85.            EXIT
  86.        END
  87. END
  88.  
  89.  
  90. /* Get the drive or directory path (when command argument is -d <dir> */
  91. /*****************/
  92.  
  93. GETDIR:
  94.  
  95. /* get Directory path if -d in arg */
  96. IF (D_FLAG = 1) THEN
  97.    DO
  98.        IF ('\' = RIGHT(Dir,1)) THEN
  99.        DO
  100.             Path = Dir
  101.             Dir = SUBSTR(Path, 1, LENGTH(Path) - 1)
  102.        END
  103.        Drive = LEFT(Dir,1)
  104.    END
  105. ELSE
  106.    DO
  107.        SAY "Please enter Home directory for MakeDCE, e.g. D:\MAKEDCE"
  108.        PARSE UPPER PULL Drive':'Path
  109.        IF (Drive = '') | (Path = '') | ('\' \= LEFT(Path,1)) THEN
  110.         DO
  111.            SAY
  112.            SAY "ERROR: Home directory specification is invalid"
  113.            SAY "EXPLANATION: You should enter Full path includeing Drive and Dir"
  114.            SAY
  115.            SIGNAL 'GETDIR'
  116.        END
  117.  
  118.        Drive = LEFT(Drive, 1)
  119.        IF ('\' = RIGHT(Path, 1)) THEN
  120.            Dir = Drive':'SUBSTR(Path, 1, LENGTH(Path) - 1)
  121.        ELSE
  122.            Dir = Drive':'Path
  123.     END
  124.  
  125. /* Verify drive free space */
  126. /***************************/
  127. Call SysDriveInfo Drive':'
  128. PARSE VAR result a Free b c
  129. IF Free < REQSPACE THEN
  130. DO
  131.   SAY "ERROR: There are only" Free "bytes free on drive" Drive'.'
  132.   SAY
  133.   SAY "EXPLANATION: MakeDCE installation requires a minimum of" REQSPACE "bytes"
  134.   SAY "    on the installation drive."
  135.   EXIT
  136. END /* do */
  137.  
  138.  
  139. /* Create the MAKEDCE directory */
  140. /*******************************/
  141. MKDIR Dir '2>>\dev\nul 1>\dev\nul'
  142. IF (rc \= 0) THEN
  143. DO
  144.     SAY Dir "already exists, Do you want to overwrite it ? (Y/N)"
  145.     PARSE PULL cont
  146.     IF (cont \= 'Y') & (cont \= 'y') then EXIT
  147. END
  148.  
  149. /* Unload MakeDCE files  */
  150. /******************************/
  151.  
  152. /* Skip copying of files if -r in arg */
  153. IF (R_FLAG = 1) THEN SIGNAL 'MAKE'
  154.  
  155. SAY "Loading MakeDCE Files into "Dir
  156. SAY
  157. srcdir = get_source_dir()
  158. SAVEFILE = srcdir'MAKEDCE.SAV'
  159. LOADRAM2 = srcdir'LOADRAM2.EXE'
  160.  
  161. call remove_READ_protection
  162. LOADRAM2 SAVEFILE Dir ' /SR /C /D /I'
  163. IF rc \= 0  THEN exit
  164.  
  165. MAKE:
  166.  
  167. /* create MakeDCE folder */
  168. SAY
  169. SAY "***************************************************************************"
  170.  
  171. /* create SETENV.CMD and set ENVIRONMENT for current WINDOW */
  172. SAY
  173. SAY "***************************************************************************"
  174. call create_makedce_folder
  175. SAY
  176.  
  177.  
  178. IF value(makedce,,env) \= Dir THEN
  179. DO
  180.    call make_setenv_cmd
  181.  
  182.    SAY 'Setting up MakeDCE environment in current Window'
  183.    call setenv
  184.    SAY
  185.    SAY "To setup MakeDCE environment permanently in the system"
  186.    SAY "Edit CONFIG.SYS according to "Dir"\SETENV.CMD, and then reboot"
  187.    SAY
  188.    SAY "To run MakeDCE examples follow the instructions in "Dir"\README"
  189. END
  190.  
  191. SAY
  192. SAY "MakeDCE installation completed."
  193. SAY "****************************************************************************"
  194. EXIT
  195.  
  196. /**********************************************************************/
  197. /* g e t e n v                                                        */
  198. /**********************************************************************/
  199. getenv: procedure
  200.   numargs = arg()
  201.   if numargs <> 1 then do
  202.     say 'ERROR: getenv: number of arguments ('numargs') should be 1.'
  203.     exit
  204.   end
  205.   val = value(arg(1),,'OS2ENVIRONMENT')
  206.   return val
  207.  
  208. /**********************************************************************/
  209. /* f i l e _ n o t _ e x i s t s     -  returns 0 if the file exists  */
  210. /**********************************************************************/
  211. file_not_exists: procedure
  212.    numargs = arg()
  213.    if numargs <> 1 then do
  214.        say 'ERROR: file_not_exists : number of arguments ('numargs') should be 1.'
  215.        exit
  216.    end
  217.    'dir ' arg(1) ' 2>> \dev\nul 1>\dev\nul'
  218.    if (rc \= 0) then
  219.       rc = 1
  220.  
  221.    return rc
  222.  
  223. /**********************************************************************/
  224. /* c h e c k d c e         -   return 1 on sucess, zero on fauilure   */
  225. /**********************************************************************/
  226. checkdce: procedure
  227.   FAILURE = 0
  228.   /* check ENV variables */
  229.   DCELOCAL = getenv('DCELOCAL')
  230.   NIDLDIR = getenv('NIDLDIR')
  231.   if (NIDLDIR = '') | (DCELOCAL = '') then
  232.       return FAILURE
  233.  
  234.   /* check RPCD.EXE, IDL.EXE, UUIDGEN.EXE */
  235.   BIN = DCELOCAL'\bin'
  236.  
  237.   IF file_not_exists( BIN'\rpcd.exe' ) THEN
  238.       return FAILURE
  239.   IF file_not_exists( BIN'\idl.exe' ) THEN
  240.       return FAILURE
  241.   IF file_not_exists( BIN'\uuidgen.exe' ) THEN
  242.       return FAILURE
  243.   IF file_not_exists( NIDLDIR'\dce\nbase.idl' ) THEN
  244.       return FAILURE
  245.  
  246.   /* check DCEOS2.LIB   */
  247.   IF file_not_exists( DCELOCAL'\lib\dceos2.lib' ) THEN
  248.       return FAILURE
  249.  
  250.   return 1
  251.  
  252. /**********************************************************************/
  253. /* c h e c m p t n        -   return 1 on sucess, 0 on failure        */
  254. /**********************************************************************/
  255. checkmptn: procedure
  256.   FAILURE = 0
  257.   /* find "protocl\mptn.sys"  in CONFIG.SYS */
  258.   Call SysFileSearch  'MPTN\PROTOCOL\MPTN.SYS', 'C:\CONFIG.SYS', 'line.'
  259.   IF line.0 = 0 THEN return FAILURE
  260.  
  261.   /* find MPTN directory */
  262.   PARSE VALUE line.1 WITH device '=' MPTNSYS junk
  263.   MPTNPROT=FILESPEC("device", MPTNSYS)FILESPEC("path", MPTNSYS)
  264.   MPTNLIB = MPTNPROT'..\lib'
  265.   IF file_not_exists( MPTNLIB'\so32dll.lib' ) THEN
  266.       return FAILURE
  267.  
  268.   return 1
  269.  
  270. /**********************************************************************/
  271. /* m a k e _ s e t e n v _ c m d        - create SETENV.CMD           */
  272. /**********************************************************************/
  273. make_setenv_cmd:
  274.   CMDFILE = Dir'\SETENV.CMD'
  275.   'del ' CMDFILE '1>\dev\nul 2>>\dev\nul'
  276.   n = LINEOUT(CMDFILE, '@echo off')
  277.   n = LINEOUT(CMDFILE, 'echo SETTING UP MAKEDCE ENVIRONMENT')
  278.   n = LINEOUT(CMDFILE, 'set MAKEDCE='Dir )
  279.   n = LINEOUT(CMDFILE, 'set PATH=%PATH%;'Dir'\BIN' )
  280.   n = LINEOUT(CMDFILE, 'set LIB=%LIB%;'Dir'\LIB' )
  281.   n = LINEOUT(CMDFILE, 'set INCLUDE=%INCLUDE%;'Dir'\INCLUDE' )
  282.   n = LINEOUT(CMDFILE, 'set BOOKSHELF=%BOOKSHELF%;'Dir'\HELP' )
  283.   n = LINEOUT(CMDFILE)
  284.   return
  285.  
  286.  
  287.  
  288. /**********************************************************************/
  289. /* g e t _ s o u r c e _ d i r                                        */
  290. /**********************************************************************/
  291. get_source_dir: procedure
  292.    PARSE SOURCE word1 word2 word3
  293.    src = FILESPEC("drive", word3)FILESPEC("path", word3)
  294.    IF (src = '') THEN
  295.    DO
  296.        SAY "Could not find source directory, exiting ...."
  297.        EXIT
  298.    END
  299.    return src
  300.  
  301.  
  302. /**********************************************************************/
  303. /* s e t e n v                                                        */
  304. /**********************************************************************/
  305. setenv:
  306.   new=Dir
  307.   x=value('makedce',new,env)
  308.   old=value('path',,env)
  309.   new=Dir'\BIN;'old
  310.   x=value('path',new,env)
  311.   old=value('lib',,env)
  312.   new=Dir'\LIB;'old
  313.   x=value('lib',new,env)
  314.   old=value('include',,env)
  315.   new=Dir'\INCLUDE;'old
  316.   x=value('include',new,env)
  317.   return 
  318.  
  319.  
  320. /**********************************************************************/
  321. /* r e m o v e _ R E A D _ p r o t e c t i o n                        */
  322. /**********************************************************************/
  323. remove_READ_protection:
  324.   'attrib -R' Dir'\README > \dev\nul'
  325.   'attrib -R' Dir'\bin\* > \dev\nul'
  326.   'attrib -R' Dir'\lib\* > \dev\nul'
  327.   'attrib -R' Dir'\help\* > \dev\nul'
  328.   'attrib -R' Dir'\include\makedce\* > \dev\nul'
  329.   'attrib -R' Dir'\examples\* > \dev\nul'
  330.   'attrib -R' Dir'\examples\binop\* > \dev\nul'
  331.   'attrib -R' Dir'\examples\alias\* > \dev\nul'
  332.   'attrib -R' Dir'\examples\array\* > \dev\nul'
  333.   'attrib -R' Dir'\examples\rcmd\* > \dev\nul'
  334.    return
  335.  
  336.  
  337. /**********************************************************************/
  338. /* c r e a t e _m a k e d c e _ f o l d e r                           */
  339. /**********************************************************************/
  340. create_makedce_folder:
  341.  
  342. SAY
  343. SAY "Installing MakeDCE Version 1.0 - Desktop Folder"
  344. SAY
  345.  
  346. MakeDCE=Dir
  347. view = SysSearchPath( "PATH", "VIEW.EXE" )
  348. ed   = SysSearchPath( "PATH", "E.EXE" )
  349.  
  350. SAY "Creating MAKEDCE Folder..."
  351. rc=SysCreateObject("WPFolder", "MakeDCE", "<WP_DESKTOP>", "OBJECTID=<MAKEDCE>","U")
  352. if \rc then rc=SysCreateObject("WPFolder", "MakeDCE", "<WP_DESKTOP>", "OBJECTID=<MAKEDCE>","R")
  353.  
  354. if \rc then do
  355.     say 'Failed to create the MakeDCE folder'
  356.     return
  357. end
  358. say 'Creating MAKEDCE Users Guide Object'
  359. rc=SysCreateObject( "WPProgram", "MakeDCE Users Guide", "<MAKEDCE>",,
  360.                "PROGTYPE=PM;EXENAME="view";PARAMETERS="MakeDCE"\HELP\MAKEDCE.INF;", "U"  )
  361. if \rc  then do
  362.     say 'Failed to create the MakeDCE Users Guide Object'
  363.     return
  364. end
  365. say 'Creating IDLGEN  Reference Object'
  366. rc=SysCreateObject( "WPProgram", "IDLGEN Reference", "<MAKEDCE>",,
  367.                "PROGTYPE=PM;EXENAME="view";PARAMETERS="MakeDCE"\HELP\IDLGEN.INF;", "R"  )
  368. if \rc then do
  369.     say 'Failed to create the IDLGEN Reference Object'
  370.     return
  371. end
  372. say 'Creating GLUEGEN Reference Object'
  373. rc=SysCreateObject( "WPProgram", "GLUEGEN Reference", "<MAKEDCE>",,
  374.                "PROGTYPE=PM;EXENAME="view";PARAMETERS="MakeDCE"\HELP\GLUEGEN.INF;", "R"  )
  375. if \rc then do
  376.     say 'Failed to create the GLUEGEN Reference Object'
  377.     return
  378. end
  379. say 'Creating PMIDLGEN Program Object'
  380. rc=SysSetIcon(MakeDCE"\bin\pmidlgen.exe",MakeDCE"\bin\PMIDLGEN.ICO") 
  381. rc=SysCreateObject( "WPProgram", "PMIDLGEN", "<MAKEDCE>",,
  382.                "PROGTYPE=PM;EXENAME="MAKEDCE"\bin\pmidlgen.exe;", "R"  )
  383. if \rc  then do
  384.     say 'Failed to create the PMIDLGEN Program Object'
  385.     return
  386. end
  387.  
  388. say 'Creating examples directory shadow'
  389. rc  = SysCreateObject( "WPShadow",'Examples', "<MAKEDCE>", "SHADOWID="MakeDCE"\Examples;", "R" )
  390. if \rc  then do
  391.     say 'Failed to create the examples directory Shadow'
  392.     return
  393. end
  394.  
  395. say 'Creating READMEE  Object'
  396. rc=SysCreateObject( "WPProgram", "README", "<MAKEDCE>",,
  397.                "PROGTYPE=PM;EXENAME="ed";PARAMETERS="MakeDCE"\README;", "U"  )
  398. if \rc  then do
  399.     say 'Failed to create the README Object'
  400.     return
  401. end
  402.  
  403. return
  404.  
  405.