home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / diskfp.zip / diskfp.cmd next >
OS/2 REXX Batch file  |  1997-03-01  |  9KB  |  232 lines

  1. /* diskfp.CMD to loaddskf and xcopy fixpack disks */
  2. /*                                                */
  3. /* This command file written by Trevor Hemsley    */
  4. /* 1st March 1997. All responsibility for the     */
  5. /* use of this command file lies with the user    */
  6. /* of it. No guarantee is made that it will work  */
  7. /* correctly. I am not responsible for any damage */
  8. /* that may be caused to your system by use of    */
  9. /* this command file nor by any fixpack you may   */
  10. /* apply to your system using it.                 */
  11. /*                                                */
  12. /*                                                */
  13.  Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  14.  Call SysLoadFuncs
  15.  parse upper arg src dest        /* get source and target dirs passed */
  16.  
  17.  if src = "" then                /* if no source specified */ 
  18.     do
  19.     say "No source specified"    /* say so */
  20.     call syntax                  /* then get out */ 
  21.     end
  22.  
  23.  if dest = "" then               /* if no destination specified */
  24.     do
  25.     say "No destination specifed" /* say so */
  26.     call syntax                   /* get out */
  27.     end
  28.  
  29.  say "Enter the drive letter of the OS/2 boot partition you want serviced"
  30.  pull answer
  31.  if length(answer) ¬= 1 then      /* validity check the drive letter given */
  32.     do
  33.     say "Drive letter invalid"
  34.     exit
  35.     end
  36.  else
  37.     do
  38.     map = SysDriveMap(answer, "LOCAL") /* and check it exists */
  39.     if substr(map, 1, 1) ¬= answer then /* if not first character of return */
  40.        do
  41.        say "Invalid drive specified"
  42.        exit
  43.        end
  44.     syslevelfile = answer || ":\os2\install\syslevel.os2" /* set up filename */
  45.     driveletter = answer                  /* save the drive letter for later */
  46.     rrc = SysFileTree(syslevelfile, syslf., "FO")   /* check syslevel exists */
  47.     if syslf.0 = 0 then                             /* if not */
  48.        do
  49.        say "File "syslevelfile" does not exist"
  50.        exit
  51.        end
  52.     end
  53.  
  54.  say "Enter the directory name where the archive files will be placed"
  55.  say "Example - C:\ARCHOS2 (this will be the default). There must be"
  56.  say "enough space on this drive to contain all the files that are to"
  57.  say "to be updated. A fatal error could occur if there is not enough"
  58.  say "space."
  59.  arcgiven = "N"
  60.  do until arcOK = "Y"
  61.  pull answer
  62.  if answer = "" then
  63.     do
  64.     answer = "C:\ARCHOS2"
  65.     end
  66.  arc = answer
  67.  rrc = SysFileTree(arc, arcdir., "D")   /* check directory exists */
  68.  if arcdir.0 = 0 then                             /* if not */
  69.     do
  70.     rc = SysMkDir(arc)
  71.     if rc = 0 then
  72.        do
  73.        curdir = DIRECTORY()
  74.        dir = DIRECTORY(arc)
  75.        "@CD .."
  76.        newdir = DIRECTORY(curdir)
  77.        drive = substr(dir, 1, 2)
  78.        driveinfo = SysDriveInfo(drive)
  79.        freespace = WORD(driveinfo, 2)
  80.        if freespace < 20000000 then
  81.           do
  82.           say "Not enough freespace on drive "drive" for archive files"
  83.           rrc = SysRmDir(arc)
  84.           say "Please respecify"
  85.           end
  86.        else
  87.           do
  88.           arcOK = "Y"
  89.           end
  90.        end
  91.     else
  92.        do
  93.        say "Error "rc" making directory "arc
  94.        say "Please respecify"
  95.        end
  96.     end
  97.  else
  98.     do /* if directory already exists */
  99.     say "Sorry, that directory already exists"
  100.     end
  101.  end
  102.     
  103.  say "Please make sure there is a 1.44Mb diskette in drive A:"
  104.  say "This diskette will be overwritten, is this OK - Y/N"
  105.  pull answer
  106.  if answer ¬= "Y" then exit
  107.  
  108.  rrc = SysFileTree(dest, files., "D")
  109.  if files.0 = 0 then
  110.     do
  111.     say "Destination directory "dest" does not exist, create it?"
  112.     pull answer
  113.     if answer ¬= "Y" then exit
  114.     "@MD "dest
  115.     end
  116.  else
  117.     do
  118.     say "Directory "dest" exists already, use it anyway?"
  119.     pull answer
  120.     if answer ¬= "Y" then exit
  121.     end
  122.  
  123.  filemask = src || "\xr_m*.?DK"         /* set up filemask for fixpack diskette images */
  124.  rrc = SysFileTree(filemask, srcdisk., "FO")   /* check in source dir for them */
  125.  if srcdisk.0 = 0 then                         /* if none there */
  126.     do
  127.     say "Source directory is empty"
  128.     exit
  129.     end
  130.  else
  131.     do i = 1 to srcdisk.0 by 1         /* otherwise loop for # of files */
  132.     "@loaddskf "srcdisk.i" A: /F /Y"    /* loading them up */
  133.     if RC ¬= 0 then
  134.        do
  135.        say "LOADDSKF returned a non-zero return code. Continue Y/N?"
  136.        pull answer
  137.        if answer ¬= "Y" then exit
  138.        end
  139.     say ""
  140.     say "XCOPY contents of "srcdisk.i" in progress"
  141.     "@XCOPY A:\ "dest" /h/o/t/s/e/r/v 1>nul"
  142.     if RC ¬= 0 then
  143.        do
  144.        say "XCOPY returned a non-zero return code. Continue Y/N?"
  145.        pull answer
  146.        if answer ¬= "Y" then exit
  147.        end   
  148.     end
  149.  
  150.  filemask = src || "\csf*.2DK"         /* set up filemask for kicker diskette image */
  151.  rrc = SysFileTree(filemask, srcdisk., "FO")   /* check in source dir for them */
  152.  if srcdisk.0 = 0 then                         /* if none there */
  153.     do until answer = "N"
  154.     say ""
  155.     say "Kicker diskette 2 was not found in source directory"
  156.     say "Copy the file CSFBOOT.2DK to "src" then press enter"
  157.     pull answer
  158.     rrc = SysFileTree(filemask, srcdisk., "FO")   /* check in source dir for them */
  159.     if srcdisk.0 = 0 then                         /* if none there */
  160.        do
  161.        say "Sorry, you still didn't get it right"
  162.        end
  163.     else
  164.        do
  165.        answer = "N"
  166.        end
  167.     end
  168.  do i = 1 to srcdisk.0 by 1         /* otherwise loop for # of files */
  169.  "@loaddskf "srcdisk.i" A: /F /Y"    /* loading them up */
  170.  if RC ¬= 0 then
  171.     do
  172.     say "LOADDSKF returned a non-zero return code. Continue Y/N?"
  173.     pull answer
  174.     if answer ¬= "Y" then exit
  175.     end
  176.  say ""
  177.  say "XCOPY contents of "srcdisk.i" in progress" 
  178.  say "Expect a SYS1186 error for EA DATA. SF on this copy. This is OK"
  179.  "@XCOPY A:\ "dest" /h/o/t/s/e/r/v 1>nul"
  180.  /* no error checking on this one as CSF disk has an EA DATA. SF on it */
  181.  /* and this causes XCOPY to give a non-zero RC */
  182.  end
  183.  
  184. /* set up the response file to apply the fixpack to drive given */
  185.  "@echo :LOGFILE "driveletter":\OS2\INSTALL\SERVICE.LOG >"dest"\apply.fil"
  186.  "@echo :FLAGS REPLACE_PROTECTED REPLACE_NEWER >>"dest"\apply.fil"
  187.  "@echo :SOURCE "dest" >>"dest"\apply.fil"
  188.  "@echo :SERVICE >>"dest"\apply.fil"
  189.  "@echo :SYSLEVEL "syslevelfile" >>"dest"\apply.fil"
  190.  "@echo :ARCHIVE "dir" >>"dest"\apply.fil"
  191.  
  192. /* set up response file to back out fixpack from the drive specified */
  193.  "@echo :LOGFILE "driveletter":\OS2\INSTALL\SERVICE.LOG >"dest"\backout.fil"
  194.  "@echo :TARGET ARCHIVE >>"dest"\backout.fil"
  195.  "@echo :BACKOUT >>"dest"\backout.fil"
  196.  "@echo :SYSLEVEL "driveletter":\OS2\INSTALL\SYSLEVEL.OS2 >>"dest"\backout.fil"
  197.  
  198. /* set up command files to apply and backout fixpack */
  199.  "@echo @echo Hit Ctrl-Break when you see the prompt to hit Ctrl-Alt-Del >"dest"\apply.cmd"
  200.  "@echo @pause>>"dest"\apply.cmd"
  201.  "@echo fservice /s:"dest" /r:"dest"\apply.fil /L1:"driveletter":\os2\install\service.log >>"dest"\apply.cmd"
  202.  "@echo @echo Hit Ctrl-Break when you see the prompt to hit Ctrl-Alt-Del>"dest"\backout.cmd"
  203.  "@echo @pause>>"dest"\backout.cmd"
  204.  "@echo fservice /s:"dest" /r:"dest"\backout.fil /L1:"driveletter":\os2\install\service.log >>"dest"\backout.cmd"
  205.  
  206.  say " "
  207.  say "Now reboot to a command line using Alt+F1 option F2 and change to the directory "dest
  208.  say 'and issue the command "APPLY" to apply the fixpack or "BACKOUT" to back it out.'
  209.  say " "
  210.  say "Please make sure that you have previously read the various README files that"
  211.  say "are now in the directory "dest" as these may contain important information"
  212.  say "from IBM about problems that you may encounter after applying this fixpack."
  213. exit
  214.  
  215. syntax: say ""
  216. say "Syntax of command is:"
  217. say ""
  218. say "DISKFP source_dir destination_dir"
  219. say " "
  220. say "where source_dir is a directory containing the diskette image files"
  221. say "             for the fixpack this should contain all of the fixpack"
  222. say "             diskette images and the second diskette image of the"
  223. say "             kicker diskettes (usually csfboot.2dk). No other files"
  224. say "             should be present in this directory."
  225. say ""
  226. say "and"
  227. say "      destination_dir is the directory name where the fixpack files"
  228. say "             ready to be applied to the system will be copied. This"
  229. say "             should be a new directory name not one that presently"
  230. say "             exists."
  231. exit
  232.