home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / SPONLY.ZIP / SPONLY.CMD
OS/2 REXX Batch file  |  1993-04-19  |  25KB  |  466 lines

  1. /* REXX command file CASSKEL */
  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. /*****************************************************/
  21. /*             MODIFICATIONS START HERE              */
  22. /*****************************************************/
  23.  
  24. /* 'SRVATTCH z: \\\\bjasrv\d1\ALIAS' */                             /* Additional SRVATTCHs can be placed here*/
  25.  
  26. /* 'SRVATTCH x: SERVER2'         */                             /* They can be placed before specific     */
  27.                                                                 /* RunInstall statements too if you only  */
  28.                                                                 /* want to attach to a special server     */
  29.                                                                 /* right before a specific install.       */
  30.  
  31. /*****************************************************/
  32. /*         DO NOT REMOVE THE NEXT FOUR LINES         */
  33. /*              (They may be modified)               */
  34. /*****************************************************/
  35.  
  36. bootdrive='c:'                                                  /* Boot Drive                             */
  37. configsys = bootdrive || '\CONFIG.SYS'                          /* Fully qualified path to CONFIG.SYS     */
  38.  
  39. exepath = 'X:\EXE\v200b'
  40. dllpath = 'X:\DLL\V200;x:\img\lcu'                              /* Paths to the DLL directories on server */
  41.  
  42. maintdir= bootdrive || '\service'
  43.  
  44. srvifssrv = 'server1'
  45.  
  46. /*****************************************************/
  47. /* The next four lines are included to make it       */
  48. /* easier to change the version of OS/2 2.0 that is  */
  49. /* to be installed.                                  */
  50. /*                                                   */
  51. /* These variables are refrenced in the product data */
  52. /* sections for SEINST and SEMAINT.                  */
  53. /*****************************************************/
  54.  
  55. os2dir  = 'OS2V20'                                              /* Name of OS/2 2.0 directories         */
  56. os2img  = 'x:\img\' || os2dir                                   /* - product image directory            */
  57. os2rsp  = 'X:\RSP\' || os2dir                                   /* - response file directory            */
  58. os2log  = 'X:\LOG\' || os2dir                                   /* - log file directory                 */
  59.  
  60.  
  61. x.semaint = 1                                                   /* structure index                      */
  62. x.1.name='OS/1 1.0 Maintenance'                                 /* product name                         */
  63. x.1.statevar = 'CAS_' || x.1.name                               /* state variable name                  */
  64. x.1.instprog = exepath || '\semaint                    ',       /* fully qualified install program name */
  65.                 ' /s:' || os2img || '                  ',       /* - source directory                   */
  66.                 ' /t:' || maintdir || '                ',       /* - target directory                   */
  67.                 ' /b:' || bootdrive || '               ',       /* - target boot drive (not necessarily current) */
  68.                 '/l1:' || os2log || '\' || client || '.log'        /* - log file                           */
  69. x.1.rspdir   = ''                                               /* no auto selection                    */
  70. x.1.default  = ''
  71.  
  72. x.laps_prep = 2                                                 /* structure index                      */
  73. x.2.name='LAPS Maintnenace'                                     /* product name                         */
  74. x.2.statevar = 'CAS_' || x.2.name                               /* state variable name                  */
  75. x.2.instprog = 'x:\img\laps\laps                      ',        /* fully qualified install program name */
  76.                 ' /e:prep                             ',        /* - prep installation                  */
  77.                 ' /s:x:\img\laps                      ',        /* - source directory                   */
  78.                 ' /t:' || maintdir || '               ',        /* - target directory                   */
  79.                 '/tu:' || bootdrive || '              ',        /* - location of config.sys             */
  80.                 '/l1:x:\log\laps\' || client || '.log ',        /* - log file                           */
  81.                 ' /r:x:\rsp\laps\lapsrsp.rsp'                   /* - response file                      */
  82. x.2.rspdir   = ''                                               /* no auto selection                    */
  83. x.2.default  = ''
  84.  
  85. x.thinifs = 3                                                   /* structure index                      */
  86. x.3.name='SRVIFS Requester'                                     /* product name                         */
  87. x.3.statevar = ''                                               /* state variable name                  */
  88. x.3.instprog = 'x:\img\srvifs\thinifs                   ',      /* fully qualified install program name */
  89.                '  /s:x:\img\srvifs                      ',      /* - source directory                   */
  90.                '  /t:' || bootdrive || '\srvifsrq       ',      /* - target directory                   */
  91.                ' /tu:' || bootdrive || '\               ',      /* - config.sys location                */
  92.                ' /l1:x:\log\srvifs\' || client || '.log ',      /* - log file                           */
  93.                '/req:' || client || '                   ',      /* - requester name                     */
  94.                '/srv:' || srvifssrv || '                ',      /* - server name                        */
  95.                '  /d:x'                                         /* - remote drive identifier            */
  96. x.3.rspdir   = ''                                               /* no auto selection                    */
  97. x.3.default  = ''
  98.  
  99. x.ifsdel = 4                                                    /* structure index                      */
  100. x.4.name='SRVIFS Delete'                                        /* product name                         */
  101. x.4.statevar = ''                                               /* state variable name                  */
  102. x.4.instprog = 'x:\img\srvifs\ifsdel             ',             /* fully qualified install program name */
  103.                ' /t:' || bootdrive || '\srvifsrq ',             /* - target directory                   */
  104.                '/tu:' || bootdrive                              /* - config.sys location                */
  105. x.4.rspdir   = ''                                               /* no auto selection                    */
  106. x.4.default  = ''
  107.  
  108. x.casinstl = 5                                                 /* structure index                               */
  109. x.5.name='LAN CID Utility'                                     /* product name                                  */
  110. x.5.statevar = ''                                              /* state variable name                           */
  111. x.5.instprog = 'x:\img\lcu\casinstl                 ',         /* fully qualified install program name          */
  112.                '/cmd:x:\client\sponly                       ',         /* - location of .cmd files (passed to casagent) */
  113.                ' /tu:' || bootdrive || '             ',         /* - config.sys location (boot drive)            */
  114.                ' /pl:' || dllpath || '                ',         /* - string to add to libpath                    */
  115.                ' /pa:x:\img\lcu                      ',         /* - workstation's path to LCU code on server    */
  116.                ' /d ',
  117.                ' /l1:x:\log\lcu\' || client || '.log ',         /* - CASINSTL log file                           */
  118.                ' /l1:x:\log\lcu\SRVIFS_REQ.log'                 /* - CASAGENT log file                           */
  119. x.5.rspdir   = ''                                              /* no auto selection                             */
  120. x.5.default  = ''
  121.  
  122. x.casdelet = 6                                                /* structure index                      */
  123. x.6.name='LAN CID Utility Delete'                             /* product name                         */
  124. x.6.statevar = ''                                             /* state variable name                  */
  125. x.6.instprog = 'x:\img\lcu\casdelet   ',                      /* fully qualified install program name */
  126.                 '/pl:' || dllpath || '  ',                      /* - string to delete from libpath      */
  127.                 '/tu:' || bootdrive                            /* - config.sys location (boot drive)   */
  128. x.6.rspdir   = ''                                             /* no auto selection                    */
  129. x.6.default  = ''
  130.  
  131. x.fservice = 7
  132. x.7.name='OS/1 Service Pak'
  133. x.7.statevar = 'CAS_' || x.7.name
  134. x.7.instprog = 'x:\csd\os2v20\csd1\fservice         ',
  135.                ' /s:x:\csd\os2v20\csd1              ',
  136.                ' /t:' || maintdir || '             ',
  137.                ' /l1:x:\log\csd\os2v20\' || client || '.log',
  138.                ' /r:'
  139. x.7.rspdir   = 'x:\rsp\csd\os2v20'
  140. x.7.default  = 'default.rsp'
  141.  
  142.  
  143. NUM_INSTALL_PROGS = 7
  144.  
  145. /****************************************************/
  146. /*            DO NOT MODIFY THE NEXT LINE           */
  147. /****************************************************/
  148.  
  149. OVERALL_STATE = GetEnvironmentVars()
  150.  
  151. Do Forever
  152.   Select
  153.     when OVERALL_STATE = 0 then do
  154.       if BootDriveisdiskette() == YES then iterate
  155.  
  156.       if RunInstall(x.semaint)   == BAD_RC then exit            /* Install maintenance system   */
  157.       if RunInstall(x.laps_prep) == BAD_RC then exit            /* Install LAPS prep system     */
  158.       if RunInstall(x.thinifs)   == BAD_RC then exit            /* Install SRVIFS requester     */
  159.       if RunInstall(x.casinstl)  == BAD_RC then exit            /* Install LCU                  */
  160.     end
  161.  
  162.     when OVERALL_STATE = 1 then do
  163.       if RunInstall(x.fservice) == BAD_RC then exit             /* Install the service pak      */
  164.       if BootDriveisdiskette() == YES then
  165.         call reboot
  166.       else
  167.         call checkboot
  168.     end
  169.     when OVERALL_STATE = 2 then do
  170.       if RunInstall(x.ifsdel) == BAD_RC then exit
  171.       if RunInstall(x.casdelet) == BAD_RC then exit             /* Delete LCU                   */
  172.       Call Reboot                                               /* Reboot                       */
  173.     end
  174.   end
  175. end
  176. exit
  177.  
  178.  
  179. /*************************************************************/
  180. /*         DO NOT MODIFY ANY CODE BELOW THIS LINE !!!        */
  181. /*************************************************************/
  182.  
  183. RunInstall: procedure expose x. queue_reboot call_again configsys logfile client OVERALL_STATE
  184.   parse arg index, new_state, other
  185.   install = SetEnvironmentVar(x.index.statevar)
  186.   if install == YES then do
  187.     rc2 = LogMessage(72, x.index.name, '', logfile)             /* log an install starting msg  */
  188.     install_prog = 'CMD /C ' || strip(x.index.instprog)         /* build the command string     */
  189.  
  190.                                                 /* If automatic responst file selection was     */
  191.                                                 /* indicated, then get the response file name   */
  192.                                                 /* and append it to the command string.         */
  193.     if x.index.default <> '' then do
  194.       response_file = DetermineResponseFile(x.index.rspdir, client,
  195.                                             , x.index.default, x.index.name,
  196.                                             , logfile)
  197.       if response_file == '' then exit
  198.       install_prog = install_prog || response_file
  199.     end
  200.  
  201.     install_prog                                                /* Execute the install program  */
  202.  
  203.     state = value(x.index.statevar,,'OS2ENVIRONMENT')           /* Get the current install state*/
  204.                                                                 /* for this install program from*/
  205.                                                                 /* the environment.             */
  206.  
  207.                                                 /* Check the return code and set the global     */
  208.                                                 /* variables accordingly.                       */
  209.  
  210.     parse value ProcessReturnCode(rc, state, QUEUE_REBOOT, CALL_AGAIN, logfile),
  211.            with rc ',' state ',' QUEUE_REBOOT ',' CALL_AGAIN
  212.  
  213.     rc2 = value(x.index.statevar, state, 'OS2ENVIRONMENT')      /* Set the new install state for*/
  214.                                                                 /* this install program.        */
  215.  
  216.                                                 /* Put the install state into the CONFIG.SYS,   */
  217.                                                 /* if this action was unsuccessful, then exit.  */
  218.  
  219.     if PutStateVar(x.index.statevar, state, configsys, logfile) <> 0 then exit
  220.  
  221.     if rc == GOOD_RC then do
  222.       if pos('\SEMAINT', translate(install_prog)) <> 0 then     /* If the install program was   */
  223.         Call PreserveStartupCmd(install_prog)                   /* SEMAINT, then make sure      */
  224.                                                                 /* STARTUP.CMD won't be copied  */
  225.                                                                 /* over when SEINST runs.       */
  226.  
  227.       rc2 = LogMessage(70, x.index.name, '', logfile)           /* log an install successful msg*/
  228.       return GOOD_RC                                            /* return a good return code    */
  229.     end
  230.  
  231.     else do
  232.       rc2 = LogMessage(71, x.index.name, '', logfile)           /* log an install failed msg    */
  233.       if (new_state <> '') then                                 /* If a new state was requested,*/
  234.                                                                 /* then set OVERALL_STATE to the*/
  235.         rc2 = SetState(new_state, 'RunInstall', 2)              /* new state.                   */
  236.  
  237.       return BAD_RC                                             /* return a bad return code     */
  238.     end
  239.   end
  240.   return GOOD_RC
  241.  
  242.  
  243. /*************************************************************/
  244. PreserveStartupCmd: procedure
  245.  
  246.   parse upper arg string, other
  247.  
  248.   if pos('/T:', string) <> 0 then                               /* Determine if there is a      */
  249.     findvalue = '/T:'                                           /* target parameter.  If there  */
  250.   else                                                          /* is none, return.             */
  251.     if pos('-T:',string) <> 0 then
  252.       findvalue = '-T:'
  253.     else
  254.       return 0
  255.  
  256.   remain = substr(string, pos(findvalue, string) + 3)           /* Get the value of the target  */
  257.                                                                 /* parameter.                   */
  258.   blank = pos(' ', remain)
  259.  
  260.   if (blank <> 0) then
  261.     param = substr(remain, 1, blank-1)
  262.   else
  263.     param = remain
  264.                                                 /* Erase startup.lcu in the target directory,  */
  265.                                                 /* then rename startup.s13 to startup.lcu      */
  266.  
  267.   'if exist ' param || '\startup.lcu erase  ' param || '\startup.lcu'
  268.   'if exist ' param || '\startup.s13 rename ' param || '\startup.s13 *.lcu'
  269.  
  270.   return 0
  271.  
  272. /*************************************************************/
  273. GetEnvironmentVars: procedure expose X. NUM_INSTALL_PROGS
  274.  
  275.  
  276.   OVERALL_STATE = value(x.0.statevar,,'OS2ENVIRONMENT')         /* Get the overall install state */
  277.                                                                 /* from the environment.         */
  278.  
  279.   if OVERALL_STATE == '' then do                                /* If the overall install state  */
  280.     OVERALL_STATE = 0                                           /* has not been set yet, reset   */
  281.     do I=0 to NUM_INSTALL_PROGS by 1                            /* all the state vars to 0.      */
  282.       if x.I.statevar <> '' then
  283.         rc = value(x.I.statevar,'0','OS2ENVIRONMENT')
  284.     end
  285.   end
  286.  
  287.   return OVERALL_STATE
  288.  
  289.  
  290. /*************************************************************/
  291. SetEnvironmentVar: procedure
  292.   parse arg env_string, other
  293.   if env_string == '' then do                                   /* If the install program has   */
  294.                                                                 /* no state variable, then ...  */
  295.  
  296.     rc = value('REMOTE_INSTALL_STATE','0','OS2ENVIRONMENT')     /* Set the REMOTE_INSTALL_STATE */
  297.                                                                 /* to 0 so that the program     */
  298.                                                                 /* being run can know that is   */
  299.                                                                 /* being run in an unattended   */
  300.                                                                 /* environment.                 */
  301.  
  302.     return YES                                                  /* return install=yes           */
  303.  
  304.   end
  305.  
  306.   state = value(env_string,,'OS2ENVIRONMENT')                   /* Otherwise, get the value of  */
  307.                                                                 /* the state variable from the  */
  308.                                                                 /* environment.                 */
  309.  
  310.   if state <> '' then do                                        /* If the state variable exists */
  311.  
  312.     rc = value('REMOTE_INSTALL_STATE',state,'OS2ENVIRONMENT')   /* Set the REMOTE_INSTALL_STATE */
  313.                                                                 /* environment variable to the  */
  314.                                                                 /* value of the state variable. */
  315.  
  316.     return YES                                                  /* return install=yes           */
  317.   end
  318.   else                                                          /* Otherwise,                   */
  319.     return NO                                                   /* return install=no            */
  320.  
  321.  
  322. /*************************************************************/
  323. BootDriveIsDiskette:
  324.  
  325.   if IsBootDriveRemovable() == 1 then do                        /* If the drive booted from is  */
  326.                                                                 /* a diskette drive, then set   */
  327.     rc2 = SetState(OVERALL_STATE+1)                             /* the OVERALL_STATE to the     */
  328.                                                                 /* requested value.             */
  329.     return 'YES'
  330.  
  331.   end
  332.  
  333.   else                                                          /* else the machine was booted  */
  334.                                                                 /* from the hardfile.           */
  335.     return 'NO'
  336.  
  337. /*************************************************************/
  338. BootDriveIsFixedDisk:
  339.  
  340.   if IsBootDriveRemovable() == 0 then do                        /* If the drive booted from is  */
  341.                                                                 /* a fixed disk, then set       */
  342.     rc2 = SetState(OVERALL_STATE+1)                             /* the OVERALL_STATE to the     */
  343.                                                                 /* requested value.             */
  344.     return 'YES'
  345.  
  346.   end
  347.  
  348.   else                                                          /* else the machine was booted  */
  349.                                                                 /* from a diskette.             */
  350.     return 'NO'
  351.  
  352. /*************************************************************/
  353. SetState:
  354.   parse arg new_state, proc_name, param_num, other
  355.  
  356.     if datatype(new_state, number) <> 1 then do                 /* If the new state requested is*/
  357.                                                                 /* not numeric, then log an     */
  358.       if proc_name <> '' then                                   /* error.                       */
  359.         LogMessage(63, proc_name, param_num, logfile)
  360.       else
  361.         LogMessage(63, 'SetState', 1, logfile)
  362.  
  363.       exit
  364.     end
  365.  
  366.     OVERALL_STATE = new_state                                   /* Set the OVERALL_STATE to the */
  367.                                                                 /* new state requested.         */
  368.  
  369.     rc = value(x.0.statevar, new_state, 'OS2ENVIRONMENT')       /* Save the OVERALL_STATE in the*/
  370.                                                                 /* environment.                 */
  371.     return 'NO_ERROR'
  372.  
  373.  
  374. /*************************************************************/
  375. SaveStates:
  376.  
  377.   do I=0 to NUM_INSTALL_PROGS by 1            /* Put the install states into the CONFIG.SYS,  */
  378.     if x.I.statevar <> '' then                /* if this action was unsuccessful, then exit.  */
  379.  
  380.       if PutStateVar(x.I.statevar, value(x.I.statevar,,'OS2ENVIRONMENT'),
  381.                      , configsys, logfile) <> 0 then exit
  382.   end
  383.  
  384.   return
  385.  
  386. /*************************************************************/
  387. RebootAndGotoState:
  388.   parse arg new_state, other
  389.  
  390.   rc2 = SetState(new_state, 'RebootAndGotoState', 1)           /* Set the state to go to in    */
  391.                                                                /* OVERALL_STATE.               */
  392.  
  393.   Call SaveStates                                              /* Save the environment vars    */
  394.  
  395.   Call Reboot                                                  /* Reboot the machine           */
  396.  
  397.   return
  398.  
  399.  
  400. /*************************************************************/
  401. CheckBoot:
  402.   if QUEUE_REBOOT <> 0 then do                                  /* If a reboot has been queued  */
  403.                                                                 /* by an install program ...    */
  404.  
  405.     if CALL_AGAIN == 0 then                                     /* If no install programs want  */
  406.                                                                 /* to be recalled ...           */
  407.  
  408.       rc = SetState(OVERALL_STATE+1)                            /* Increment the overall state  */
  409.                                                                 /* variable.                    */
  410.  
  411.     Call SaveStates                                             /* Save the environment vars    */
  412.  
  413.     Call Reboot                                                 /* Reboot the machine           */
  414.  
  415.   end
  416.  
  417.   else                                                          /* Otherwise, increment the     */
  418.     rc = SetState(OVERALL_STATE+1)                              /* state variable and go on.    */
  419.  
  420.   return
  421.  
  422.  
  423. /*************************************************************/
  424. Reboot:
  425.   bootdrive
  426.  
  427.   rc = value('OS2_SHELL', bootdrive || '\OS2\CMD.EXE', 'OS2ENVIRONMENT')
  428.   rc = value('COMSPEC',   bootdrive || '\OS2\CMD.EXE', 'OS2ENVIRONMENT')
  429.  
  430.   'cls'
  431.   rc = AskRemoveDiskIfFloppy()
  432.  
  433.   pathlen = length(exepath)                                     /* Get length of exepath        */
  434.   posslash = lastpos("\",strip(exepath))                        /* Determine the last occurcnce */
  435.                                                                 /*   of '\' in exepath          */
  436.  
  437.   if posslash = pathlen then                                    /* If '\' is the last character */
  438.  
  439.     cmdline = exepath || 'SETBOOT /IBD:' || bootdrive           /* Then append 'SETBOOT'        */
  440.  
  441.   else
  442.  
  443.     cmdline = exepath || '\SETBOOT /IBD:' || bootdrive          /* Else append '\SETBOOT'       */
  444.  
  445.   LogMessage(74, '', '', logfile)                               /* Log a message indicating     */
  446.                                                                 /* reboot.                      */
  447.   cmdline
  448.  
  449.   LogMessage(73, 'SETBOOT', '', logfile)                        /* If the code gets to here, the*/
  450.                                                                 /* reboot failed.  Log a message*/
  451.   exit                                                          /* and exit.                    */
  452.  
  453.   return
  454.  
  455.  
  456. /*************************************************************/
  457. AddDLLFunctions:
  458.   Call RxFuncAdd 'ProcessReturnCode',     'CASAGENT', 'PROCESSRETURNCODE'
  459.   Call RxFuncAdd 'DetermineResponseFile', 'CASAGENT', 'DETERMINERESPONSEFILE'
  460.   Call RxFuncAdd 'PutStateVar',           'CASAGENT', 'PUTSTATEVAR'
  461.   Call RxFuncAdd 'LogMessage',            'CASAGENT', 'GETANDLOGMESSAGE'
  462.   Call RxFuncAdd 'AskRemoveDiskIfFloppy', 'CASAGENT', 'ASKREMOVEDISKIFFLOPPY'
  463.   Call RxFuncAdd 'IsBootDriveRemovable',  'CASAGENT', 'ISBOOTDRIVEREMOVABLE'
  464.  
  465.   return
  466.