home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / pmdfinst.zip / pmdfinst.cmd
OS/2 REXX Batch file  |  1997-04-28  |  19KB  |  435 lines

  1. /**********************************************************************/
  2. /* Install PMDF support files                                         */
  3. /**********************************************************************/
  4. /**********************************************************************/
  5. /* Variable Dictionary                                                */
  6. /*                                                                    */
  7. /* BootDrive       User's boot drive                                  */
  8. /* Debug           Set to "test" to manually set kernel version       */
  9. /*                 Set to "cleanup" to only run cleanup proc          */
  10. /* ErrorFlag       Error? (yes/no)                                    */
  11. /* FileFound       File name found during file search                 */
  12. /* FileSearch      File name to search for on disk/diskette           */
  13. /* InstPath        Path where the problem det code is installed       */
  14. /* Line            Output to install log                              */
  15. /* Medium          Install code is on diskette, hard file, CD ROM?    */
  16. /* ok              "Pull" variable to allow user to continue          */
  17. /* OutFileLog      Run-time log for PMDF package install              */
  18. /* PathCheck.n     Does install path exist?                           */
  19. /* SrcDrive        Drive where the source code is located             */
  20. /* SrcPath1        Path where the PMDF source code part1 is located   */
  21. /* SrcPath2        Path where the PMDF source code part2 is located   */
  22. /*                                                                    */
  23. /**********************************************************************/
  24. /* Change Log                                                         */
  25. /*                                                                    */
  26. /* chg  date      by        description                               */
  27. /* ---  --------  --------  ----------------------------------------- */
  28. /*  00  94-09-19  Reese     Create PMDFInst based on PDPInst/PDPInst2 */
  29. /*                                                                    */
  30. /**********************************************************************/
  31.  
  32. /*trace '?r'*/
  33. ADDRESS CMD "@CLS";
  34. ADDRESS CMD "@ECHO OFF";
  35.  
  36. CALL RxFuncAdd 'SysLoadFuncs','REXXUTIL','SysLoadFuncs';
  37. CALL SysLoadFuncs;
  38.  
  39. Env  = "OS2ENVIRONMENT";
  40.  
  41. Arg Debug;
  42.  
  43. /**********************************************************************/
  44. /* Determine boot drive                                               */
  45. /**********************************************************************/
  46.  
  47. BootDrive       = SUBSTR(value('SYSTEM_INI',,Env),1,1);
  48. OutFileLog      = BootDrive || ":\OS2\Install\PMDFInst.LOG";
  49.  
  50. /*
  51. rc = SysFileDelete(OutFileLog);   /* Erase any old versions of log    */
  52. */
  53.  
  54. Line = LINEOUT(OutFileLog, "----- START OF PMDFInst -----");
  55. Line = LINEOUT(OutFileLog, " ");
  56. Line = LINEOUT(OutFileLog, Date() Time());
  57. Line = LINEOUT(OutFileLog, " ");
  58. Line = LINEOUT(OutFileLog, "This is the run-time log for the PMDF");
  59. Line = LINEOUT(OutFileLog, "v0922 install package.  It can be    ");
  60. Line = LINEOUT(OutFileLog, "deleted at any time without affecting");
  61. Line = LINEOUT(OutFileLog, "the PMDF functions.                  ");
  62.  
  63. Line = LINEOUT(OutFileLog, " ");
  64. Line = LINEOUT(OutFileLog, ">> Path/Drive values:");
  65. Line = LINEOUT(OutFileLog, "Debug               = " Debug);
  66. Line = LINEOUT(OutFileLog, "BootDrive           = " BootDrive);
  67.  
  68.  
  69. /**********************************************************************/
  70. /* Figure out if user is installing from CD-ROM or diskettes          */
  71. /**********************************************************************/
  72.  
  73. If Debug <> "DESKTOP" then do;
  74.       SrcDrive   = SUBSTR(Directory(),1,1);
  75.       FileSearch = "\OS2Image\DMPD1" || "\DF_RET.EXE"; /* assume CD-ROM */
  76. /*      FileSearch = "\OS2Image\DMPD1" || "\PMDF.EXE"; /* assume CD-ROM */ */
  77.       FileFound  = STREAM(FileSearch, "c", "query exists");
  78.       Line = LINEOUT(OutFileLog,,
  79.          "\OS2Image\DMPD1\DF_RET.EXE FileFound = " || FileFound);
  80.  
  81.       If FileFound = " " then do; /* User may be using diskettes      */
  82.          FileSearch = SrcDrive || ":\DF_RET.EXE";
  83.          FileFound  = STREAM(FileSearch, "c", "query exists");
  84.          Line = LINEOUT(OutFileLog,,
  85.             SrcDrive || ":\DF_RET.EXE FileFound = " || FileFound);
  86.  
  87.          If FileFound = " " then do; /* User not in install directory */
  88.            FileSearch = SrcDrive || ":DF_RET.EXE";
  89.            FileFound  = STREAM(FileSearch, "c", "query exists");
  90.            Line = LINEOUT(OutFileLog,,
  91.               SrcDrive || ":DF_RET.EXE FileFound = " || FileFound);
  92.            If FileFound = " " then do; /* User not in install directory */
  93.             BEEP(262, 250);       /* Alert user with a beep           */
  94.             SAY " ";
  95.             SAY "If you are installing from the command line, you must";
  96.             SAY "be in the path that contains the install code.  Please";
  97.             SAY "change directories and try again.";
  98.             EXIT;
  99.            End;
  100.            Else do;
  101.              Medium     = 2;       /* 1=diskette, 2=hardfile, 3=CD-ROM */
  102.              SrcPath1   = SrcDrive || ":";
  103.              SrcPath2   = SrcDrive || ":..\DMPD2\";
  104.            End;
  105.          End;                     /* End If FileFound = " "           */
  106.  
  107.          Else do;                 /* Source code is on diskettes      */
  108.             Medium     = 1;       /* 1=diskette, 2=hardfile, 3=CD-ROM */
  109.             SrcPath1   = SrcDrive || ":\";
  110.             SrcPath2   = SrcDrive || ":\";
  111.             /* set up for testing diskettes inserted correctly        */
  112.             FileSearch = SrcDrive || ":\KERNEL.SDF";
  113.          End;                     /* End else do (user has diskettes  */
  114.       End;                        /* End If FileFound = " "           */
  115.       Else do;                    /* Source code is on CD-ROM         */
  116.          Medium     = 3;          /* 1=diskette, 2=hardfile, 3=CD-ROM */
  117.          SrcPath1   = SrcDrive || ":\OS2Image\DMPD1";
  118.          SrcPath2   = SrcDrive || ":\OS2Image\DMPD2";
  119.       End;                        /* End else do (user has CD-ROM)    */
  120.  
  121. Line = LINEOUT(OutFileLog, " ");
  122. Line = LINEOUT(OutFileLog, ">> Path/Drive values:");
  123. Line = LINEOUT(OutFileLog, "SrcDrive            = " SrcDrive);
  124. Line = LINEOUT(OutFileLog, "SrcPath1            = " SrcPath1);
  125. Line = LINEOUT(OutFileLog, "SrcPath2            = " SrcPath2);
  126.  
  127. End;                              /* End if debug <> DESKTOP          */
  128.  
  129.  
  130. /**********************************************************************/
  131. /* Get PMDF Install path from user                                    */
  132. /**********************************************************************/
  133.  
  134. Do forever;
  135.    SAY " ";
  136.    SAY " ";
  137.    SAY "**********";
  138.    SAY " ";
  139.    If Debug <> "DESKTOP" then do;
  140.       SAY "Install path default is '"||BootDrive||":\OS2\SYSTEM\PMDF'.";
  141.       SAY " ";
  142.       SAY "Please tell me the new install drive and path (x:[\path])...";
  143.       SAY "or type 'E' to exit...";
  144.       SAY "or press Enter to set it to '" || BootDrive ||,
  145.          ":\OS2\SYSTEM\PMDF'.";
  146.    End;                           /* End If debug <> "DESKTOP"        */
  147.    Else do;
  148.       SAY "PMDF.EXE path default is '" || BootDrive || ":\OS2\SYSTEM\PMDF'.";
  149.       SAY " ";
  150.       SAY "Please tell me the install drive and path (x:[\path]) where";
  151.       SAY "  your PMDF.EXE file is located...";
  152.       SAY "or type 'E' to exit...";
  153.       SAY "or press Enter to accept '" || BootDrive || ":\OS2\SYSTEM\PMDF'.";
  154.    End;                           /* End Else do                      */
  155.    SAY " ";
  156.    Pull InstPath;
  157.    If (InstPath = "E" | InstPath = "EXIT") then do;
  158.       Line = LINEOUT(OutFileLog, "User typed EXIT at InstPath.");
  159.       Line = LINEOUT(OutFileLog, "----- END OF PMDFInst -----");
  160.       EXIT;
  161.    End;
  162.    If InstPath = " " then do;
  163.       InstPath = BootDrive || ":\OS2\SYSTEM\PMDF";
  164.       Line = LINEOUT(OutFileLog, " ");
  165.       Line = LINEOUT(OutFileLog, ">> Create PMDF directory:");
  166.       rc = SysMkDir(InstPath);
  167.       Line = LINEOUT(OutFileLog,,
  168.          "SysMkDir InstPath                 RC = " rc);
  169.       Error = 0;
  170.    End;                           /* End If InstPath = " "            */
  171.    Else do;
  172.       InstPath = STRIP(InstPath, "t", "\");
  173.       If SUBSTR(InstPath, 2, 1) <> ":" then do;
  174.          BEEP(262, 250);          /* Alert user with a beep           */
  175.          SAY " ";
  176.          SAY "ERROR:  format of install path must be x:[\path]";
  177.          Error = 1;
  178.       End;                        /* End Else do                      */
  179.       Else
  180.          If (LENGTH(InstPath)) > 2 then
  181.             If SUBSTR(InstPath, 3, 1) <> "\" then do;
  182.                BEEP(262, 250);    /* Alert user with a beep           */
  183.                SAY " ";
  184.                SAY "ERROR:  format of install path must be x:\path";
  185.                Error = 1;
  186.             End;                  /* End If LENGTH(InstPath) > 2      */
  187.             Else do;
  188.                Line = LINEOUT(OutFileLog, " ");
  189.                Line = LINEOUT(OutFileLog,,
  190.                   ">> Try to create Install directory:");
  191.                rc = SysMkDir(InstPath);
  192.                Line = LINEOUT(OutFileLog,,
  193.                   "SysMkDir InstPath                 RC = " rc);
  194.                If (POS("\", InstPath, 4)) > 0 then do;
  195.                   Call SysFileTree InstPath, 'PathCheck.', 'SD';
  196.                   If PathCheck.0 = 0 then do;
  197.                      BEEP(262, 250); /* Alert user with a beep        */
  198.                      SAY " ";
  199.                      SAY "ERROR:  cannot find specified Install",
  200.                          "directory.";
  201.                      SAY "        Please create the directory, then",
  202.                         "try again";
  203.                      Error = 1;
  204.                   End;
  205.                   Else Error = 0;
  206.                End;               /* End If POS > 0                   */
  207.                Else Error = 0;
  208.             End;                  /* End Else do                      */
  209.          Else Error = 0;
  210.    End;                           /* End Else do                      */
  211.    If Error = 0 then do;
  212.       If Debug = "DESKTOP" then do;
  213.          FileSearch = InstPath || "\PMDF.EXE";
  214.          FileFound  = STREAM(FileSearch, "c", "query exists");
  215.          Line = LINEOUT(OutFileLog, "InstPath\PMDF.EXE FileFound = " ||,
  216.             FileFound);
  217.  
  218.          If FileFound = " " then do; /* User did not give correct path*/
  219.             BEEP(262, 250);       /* Alert user with a beep           */
  220.             SAY " ";
  221.             SAY "PMDF.EXE not found in specified",
  222.                "drive\path.  Please try again.";
  223.          End;                     /* End If FileFound = " "           */
  224.          Else LEAVE;              /* Everything ok - get out          */
  225.       End;                        /* End If Debug = DESKTOP           */
  226.       Else LEAVE;                 /* Will create path                 */
  227.    End;                           /* End If Error = 0                 */
  228. End;                              /* End Do forever                   */
  229.  
  230. Line = LINEOUT(OutFileLog, " ");
  231. Line = LINEOUT(OutFileLog, ">> Path/Drive values:");
  232. Line = LINEOUT(OutFileLog, "InstPath            = " InstPath);
  233.  
  234.  
  235. /**********************************************************************/
  236. /* Begin installation                                                 */
  237. /**********************************************************************/
  238.  
  239. If debug <> "DESKTOP" then do;
  240.  
  241. SAY " ";
  242. SAY "**********";
  243. SAY " ";
  244. SAY "Installing PMDF package...";
  245. SAY " ";
  246.  
  247.  
  248. /**********************************************************************/
  249. /* Rename old PMDFVers file if user re-installs w/o de-installing     */
  250. /**********************************************************************/
  251.  
  252. Line = LINEOUT(OutFileLog, " ");
  253. Line = LINEOUT(OutFileLog, ">> Check for existing PMDFVers.LST file:");
  254.  
  255. /*-------------------------*/
  256. /* Remove old PMDFVers.Lst */
  257. /*-------------------------*/
  258. Line = LINEOUT(OutFileLog,,
  259.    "Copy InstPath\PMDFVers.Lst InstPath\PMDFVers.Old");
  260. Line = LINEOUT(OutFileLog); /* Close the file                         */
  261.  
  262. ADDRESS CMD,
  263.    "Copy" InstPath||"\PMDFVers.Lst",
  264.    InstPath||"\PMDFVers.Old",
  265.    "1>>" OutFileLog "2>>&1";
  266.  
  267. rc = SysFileDelete(InstPath || "\PMDFVers.Lst");
  268. Line = LINEOUT(OutFileLog,,
  269.    "SysFileDelete \PMDFVers.Lst         RC = " rc);
  270.  
  271.  
  272. /**********************************************************************/
  273. /* Install PMDF files                                                 */
  274. /**********************************************************************/
  275.  
  276. Line = LINEOUT(OutFileLog, " ");
  277. Line = LINEOUT(OutFileLog, ">> Install PMDF files:");
  278.  
  279. /*-------------------------*/
  280. /* Copy PMDF files         */
  281. /*-------------------------*/
  282. Line = LINEOUT(OutFileLog, " ");
  283. Line = LINEOUT(OutFileLog,,
  284.    "Copy SrcPath1* InstPath\*");
  285. Line = LINEOUT(OutFileLog);       /* Close the file                   */
  286.  
  287. ADDRESS CMD,
  288.    "Copy" SrcPath1"* " InstPath,
  289.    "1>>" OutFileLog "2>>&1";
  290.  
  291. If Medium = 1 then do forever;
  292.    BEEP(262, 250);                /* Alert user with a beep           */
  293.    SAY " ";
  294.    SAY "**********";
  295.    SAY " ";
  296.    SAY "Please insert diskette #2, then press Enter...";
  297.    SAY "or type 'E' to exit (abort installation).";
  298.    Pull ok;
  299.    If (ok = "E" | ok = "EXIT") then do;
  300.       Line = LINEOUT(OutFileLog, "User typed EXIT.");
  301.       CALL Cleanup InstPath;
  302.       Line = LINEOUT(OutFileLog, " ");
  303.       Line = LINEOUT(OutFileLog, "----- END OF PMDFInst -----");
  304.       Line = LINEOUT(OutFileLog); /* Close the file                   */
  305.       EXIT;
  306.    End;                           /* End If FileFound = EXIT          */
  307.    FileFound  = STREAM(FileSearch, "c", "query exists");
  308.    If FileFound <> "" then LEAVE;
  309. End;                              /* End Do forever                   */
  310.  
  311. SAY " ";
  312. SAY "Installing...";
  313.  
  314. Line = LINEOUT(OutFileLog, " ");
  315. Line = LINEOUT(OutFileLog,,
  316.    "Copy SrcPath2 InstPath\*");
  317. Line = LINEOUT(OutFileLog);       /* Close the file                   */
  318.  
  319. ADDRESS CMD,
  320.    "Copy" SrcPath2 InstPath,
  321.    "1>>" OutFileLog "2>>&1";
  322.  
  323. End;                              /* End if debug <> DESKTOP          */
  324.  
  325. /**********************************************************************/
  326. /* Create Problem Determination folder on the desktop                 */
  327. /**********************************************************************/
  328.  
  329. SAY " ";
  330. SAY "**********";
  331. SAY " ";
  332. SAY "Installing desktop objects...";
  333.  
  334. Line = LINEOUT(OutFileLog, " ");
  335. Line = LINEOUT(OutFileLog, ">> Create DESKTOP folders & objects:");
  336.  
  337. rc = SysCreateObject("WPFolder","Problem^Determination","<WP_DESKTOP>",,
  338.    "ICONVIEW    = NONGRID,NORMAL;"                                   ||,
  339.    "TREEVIEW    = LINES,NORMAL;"                                     ||,
  340.    "DETAILSVIEW = MINI;"                                             ||,
  341.    "ICONFONT    = 8.Helv;"                                           ||,
  342.    "TREEFONT    = 14.System;"                                        ||,
  343.    "DETAILSFONT = 8.Helv;"                                           ||,
  344.    "ICONFILE    = " || InstPath || "\Dump2.ICO;"                     ||,
  345.    "HELPPANEL   = 1277;"                                             ||,
  346.    "NOPRINT     = YES;"                                              ||,
  347.    "OBJECTID=<PDPWARP_FOLDER>",,
  348.    "r");
  349.  
  350. If rc <> 1 then do;
  351.    SAY "Folder: PROBLEM DETERMINATION could not be created/updated!";
  352.    Line = LINEOUT(OutFileLog,,
  353.           "Folder:  PROBLEM DETERMINATION could not be "             ||,
  354.           "created/updated!  RC = " rc);
  355.    CALL Cleanup InstPath;
  356.    Line = LINEOUT(OutFileLog, " ");
  357.    Line = LINEOUT(OutFileLog, "----- ABEND OF PMDFInst -----");
  358.    Line = LINEOUT(OutFileLog); /* Close the file                      */
  359.    EXIT;
  360. End;                      /* If rc <> 1                               */
  361.  
  362. Line = LINEOUT(OutFileLog,,
  363.        "Folder:  PROBLEM DETERMINATION created/updated ok.");
  364.  
  365.  
  366. /**********************************************************************/
  367. /* Create PM Dump Facility Executable                                 */
  368. /**********************************************************************/
  369.  
  370. rc = SysCreateObject("WPProgram","PM Dump Facility","<PDPWARP_FOLDER>",,
  371.    "EXENAME     = " || InstPath || "\PMDF.EXE;"                      ||,
  372.    "STARTUPDIR  = " || InstPath || ";"                               ||,
  373.    "PROGTYPE    = PM;"                                               ||,
  374.    "HELPPANEL   = 4083;"                                             ||,
  375.    "NOPRINT     = YES;"                                              ||,
  376.    "ASSOCFILTER = DUMPDATA.*,PDUMP.*,*.DMP,,;"                       ||,
  377.    "OBJECTID    = <PDPWARP_PMDF>",,
  378.    'r');
  379.  
  380. If rc <> 1 then do;
  381.    SAY "Program: PMDF could not be created/updated !";
  382.    Line = LINEOUT(OutFileLog,,
  383.           "Program: PMDF",
  384.           "could not be created/updated!");
  385. End;
  386.  
  387. Else Line = LINEOUT(OutFileLog,,
  388.             "Program: PMDF",
  389.             "created/updated ok.");
  390.  
  391.  
  392. /**********************************************************************/
  393. /*  EXIT                                                              */
  394. /**********************************************************************/
  395.  
  396. CALL Cleanup InstPath;
  397.  
  398. SAY " ";
  399. SAY "**********";
  400. SAY " ";
  401. SAY "Done...";
  402. SAY " ";
  403. SAY " ";
  404. SAY " ";
  405. SAY " ";
  406. SAY " ";
  407. SAY " ";
  408.  
  409. CALL SysSleep 2;
  410.  
  411. Line = LINEOUT(OutFileLog, " ");
  412. Line = LINEOUT(OutFileLog, "----- END OF PMDFInst -----");
  413.  
  414. EXIT;
  415.  
  416. /**********************************************************************/
  417. /*  Clean-up Procedure                                                */
  418. /**********************************************************************/
  419.  
  420. Cleanup:
  421.  
  422.    Arg InstPath;
  423.    Line = LINEOUT(OutFileLog, " ");
  424.    Line = LINEOUT(OutFileLog, ">> Start of Clean-up procedure:");
  425.  
  426.    rc = SysFileDelete(InstPath || "\PMDFInst.CMD");
  427.    Line = LINEOUT(OutFileLog,,
  428.       "SysFileDelete PMDFInst.CMD          RC = " rc);
  429.  
  430.  
  431.    Line = LINEOUT(OutFileLog, "Clean-up procedure has Executed.");
  432.  
  433. Return;
  434.  
  435.