home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / netdor4.zip / CSDM / CASBASE.FIL next >
Text File  |  1996-04-04  |  16KB  |  338 lines

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