home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lansystk.zip / MPTSUTIL / APPLETS / CASBASE.FIL < prev    next >
Text File  |  1998-05-08  |  16KB  |  345 lines

  1. /* REXX command file for LCU 2.0     */
  2.  
  3. /****************************************************/
  4. /*         DO NOT MODIFY THE NEXT EIGHT LINES       */
  5. /****************************************************/
  6.  
  7. parse ARG client logfile additional
  8.  
  9. QUEUE_REBOOT = 0
  10. CALL_AGAIN = 0
  11.  
  12. Call AddDLLFunctions
  13.  
  14. x.0.instprog = ''
  15. x.0.rspdir   = ''
  16. x.0.statevar = 'CAS_STATE'
  17. x.0.default  = ''
  18.  
  19. /****************************************************/
  20. /*             MODIFICATIONS START HERE             */
  21. /****************************************************/
  22.  
  23. /* START SYSTEM DATA HERE        */
  24.  
  25. /* 'SRVATTCH z: \\SERVER\ALIAS' */                              /* Additional SRVATTCHs are placed here   */
  26.  
  27. /* 'SRVATTCH y: SERVER2'         */                             /* They can be placed before specific     */
  28.                                                                 /* RunInstall statements too if you only  */
  29.                                                                 /* want to attach to a special server     */
  30.                                                                 /* right before a specific install.       */
  31.  
  32. /* START SRVATTACHES HERE        */
  33.  
  34. /* START PRODUCT DATA HERE       */
  35.  
  36.  
  37. /****************************************************/
  38. /*            DO NOT MODIFY THE NEXT LINE           */
  39. /****************************************************/
  40.  
  41. OVERALL_STATE = GetEnvironmentVars()
  42.  
  43. Do Forever
  44.   Select
  45. /* PUT INSTALLS HERE             */
  46.   end
  47. end
  48. exit
  49.  
  50.  
  51. /*************************************************************/
  52. /*         DO NOT MODIFY ANY CODE BELOW THIS LINE !!!        */
  53. /*************************************************************/
  54.  
  55. RunInstall: procedure expose x. queue_reboot call_again configsys logfile client OVERALL_STATE
  56.   parse arg index, new_state, other
  57.   install = SetEnvironmentVar(x.index.statevar)
  58.   if install == YES then do
  59.     state = value('REMOTE_INSTALL_STATE',,'OS2ENVIRONMENT')     /* check   REMOTE_INSTALL_STATE */
  60.     if state <> 0 then
  61.       rc2 = LogMessage(75, x.index.name, state, logfile)        /* log an install starting msg  */
  62.     else
  63.       rc2 = LogMessage(72, x.index.name, '', logfile)           /* log an install starting msg  */
  64.  
  65.     install_prog = 'CMD /C ' || strip(x.index.instprog)         /* build the command string     */
  66.  
  67.                                                 /* If automatic responst file selection was     */
  68.                                                 /* indicated, then get the response file name   */
  69.                                                 /* and append it to the command string.         */
  70.     if x.index.default <> '' then do
  71.       response_file = DetermineResponseFile(x.index.rspdir, client,
  72.                                             , x.index.default, x.index.name,
  73.                                             , logfile)
  74.       if response_file == '' then exit
  75.       install_prog = install_prog || response_file
  76.     end
  77.  
  78.     install_prog                                                /* Execute the install program  */
  79.  
  80.     state = value(x.index.statevar,,'OS2ENVIRONMENT')           /* Get the current install state*/
  81.                                                                 /* for this install program from*/
  82.                                                                 /* the environment.             */
  83.  
  84.                                                 /* Check the return code and set the global     */
  85.                                                 /* variables accordingly.                       */
  86.  
  87.     parse value ProcessReturnCode(rc, state, QUEUE_REBOOT, CALL_AGAIN, logfile),
  88.            with rc ',' state ',' QUEUE_REBOOT ',' CALL_AGAIN
  89.  
  90.     rc2 = value(x.index.statevar, state, 'OS2ENVIRONMENT')      /* Set the new install state for*/
  91.                                                                 /* this install program.        */
  92.  
  93.                                                 /* Put the install state into the CONFIG.SYS,   */
  94.                                                 /* if this action was unsuccessful, then exit.  */
  95.  
  96.     if PutStateVar(x.index.statevar, state, configsys, logfile) <> 0 then exit
  97.  
  98.     if rc == GOOD_RC then do
  99.       if pos('\SEMAINT', translate(install_prog)) <> 0 then     /* If the install program was   */
  100.         Call PreserveStartupCmd(install_prog)                   /* SEMAINT, then make sure      */
  101.                                                                 /* STARTUP.CMD won't be copied  */
  102.                                                                 /* over when SEINST runs.       */
  103.  
  104.       rc2 = LogMessage(70, x.index.name, '', logfile)           /* log an install successful msg*/
  105.       return GOOD_RC                                            /* return a good return code    */
  106.     end
  107.  
  108.     else do
  109.       rc2 = LogMessage(71, x.index.name, '', logfile)           /* log an install failed msg    */
  110.       if (new_state <> '') then                                 /* If a new state was requested,*/
  111.                                                                 /* then set OVERALL_STATE to the*/
  112.         rc2 = SetState(new_state, 'RunInstall', 2)              /* new state.                   */
  113.  
  114.       return BAD_RC                                             /* return a bad return code     */
  115.     end
  116.   end
  117.   return GOOD_RC
  118.  
  119.  
  120. /*************************************************************/
  121. PreserveStartupCmd: procedure
  122.  
  123.   parse upper arg string, other
  124.  
  125.   if pos('/T:', string) <> 0 then                               /* Determine if there is a      */
  126.     findvalue = '/T:'                                           /* target parameter.  If there  */
  127.   else                                                          /* is none, return.             */
  128.     if pos('-T:',string) <> 0 then
  129.       findvalue = '-T:'
  130.     else
  131.       return 0
  132.  
  133.   remain = substr(string, pos(findvalue, string) + 3)           /* Get the value of the target  */
  134.                                                                 /* parameter.                   */
  135.   blank = pos(' ', remain)
  136.  
  137.   if (blank <> 0) then
  138.     param = substr(remain, 1, blank-1)
  139.   else
  140.     param = remain
  141.                                                 /* Erase startup.lcu in the target directory,  */
  142.                                                 /* then rename startup.s13 to startup.lcu      */
  143.  
  144.   'if exist ' param || '\startup.lcu erase  ' param || '\startup.lcu'
  145.   'if exist ' param || '\startup.s13 rename ' param || '\startup.s13 *.lcu'
  146.  
  147.   return 0
  148.  
  149. /*************************************************************/
  150. GetEnvironmentVars: procedure expose X. NUM_INSTALL_PROGS
  151.  
  152.  
  153.   OVERALL_STATE = value(x.0.statevar,,'OS2ENVIRONMENT')         /* Get the overall install state */
  154.                                                                 /* from the environment.         */
  155.  
  156.   if OVERALL_STATE == '' then do                                /* If the overall install state  */
  157.     OVERALL_STATE = 0                                           /* has not been set yet, reset   */
  158.     do I=0 to NUM_INSTALL_PROGS by 1                            /* all the state vars to 0.      */
  159.       if x.I.statevar <> '' then
  160.         rc = value(x.I.statevar,'0','OS2ENVIRONMENT')
  161.     end
  162.   end
  163.  
  164.   return OVERALL_STATE
  165.  
  166.  
  167. /*************************************************************/
  168. SetEnvironmentVar: procedure
  169.   parse arg env_string, other
  170.   if env_string == '' then do                                   /* If the install program has   */
  171.                                                                 /* no state variable, then ...  */
  172.  
  173.     rc = value('REMOTE_INSTALL_STATE','0','OS2ENVIRONMENT')     /* Set the REMOTE_INSTALL_STATE */
  174.                                                                 /* to 0 so that the program     */
  175.                                                                 /* being run can know that is   */
  176.                                                                 /* being run in an unattended   */
  177.                                                                 /* environment.                 */
  178.  
  179.     return YES                                                  /* return install=yes           */
  180.  
  181.   end
  182.  
  183.   state = value(env_string,,'OS2ENVIRONMENT')                   /* Otherwise, get the value of  */
  184.                                                                 /* the state variable from the  */
  185.                                                                 /* environment.                 */
  186.  
  187.   if state <> '' then do                                        /* If the state variable exists */
  188.  
  189.     rc = value('REMOTE_INSTALL_STATE',state,'OS2ENVIRONMENT')   /* Set the REMOTE_INSTALL_STATE */
  190.                                                                 /* environment variable to the  */
  191.                                                                 /* value of the state variable. */
  192.  
  193.     return YES                                                  /* return install=yes           */
  194.   end
  195.   else                                                          /* Otherwise,                   */
  196.     return NO                                                   /* return install=no            */
  197.  
  198.  
  199. /*************************************************************/
  200. BootDriveIsDiskette:
  201.  
  202.   if IsBootDriveRemovable() == 1 then do                        /* If the drive booted from is  */
  203.                                                                 /* a diskette drive, then set   */
  204.     rc2 = SetState(OVERALL_STATE+1)                             /* the OVERALL_STATE to the     */
  205.                                                                 /* requested value.             */
  206.     return 'YES'
  207.  
  208.   end
  209.  
  210.   else                                                          /* else the machine was booted  */
  211.                                                                 /* from the hardfile.           */
  212.     return 'NO'
  213.  
  214. /*************************************************************/
  215. BootDriveIsFixedDisk:
  216.  
  217.   if IsBootDriveRemovable() == 0 then do                        /* If the drive booted from is  */
  218.                                                                 /* a fixed disk, then set       */
  219.     rc2 = SetState(OVERALL_STATE+1)                             /* the OVERALL_STATE to the     */
  220.                                                                 /* requested value.             */
  221.     return 'YES'
  222.  
  223.   end
  224.  
  225.   else                                                          /* else the machine was booted  */
  226.                                                                 /* from a diskette.             */
  227.     return 'NO'
  228.  
  229. /*************************************************************/
  230. SetState:
  231.   parse arg new_state, proc_name, param_num, other
  232.  
  233.     if datatype(new_state, number) <> 1 then do                 /* If the new state requested is*/
  234.                                                                 /* not numeric, then log an     */
  235.       if proc_name <> '' then                                   /* error.                       */
  236.         LogMessage(63, proc_name, param_num, logfile)
  237.       else
  238.         LogMessage(63, 'SetState', 1, logfile)
  239.  
  240.       exit
  241.     end
  242.  
  243.     OVERALL_STATE = new_state                                   /* Set the OVERALL_STATE to the */
  244.                                                                 /* new state requested.         */
  245.  
  246.     rc = value(x.0.statevar, new_state, 'OS2ENVIRONMENT')       /* Save the OVERALL_STATE in the*/
  247.                                                                 /* environment.                 */
  248.     return 'NO_ERROR'
  249.  
  250.  
  251. /*************************************************************/
  252. SaveStates:
  253.  
  254.   do I=0 to NUM_INSTALL_PROGS by 1            /* Put the install states into the CONFIG.SYS,  */
  255.     if x.I.statevar <> '' then                /* if this action was unsuccessful, then exit.  */
  256.  
  257.       if PutStateVar(x.I.statevar, value(x.I.statevar,,'OS2ENVIRONMENT'),
  258.                      , configsys, logfile) <> 0 then exit
  259.   end
  260.  
  261.   return
  262.  
  263. /*************************************************************/
  264. RebootAndGotoState:
  265.   parse arg new_state, other
  266.  
  267.   rc2 = SetState(new_state, 'RebootAndGotoState', 1)           /* Set the state to go to in    */
  268.                                                                /* OVERALL_STATE.               */
  269.  
  270.   Call SaveStates                                              /* Save the environment vars    */
  271.  
  272.   Call Reboot                                                  /* Reboot the machine           */
  273.  
  274.   return
  275.  
  276.  
  277. /*************************************************************/
  278. CheckBoot:
  279.   if QUEUE_REBOOT <> 0 then do                                  /* If a reboot has been queued  */
  280.                                                                 /* by an install program ...    */
  281.  
  282.     if CALL_AGAIN == 0 then                                     /* If no install programs want  */
  283.                                                                 /* to be recalled ...           */
  284.  
  285.       rc = SetState(OVERALL_STATE+1)                            /* Increment the overall state  */
  286.                                                                 /* variable.                    */
  287.  
  288.     Call SaveStates                                             /* Save the environment vars    */
  289.  
  290.     Call Reboot                                                 /* Reboot the machine           */
  291.  
  292.   end
  293.  
  294.   else                                                          /* Otherwise, increment the     */
  295.     rc = SetState(OVERALL_STATE+1)                              /* state variable and go on.    */
  296.  
  297.   return
  298.  
  299.  
  300. /*************************************************************/
  301. Reboot:
  302.   bootdrive
  303.  
  304.   rc = value('OS2_SHELL', bootdrive || '\OS2\CMD.EXE', 'OS2ENVIRONMENT')
  305.   rc = value('COMSPEC',   bootdrive || '\OS2\CMD.EXE', 'OS2ENVIRONMENT')
  306.  
  307.   'cls'
  308.   rc = AskRemoveDiskIfFloppy()
  309.  
  310.   pathlen = length(exepath)                                     /* Get length of exepath        */
  311.   posslash = lastpos("\",strip(exepath))                        /* Determine the last occurcnce */
  312.                                                                 /*   of '\' in exepath          */
  313.  
  314.   if posslash = pathlen then                                    /* If '\' is the last character */
  315.  
  316.     cmdline = exepath || 'SETBOOT /IBD:' || bootdrive           /* Then append 'SETBOOT'        */
  317.  
  318.   else
  319.  
  320.     cmdline = exepath || '\SETBOOT /IBD:' || bootdrive          /* Else append '\SETBOOT'       */
  321.  
  322.   LogMessage(74, '', '', logfile)                               /* Log a message indicating     */
  323.                                                                 /* reboot.                      */
  324.   cmdline
  325.  
  326.   LogMessage(73, 'SETBOOT', '', logfile)                        /* If the code gets to here, the*/
  327.                                                                 /* reboot failed.  Log a message*/
  328.   exit                                                          /* and exit.                    */
  329.  
  330.   return
  331.  
  332.  
  333. /*************************************************************/
  334. AddDLLFunctions:
  335.   Call RxFuncAdd 'ProcessReturnCode',     'CASAGENT', 'PROCESSRETURNCODE'
  336.   Call RxFuncAdd 'DetermineResponseFile', 'CASAGENT', 'DETERMINERESPONSEFILE'
  337.   Call RxFuncAdd 'PutStateVar',           'CASAGENT', 'PUTSTATEVAR'
  338.   Call RxFuncAdd 'LogMessage',            'CASAGENT', 'GETANDLOGMESSAGE'
  339.   Call RxFuncAdd 'AskRemoveDiskIfFloppy', 'CASAGENT', 'ASKREMOVEDISKIFFLOPPY'
  340.   Call RxFuncAdd 'IsBootDriveRemovable',  'CASAGENT', 'ISBOOTDRIVEREMOVABLE'
  341.   Call RxFuncAdd 'GetOS2Version',         'CASAGENT', 'GETOS2VERSION'
  342.   Call RxFuncAdd 'SetCIDType',            'CASAGENT', 'SETCIDTYPE'
  343.  
  344.   return
  345.