home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cidsam.zip / SAMPINST.CMD < prev    next >
OS/2 REXX Batch file  |  1993-06-07  |  29KB  |  734 lines

  1. /***************************************************************************/
  2. /* product XXXXX Installation                                              */
  3. /*                                                                         */
  4.               /*******************************************/
  5.               /*  This command file is an example of a   */
  6.               /*  complete CID installation.             */
  7.               /*  It is based on production code, but    */
  8.               /*  is provided only as an example.        */
  9.               /*  Some external routines called by this  */
  10.               /*  sample are *not* provided.             */
  11.               /*******************************************/
  12.  
  13. /* Install product AAAAA if version installed is < 1.00                    */
  14. /* Install product BBBBB if the version installed is < 2.00                */
  15. /* Install product XXXXX if the version installed is < 1.00                */
  16. /*                                                                         */
  17. /* Note: program getbootd must be in the same directory as this cmd file   */
  18. /*                                                                         */
  19. /***************************************************************************/
  20. /* Change History                                                          */
  21. /*                                                                         */
  22. /* Mark Doc       When    Who     Why                                      */
  23. /***************************************************************************/
  24. /* This command file accepts a set of input parameters that are fairly     */
  25. /* common among CID-enabled install programs.  All of the IBM OS/2 cid-    */
  26. /* enabled programs use them, for example.                                 */
  27. /*                                                                         */
  28. /*    /R:<path>respfile    gives the name of the response file.  This is a */
  29. /*                         required parameter.                             */
  30. /*                                                                         */
  31. /*    /S:<path>            names the directory where the source files (the */
  32. /*                         files from which the install is done) reside.   *
  33. /*                         This is typically a network drive.  If not      */
  34. /*                         specified, the path defaults to the directory   */
  35. /*                         from which this program was loaded.             */
  36. /*                                                                         */
  37. /*    /G:<path>            names another directory where other needed      */
  38. /*                         might be located (imbedded response files,      */
  39. /*                         for example).                                   */
  40. /*                                                                         */
  41. /*    /L1:<path>file       names a file where history and log information  */
  42. /*                         will be placed.                                 */
  43. /***************************************************************************/
  44.  
  45. arg inparms
  46.                                      /* If NVDM/2 invoked us, and this is not */
  47.                                      /* the first invocation, we must be done */
  48.  
  49.                 /******************************************/
  50.                 /* The environment variable               */
  51.                 /*    REMOTE_INSTALL_NEXT_STATE           */
  52.                 /* is specified by LAN CID Utility.  See  */
  53.                 /* the LCU guide for information on this  */
  54.                 /* variable.                              */
  55.                 /******************************************/
  56. state = VALUE('REMOTE_INSTALL_NEXT_STATE',,'OS2ENVIRONMENT')
  57. IF state <> "" THEN
  58.   IF state <> 0 THEN
  59.     DO
  60.       CALL ENDLOCAL
  61.       EXIT 0
  62.     END
  63.  
  64. /****************************  Start  *************************************/
  65.  
  66.                 /******************************************/
  67.                 /* Most of the things in the main routine */
  68.                 /* of this command file have to be done.  */
  69.                 /* The way you do them may vary.          */
  70.                 /* Basically, the main line of this       */
  71.                 /* program                                */
  72.                 /*    Parses the command line             */
  73.                 /*    Reads the response file             */
  74.                 /*    Unpacks the programs needed to do   */
  75.                 /*       the install.                     */
  76.                 /*    Checks to make sure there is enough */
  77.                 /*       space to do the install.         */
  78.                 /*    Installs the product(s).            */
  79.                 /*    Does something to handle files that */
  80.                 /*       could not be replaced because    */
  81.                 /*       they were in use.                */
  82.                 /*                                        */
  83.                 /* The return codes used are those        */
  84.                 /* required by LAN CID Utility (LCU) and  */
  85.                 /* Netview DM/2.                          */
  86.                 /******************************************/
  87. CALL SETLOCAL
  88.                                            /* Set the default source path.    */
  89. srcpath = GetLoadDir()                     /* srcpath may be overridden later */
  90. BootDrive = GetBootDrive()                 /* What drive were we booted from? */
  91. WkDir = BootDrive"\OS2\INSTALL\ESAWKDIR"   /* Create a working directory.     */
  92. ADDRESS CMD "@MkDir" WkDir ">NUL 2>&1"
  93.                                          /* create log and history file names */
  94. hist = WkDir"\dcfinst.hst"
  95. logf = WkDir"\dcfinst.log"
  96. ADDRESS CMD "@ERASE" hist ">NUL 2>&1"
  97. ADDRESS CMD "@ERASE" logf ">NUL 2>&1"
  98.                 /******************************************/
  99.                 /* Set up the environment for the error   */
  100.                 /* logging routine from hlrfio.  (See     */
  101.                 /* cidlog.c)                              */
  102.                 /******************************************/
  103. CALL VALUE "LOG_FILE",logf,"OS2ENVIRONMENT"
  104. CALL VALUE "LOG_MESSAGE_FILE","XXXXX.msg","OS2ENVIRONMENT"
  105. histout = ">>"hist" 2>>&1"
  106.  
  107. irc = 0
  108.                                   /* Check command line and do initialization */
  109. IF ParseParms(inparms) THEN
  110.   DO
  111.                                /* Locate the message file so we can log stuff */
  112.                                                   /* Parse the response file  */
  113.      IF (ParseRespFile(respfile)) THEN
  114.                                          /* Make sure there's at least enough */
  115.                                                       /*  space for our files */
  116.        IF EnoughRoomForInstFiles(BootDrive, TargetDrive) THEN
  117.          DO
  118.                                            /* Read the installation directory */
  119.            IF (readlist(loadpath"\XXXXX.dat")) THEN
  120.              DO
  121.                             /* See what groups, if any, we will be installing */
  122.                CALL GetInstallGroups
  123.                IF (instgrps.0 > 0) THEN
  124.                  DO
  125.                                              /* Unpack the installation stuff */
  126.                    CALL InstUnpack
  127.                                              /* See if there's enough space   */
  128.                    IF spacecalc() THEN       /*   do the installation.        */
  129.                                              
  130.                      DO
  131.                        CALL Install          /* Install selected groups       */ 
  132.                                /* Put Locked file Device Driver in config.sys */
  133.                        IF (LFDDused) THEN
  134.                          DO
  135.                            ADDRESS CMD "@"loadpath"\addlfdd" BootDrive"\OS2\INSTALL"
  136.                            irc = C2D('fe00'x, 2)   /* reboot is required */
  137.                            ADDRESS CMD "@ECHO XXXXX CID Install was successful.  LFDD used." histout
  138.                          END
  139.                      END
  140.                    ELSE      /* No space available */
  141.                      irc = C2D('1208'x, 2)
  142.                  END
  143.              END
  144.            ELSE              /* failed reading the directory */
  145.              irc = C2D('1604'x, 2);
  146.          END
  147.        ELSE                  /* no space for install files, even */
  148.          irc = C2D('1208'x, 2)
  149.      ELSE                    /* Failed parsing the response file */
  150.        irc = C2D('1604'x, 2);
  151.   END
  152. ELSE            /* command line parsing failed */
  153.   irc = C2D('1604'x, 2);         /* Set 'error' return code */
  154.  
  155. IF irc = 0 THEN
  156.   ADDRESS CMD "@ECHO DCFINST CID Install was successful." histout
  157. IF logfile <> "" THEN
  158.   DO
  159.     ADDRESS CMD "@type" WkDir"\XXXXX.hst >"logfile
  160.     ADDRESS CMD "@echo ---------------- log file ---------------- >"logfile
  161.     ADDRESS CMD "@type" WkDir"\XXXXX.log >>"logfile
  162.   END
  163. CALL ENDLOCAL
  164. EXIT irc
  165.  
  166.  
  167. /***************************************************************************/
  168. /*  DoWeInstallIt - Decides whether a componant needs installed            */
  169. /***************************************************************************/
  170. DoWeInstallIt: PROCEDURE EXPOSE fl. BootDrive srcpath loadpath TargetDrive hist
  171. arg product, ver, grp.1, grp.2 grp.3, grp.4, grp.5
  172.  
  173.                 /******************************************/
  174.                 /* This routine uses a very simple little */
  175.                 /* program called "chklvl" to check what  */
  176.                 /* level a componant is at.  You will     */
  177.                 /* probably want to create your own such  */
  178.                 /* utility specific to the product you    */
  179.                 /* are interested in.  The source for     */
  180.                 /* this chklvl is included in the samples */
  181.                 /* package for reference.                 */
  182.                 /******************************************/
  183. hout = ">>"hist" 2>>&1"
  184. ADDRESS CMD "@"loadpath"\chklvl" BootDrive"\ibmlvl.ini" product ver hout
  185. IF rc = 0 THEN         /* product is not installed, or back-level */
  186.   RETURN 1             /* so we will definitely install it */
  187. ELSE
  188.   IF rc = 2 THEN      /* product is at a higher level.  We won't install */
  189.     RETURN 0
  190.   ELSE                /* product is at current level. Install if corrupted */
  191.     DO
  192.       DO k = 1 to 5   /* We can have up to 5 groups */
  193.         IF grp.k = "" THEN LEAVE
  194.         i = gindex(grp.k)            /* find out what drive the file is on */
  195.         IF fl.i.DRIVE = '@' THEN
  196.           dr = BootDrive
  197.         ELSE
  198.           dr = TargetDrive
  199.         IF i > 0 THEN DO
  200.           DO j = 1 to fl.i.0         /* See if the file exists             */
  201.             IF (STREAM(dr||fl.i.j.FNAME, 'c', 'query exists') = "") THEN
  202.                 DO
  203.                   CALL logXXXXXMsg 6, product, ver
  204.                   RETURN(1)      /* corrupted or installed on another drive */
  205.                 END
  206.           END
  207.       END
  208.       RETURN 0        /* Already correctly installed */
  209.     END
  210. RETURN 1        /* should never get here */
  211.  
  212. /***************************************************************************/
  213. /*  GetInstallGroups - decide what needs to be installed                   */
  214. /***************************************************************************/
  215. GetInstallGroups: PROCEDURE EXPOSE instgrps. fl. BootDrive srcpath loadpath,
  216.                                    TargetDrive instprods. hist
  217. i = 0
  218. j = 0
  219. IF DoWeInstallIt("AAAAA", "1.00", "[AAAAFILS]") THEN
  220.   DO
  221.     i = i + 1
  222.     instgrps.i = "[AAAAFILS]"
  223.     CALL logXXXXXMsg 7, "FFST 1.00"
  224.     j = j + 1
  225.     instprods.j = "AAAAA"
  226.     instprods.j.RELVER = "1.00"
  227.     instprods.j.IPATH = BootDrive"\OS2"
  228.   END
  229. ELSE
  230.   CALL logXXXXXMsg 8, "AAAAA 1.00"
  231. IF DoWeInstallIt("BBBBB", "2.00", "[BBBFILE1]") THEN
  232.   DO
  233.     i = i + 1
  234.     instgrps.i = "[BBBFILE1]"
  235.     CALL logXXXXXMsg 7, "BBBBB 2.00"
  236.     j = j + 1
  237.     instprods.j = "BBBBB"
  238.     instprods.j.RELVER = "2.00"
  239.     instprods.j.IPATH = BootDrive"\MUGLIB"
  240.   END
  241. ELSE
  242.   CALL logXXXXXMsg 8, "BBBBB 2.00"
  243. IF DoWeInstallIt("XXXXX", "1.00", "[XXXFILS1]", "[XXXFILS2]") THEN
  244.   DO
  245.     i = i + 1
  246.     instgrps.i = "[XXXFILS1]"
  247.     i = i + 1
  248.     instgrps.i = "[XXXFILS2]"
  249.     CALL logXXXXXMsg 7, "DCF 1.00"
  250.     j = j + 1
  251.     instprods.j = "XXXXX"
  252.     instprods.j.RELVER = "1.00"
  253.     instprods.j.IPATH = TargetDrive"\SQLLIB"
  254.   END
  255. ELSE
  256.   CALL logXXXXXMsg 8, "XXXXX 1.00"
  257. instgrps.0 = i
  258. instprods.0 = j
  259. RETURN
  260.  
  261. /***************************************************************************/
  262. /*  Install - moves the files from server to PC                            */
  263. /***************************************************************************/
  264. Install: PROCEDURE EXPOSE fl. BootDrive TargetDrive srcpath LFDDused,
  265.                           instgrps. histout loadpath instprods.
  266.  
  267.  
  268.                 /******************************************/
  269.                 /* This sample assumes that the files to  */
  270.                 /* be installed are stored in PKZIPed     */
  271.                 /* groups.  Change the unpacking code to  */
  272.                 /* accomodate other packing schemes.      */
  273.                 /******************************************/
  274. LFDDused = 0
  275. DO i = 1 to instgrps.0
  276.   filename = SUBSTR(instgrps.i, 2)
  277.   filename = STRIP(filename, 't', ']')
  278.   filename = srcpath"\"filename".ZIP"
  279.   j = gindex(instgrps.i)
  280.   IF j > 0 THEN
  281.     DO
  282.       IF fl.j.DRIVE = "@" THEN
  283.         tdrive = BootDrive"\"
  284.       ELSE
  285.         tdrive = TargetDrive"\"
  286.       lfddcmd = "MOVE"
  287.       IF left(tdrive,1) <> left(BootDrive,1) THEN
  288.         lfddcmd = "COPY"
  289.       IF fl.j.LOCKED THEN
  290.         DO
  291.           ADDRESS CMD "@PKUNZIP2 -o -d" filename BootDrive"\IBMLANLK" histout
  292.           DO k = 1 to fl.j.0
  293.             ADDRESS CMD "@ECHO" lfddcmd BootDrive"\IBMLANLK"fl.j.k.FNAME tdrive||fl.j.k.FNAME ">>"BootDrive"\OS2\INSTALL\IBMLANLK.LST"
  294.           END
  295.           LFDDused = 1
  296.         END
  297.       ELSE
  298.         ADDRESS CMD "@PKUNZIP2 -o -d" filename tdrive histout
  299.       END
  300.     END
  301.  
  302. DO i = 1 to instprods.0
  303.   ADDRESS CMD "@setlvl c:\ibmlvl.ini" instprods.i instprods.i.RELVER instprods.i.IPATH
  304. END
  305.  
  306. RETURN
  307.  
  308. /***************************************************************************/
  309. /*  spacecalc -- see if there is enough space to install                   */
  310. /*               (also sees if any files are locked)                       */
  311. /***************************************************************************/
  312. spacecalc: PROCEDURE EXPOSE fl. BootDrive TargetDrive instgrps. loadpath
  313.  
  314. size.1 = 0
  315. size.2 = 0
  316. DO i = 1 TO instgrps.0
  317.   j = gindex(instgrps.i)
  318.   IF fl.j.DRIVE = '@' THEN
  319.     dr = 1
  320.   ELSE
  321.     dr = 2
  322.   DO k = 1 to fl.j.0
  323.     filename = fl.j.k.FNAME
  324.     cursize = CurrentSizeOf(filename, dr)
  325.     size.dr = size.dr + fl.j.k.SIZE - cursize
  326.     IF cursize > 0 THEN
  327.       IF NotWriteable(filename, dr) THEN
  328.         DO
  329.           IF (fl.j.LOCKED = 0) THEN
  330.             CALL logXXXXXMsg 9, instgrps.i, filename
  331.           fl.j.LOCKED = 1
  332.           size.dr = size.dr + cursize
  333.         END
  334.   END
  335. END
  336. IF LEFT(BootDrive, 1) = LEFT(TargetDrive, 1) THEN
  337.   DO
  338.     size.2 = size.2 + size.1
  339.     size.1 = 0
  340.   END
  341.  
  342. IF EnoughSpace(TargetDrive, size.2) THEN
  343.   IF EnoughSpace(BootDrive, size.1) THEN
  344.     RETURN 1
  345. RETURN 0
  346.  
  347. /***************************************************************************/
  348. /*  CurrentSizeOf - return the size in bytes of a file                     */
  349. /***************************************************************************/
  350. CurrentSizeOf: PROCEDURE EXPOSE BootDrive TargetDrive
  351. arg filename, dr
  352.  
  353. IF dr = '1' THEN
  354.   size = STREAM(BootDrive||filename, 'c', 'query size')
  355. ELSE
  356.   size = STREAM(TargetDrive||filename, 'c', 'query size')
  357. IF size = "" THEN
  358.   size = 0
  359.  
  360. RETURN size
  361. /***************************************************************************/
  362. /* EnoughRoomForInstFiles() - returns 1 if there is enough                 */
  363. /***************************************************************************/
  364. EnoughRoomForInstFiles: PROCEDURE EXPOSE hist loadpath
  365. arg bootd, targetd
  366.  
  367.                 /******************************************/
  368.                 /* Of course, your install programs will  */
  369.                 /* probably take a different amount of    */
  370.                 /* space.  This one takes 340K on the     */
  371.                 /* boot drive and 20K whereever.          */
  372.                 /******************************************/
  373.  
  374. IF bootd = targetd THEN
  375.   RETURN(EnoughSpace(bootd, 360000))
  376. ELSE
  377.   RETURN(EnoughSpace(bootd, 340000) & EnoughSpace(targetd, 20000))
  378.  
  379. /***************************************************************************/
  380. /*  EnoughSpace -- return 1 if there is enough space, 0 otherwise          */
  381. /***************************************************************************/
  382. EnoughSpace: PROCEDURE EXPOSE loadpath
  383. arg dr, bogey
  384.  
  385. IF bogey <= 0 THEN
  386.   RETURN 1
  387.  
  388. DO queued()
  389.   PARSE PULL something
  390. END
  391. ADDRESS CMD "@DIR" LEFT(dr, 1)||":\*.  /N | RXQUEUE /lifo 2>&1"
  392. PARSE PULL free .
  393. DO queued()
  394.   PARSE PULL something
  395. END
  396. IF free < bogey THEN
  397.   DO
  398.     CALL logXXXXXMsg 3, dr, bogey, free
  399.     RETURN 0
  400.   END
  401. RETURN 1
  402.  
  403. /***************************************************************************/
  404. /*  NotWriteable: returns 1 if file could not be opened for write          */
  405. /***************************************************************************/
  406. NotWriteable: PROCEDURE EXPOSE BootDrive TargetDrive
  407. arg filename, dr
  408.  
  409. IF dr = '1' THEN
  410.   p = BootDrive
  411. ELSE
  412.   p = TargetDrive
  413.  
  414. fn = p||filename
  415. ADDRESS CMD "@"BootDrive"\OS2\attrib -R" fn ">NUL 2>&1"
  416. IF rc = 0 THEN
  417.   DO
  418.     q = STREAM(fn, 'c', 'open')
  419.     IF q <> "READY:" THEN
  420.       RETURN 1
  421.     CALL STREAM fn, 'c', 'close'
  422.   END
  423. RETURN 0
  424.  
  425. /***************************************************************************/
  426. /*  readlist -- read in the list of files to be unzipped                   */
  427. /***************************************************************************/
  428. readlist: PROCEDURE EXPOSE fl.
  429.  
  430. arg listfile
  431.  
  432. IF STREAM(listfile, 'c', 'query exists') = "" THEN
  433.   DO
  434.     logXXXXXMsg 5, listfile
  435.     RETURN 0
  436.   END
  437. fl.0 = 0
  438. i = 0
  439. DO WHILE LINES(listfile)
  440.   lin = LINEIN(listfile)
  441.   IF LEFT(lin, 1) = "[" THEN
  442.     DO
  443.       i = i + 1
  444.       fl.0 = i
  445.       fl.i.ZIPNAME = WORD(lin, 1)
  446.       fl.i.DRIVE = WORD(lin, 2)
  447.       fl.i.LOCKED = 0
  448.       fl.i.0 = 0
  449.       j = 0
  450.     END
  451.   ELSE
  452.     DO
  453.       j = j + 1
  454.       fl.i.0 = j
  455.       fl.i.j.REPLACE = 1
  456.       k = 1
  457.       IF WORD(lin, 1) = "NOREPLACE" THEN
  458.         DO
  459.           k = 2
  460.           fl.i.j.REPLACE = 0
  461.         END
  462.       fl.i.j.SIZE = WORD(lin, k)
  463.       fl.i.j.FNAME = WORD(lin, k+1)
  464.       fl.i.j.EXISTS = 0
  465.     END
  466. END
  467. CALL STREAM listfile, 'c', 'CLOSE'
  468. RETURN 1
  469.  
  470. /****************************************************************/
  471. /*  gindex - returns the index in fl. corresponding to the group*/
  472. /****************************************************************/
  473. gindex: PROCEDURE EXPOSE fl.
  474. arg grp
  475.  
  476. DO i = 1 to fl.0
  477.   IF fl.i.ZIPNAME = grp THEN
  478.     RETURN i
  479. END
  480. RETURN 0
  481.  
  482. /****************************************************************/
  483. /* GetBootDrive - sets the BootDrive variable                   */
  484. /****************************************************************/
  485. GetBootDrive: PROCEDURE EXPOSE srcpath
  486.  
  487.                 /******************************************/
  488.                 /* It is very easy to write an OS/2       */
  489.                 /* routine to extract the boot drive.     */
  490.                 /* The source for "getbootd" is included  */
  491.                 /* in the sample code for reference.      */
  492.                 /******************************************/
  493. ADDRESS CMD '@'srcpath'\getbootd'
  494. driveno = rc
  495. IF ((driveno < 1) | (driveno > 26)) THEN
  496.   driveno = 3
  497. bootdrive = SUBSTR("ABCDEFGHIJKLMNOPQRSTUVWXYZ", driveno, 1) || ":"
  498.  
  499. RETURN BootDrive
  500.  
  501. /******************************************************************************/
  502. /*  GetLoadDir()                                                             |*/
  503. /*                                                                            */
  504. /*  Extract the name of the directory from which this module was              */
  505. /*  loaded.                                                                   */
  506. /******************************************************************************/
  507. GetLoadDir: PROCEDURE
  508.  
  509. PARSE SOURCE "OS/2" "COMMAND" progname
  510. loaddir = FILESPEC('drive', progname) || FILESPEC('path', progname)
  511. loaddir = strip(loaddir)
  512. loaddir = STRIP(loaddir, 'trailing', '\')
  513.  
  514. return loaddir
  515.  
  516. /****************************************************************/
  517. /* ParseParms() - read the command line and set things up       */
  518. /****************************************************************/
  519. ParseParms: PROCEDURE EXPOSE TargetDrive srcpath histout respfile genpath,
  520.                              logfile loadpath
  521. PARSE ARG inparms
  522.  
  523. genpath = ""
  524. respfile = ""
  525. logfile = ""
  526. TargetDrive = ""
  527. ADDRESS CMD "@ECHO" inparms histout
  528. DO i = 1 to WORDS(inparms)
  529.   parm = WORD(inparms, i)
  530.   IF (POS('=', parm) > 0) THEN
  531.     PARSE VAR parm clflag '=' clval;
  532.   ELSE
  533.     PARSE VAR parm clflag ':' clval;
  534.   clval = STRIP(clval, 'both');
  535.   clflag = TRANSLATE(clflag);     /* force flag to upper case            */
  536.   SELECT
  537.      WHEN (clflag = "/S") THEN
  538.                                   srcpath = clval;
  539.      WHEN (clflag = "/R") THEN    respfile  = clval;
  540.      WHEN (clflag = "/G") THEN    genpath   = clval;
  541.      WHEN (clflag = "/L1") THEN   logfile = clval;
  542.      WHEN (clflag = "/T")  THEN    TargetDrive = clval;
  543.      OTHERWISE  DO
  544.                   CALL logXXXXXMsg 1, parms.i;
  545.                         shlrc = 4;
  546.                 END
  547.   END
  548. END
  549. IF (respfile = "") THEN
  550.   DO
  551.     CALL logXXXXXMsg 2
  552.     RETURN 0
  553.   END
  554. IF STREAM(respfile, 'c', 'query exists') = "" THEN
  555.   DO
  556.     CALL logXXXXXMsg 10, respfile
  557.     RETURN 0
  558.   END
  559. loadpath = GetLoadDir()
  560. IF srcpath = "" THEN
  561.   srcpath = loadpath
  562. IF TargetDrive <> "" THEN
  563.   TargetDrive = LEFT(TargetDrive, 1) || ":"
  564. path = VALUE('PATH',,'OS2ENVIRONMENT')
  565. dpath = VALUE('DPATH',,'OS2ENVIRONMENT')
  566. rfpath = FILESPEC("drive", respfile) || FILESPEC("path", respfile)
  567. rfpath = STRIP(rfpath, 'trailing', '\')
  568. IF genpath <> "" THEN
  569.   DO
  570.     p = genpath
  571.     IF (LENGTH(p) = 2) & (SUBSTR(p, 2, 1) = ":") THEN
  572.       p = p"\"
  573.     path = p || ";" || path
  574.     dpath = p || ";" || dpath
  575.   END
  576. IF rfpath <> "" THEN
  577.   DO
  578.     p = rfpath
  579.     IF (LENGTH(p) = 2) & (SUBSTR(p, 2, 1) = ":") THEN
  580.       p = p"\"
  581.     path = p || ";" || path
  582.     dpath = p || ";" || dpath
  583.   END
  584. IF srcpath <> "" THEN
  585.   DO
  586.     p = srcpath
  587.     IF (LENGTH(p) = 2) & (SUBSTR(p, 2, 1) = ":") THEN
  588.       p = p"\"
  589.     path = p || ";" || path
  590.     dpath = p || ";" || dpath
  591.   END
  592. IF loadpath <> srcpath THEN
  593.   DO
  594.     p = loadpath
  595.     IF (LENGTH(p) = 2) & (SUBSTR(p, 2, 1) = ":") THEN
  596.       p = p"\"
  597.     path = p || ";" || path
  598.     dpath = p || ";" || dpath
  599.   END
  600. call VALUE 'PATH',path,'OS2ENVIRONMENT'
  601. call VALUE 'DPATH',dpath,'OS2ENVIRONMENT'
  602.  
  603. RETURN 1
  604.  
  605. /****************************************************************/
  606. /* InstUnpack: prepare for installation                         */
  607. /****************************************************************/
  608. InstUnpack: PROCEDURE EXPOSE TargetDrive srcpath BootDrive hist loadpath
  609.  
  610. p = ">>"hist" 2>>&1"
  611. ADDRESS CMD "@MKDIR" TargetDrive"\SQLLIB" p
  612. ADDRESS CMD "@PKUNZIP2 -o -d" srcpath"\XXXXX1.ZIP" BootDrive"\" p
  613. ADDRESS CMD "@PKUNZIP2 -o -d" srcpath"\XXXXX2.ZIP" BootDrive"\" p
  614. ADDRESS CMD "@COPY" srcpath"\PKUNZIP2.EXE" BootDrive"\OS2\INSTALL\PKUNZIP2.EXE" p
  615. ADDRESS CMD "@COPY" srcpath"\XXXXINST.EXE"  BootDrive"\OS2\INSTALL\XXXXINST.EXE" p
  616. ADDRESS CMD "@COPY" srcpath"\XXXXLVL.ASC"   BootDrive"\OS2\INSTALL\XXXXXLVL.ASC" p
  617.  
  618. RETURN
  619.  
  620. /****************************************************************/
  621. /* ParseRespFile: read and validate resp file data              */
  622. /****************************************************************/
  623. ParseRespFile: PROCEDURE EXPOSE BootDrive srcpath WkDir TargetDrive histout,
  624.                                 loadpath
  625. arg respfile
  626.  
  627. cmdname = "SETENVIR.CMD"
  628. cmdname = WkDir || "\" || cmdname
  629. ADDRESS CMD "@ERASE" cmdname        ">NUL 2>&1"
  630. ADDRESS CMD "@ERASE DCFCFG.DAT >NUL 2>&1"
  631. CALL VALUE 'LOG_MESSAGE_FILE','ESAINST.MSG','OS2ENVIRONMENT'
  632.  
  633.                 /******************************************/
  634.                 /* XXXXXRF would act very much like       */
  635.                 /* SAMPLE1, reading the response file and */
  636.                 /* putting the keywords and values into   */
  637.                 /* a command file (SETENVIR.CMD) which    */
  638.                 /* would put the pairs into the environ-  */
  639.                 /* ment.                                  */
  640.                 /******************************************/
  641.  
  642. ADDRESS CMD "@XXXXXRF /R:"respfile ">"cmdname
  643. CALL VALUE 'LOG_MESSAGE_FILE','XXXXINST.MSG','OS2ENVIRONMENT'
  644. IF rc <> 0 THEN
  645.   RETURN 0
  646. p = STREAM(cmdname, 'c', 'query exists');
  647. IF p <> "" THEN
  648.   CALL cmdname
  649. IF TargetDrive = "" THEN
  650.   DO
  651.     TargetDrive = VALUE("XXXTARGT",,"OS2ENVIRONMENT")
  652.     If TargetDrive = "" THEN
  653.       TargetDrive = "C:"
  654.     ELSE
  655.       TargetDrive = LEFT(TargetDrive, 1) || ":"
  656.   END
  657. RETURN 1
  658.  
  659. /******************************************************************************/
  660. /* logXXXXXMsg()                                                               |*/
  661. /*                                                                            */
  662. /* This procedure does all error logging.  Message logging may be             */
  663. /* also be done in the body of the shell.                                     */
  664. /*                                                                            */
  665. /* We find the name of the log message file, and try to open it.              */
  666. /* If the message file isn't found, we put out a message to STDOUT.           */
  667. /* If the message file is found, we look at offset '1F'X to find the          */
  668. /* offset of Message 1.  We read to that position, then read the              */
  669. /* 'msgno'th line to get the message text.  Then we process the               */
  670. /* substitution variables and put out the resultant message either            */
  671. /* to the Log File or to STDOUT                                               */
  672. /*                                                                            */
  673. /* We try really hard to find the log file.  If it's not on the               */
  674. /* source path and not on the current path, we try every path in              */
  675. /* PATH and DPATH.                                                            */
  676. /******************************************************************************/
  677. logXXXXXMsg: PROCEDURE EXPOSE srcpath loadpath header wkdir histout
  678. arg msgno,parm.1,parm.2,parm.3,parm.4,parm.5,parm.6,parm.7,parm.8,parm.9 .
  679.  
  680. lmfile = VALUE('LOG_MESSAGE_FILE',,"OS2ENVIRONMENT")
  681. fqlmfile = srcpath"\"lmfile
  682. IF STREAM(fqlmfile, 'c', 'query exists') = "" THEN
  683.   fqlmfile = loadpath"\"lmfile
  684.  
  685. IF STREAM(fqlmfile, 'c', 'query exists') == "" THEN
  686.   DO
  687.      ADDRESS CMD '@echo Log Message File' fqlmfile 'not found.' histout
  688.      ADDRESS CMD '@echo Can not log message number' msgno'.  Message parms were:' histout
  689.      DO i = 1 to 9
  690.        IF parm.i == "" THEN
  691.          LEAVE
  692.        ELSE
  693.          ADDRESS CMD '@echo 'parm.i histout
  694.      END
  695.      RETURN
  696.   END
  697.  
  698. OffsetX = CHARIN(fqlmfile, 32 + (msgno * 2), 2)
  699. wkvar = SUBSTR(OffsetX, 2, 1) || SUBSTR(OffsetX, 1, 1)
  700. StartingOffsetD = C2D(wkvar)
  701. OffsetX = CHARIN(fqlmfile, 32 + ((msgno+1)*2), 2)
  702. wkvar = SUBSTR(OffsetX, 2, 1) || SUBSTR(OffsetX, 1, 1)
  703. EndingOffsetD = C2D(wkvar)
  704. lin = CHARIN(fqlmfile, StartingOffsetD + 1, EndingOffsetD - StartingOffsetD - 1)
  705. CALL STREAM fqlmfile, "C", "CLOSE"                      /* Close the file @d3a*/
  706.  
  707. DO i = 1 to 9
  708.   n = POS("%" || i, lin)
  709.   IF (n <> 0) THEN
  710.     DO
  711.       lin = DELSTR(lin, n, 2)
  712.       temp = STRIP(parm.i)
  713.       lin = INSERT(temp, lin, n-1)
  714.     END
  715. END
  716. header = "DCA"
  717. n = LENGTH(msgno)
  718. DO i = 4 to (7-n)
  719.   header = header || '0'
  720. END
  721. if substr(lin,1,1) = "I" then                          /* INFO message   */
  722.    header = substr(lin,2)
  723. else
  724.    header = header || msgno || LEFT(lin, 1) || " " || SUBSTR(lin,2)
  725. LogFile = VALUE("LOG_FILE",,"OS2ENVIRONMENT")
  726. IF (LogFile <> "") THEN
  727.   DO
  728.     CALL LINEOUT LogFile, header
  729.     CALL STREAM LogFile, "C", "CLOSE"     /* close the log file */
  730.   END
  731. ELSE
  732.   ADDRESS CMD '@echo' header histout
  733. RETURN
  734.