home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 29 Fixes_o / 29-Fixes_o.zip / ap8152b1.dsk / RPLDOS7.ZIP / RPLDOS7.CMD
OS/2 REXX Batch file  |  1995-03-03  |  12KB  |  395 lines

  1. /* RPLDOS7.CMD                                                       */
  2. /* This procedure installs the IBM PC DOS 7.0                        */
  3. /* for LAN Server remote IPL.                                        */
  4. /*                                                                   */
  5. /* Copyright: (C) Copyright IBM Corp. 1995                           */
  6. /* DPD                                                               */
  7.  
  8. /* load REXX utilities, requires OS/2 2.0 or above */
  9. Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  10. Call SysLoadFuncs
  11.  
  12. nummsglines = 0
  13. drive = 'A'
  14. numdosdiskettes = 5
  15. nuloutput = ' 1>nul 2>nul'
  16. unpackflags = ' /V /P /C'
  17.  
  18. /* Process any command line parameters, none required - all optional */
  19. Parse Arg  parm.1 parm.2 parm.3 .
  20. Call Get_Input_Parameters
  21. If result <> 0 Then Exit
  22.  
  23. /* determine path to CONFIG.SYS and \IBMLAN tree */
  24. Call Find_Path_Info
  25. If result <> 0 Then Exit
  26.  
  27. /* check for PROTECTONLY=NO and BASEDEV=XDFLOPPY.FLT in CONFIG.SYS  */
  28. Call Check_CONFIG_SYS
  29. If result <> 0 Then Exit
  30.  
  31. /* Get the version of LAN Server installed on the Remote IPL server. */
  32. Call Get_LAN_Server_Version
  33. If result <> 0 Then Exit
  34.  
  35. Call Verify_Server_Started
  36. If result <> 0 Then return error_access_denied_in_use
  37.  
  38. Call Verify_Admin_Privilege
  39. If result <> 0 Then return error_access_denied_in_use
  40.  
  41. /* verify existance of \IBMLAN\INSTALL\RIB2.EXE file */
  42. Call Get_RIB2_EXE
  43. If result <> 0 Then Exit
  44.  
  45. /* copy all files from the DOS diskettes */
  46. Call Copy_DOS_disks
  47. If result <> 0 Then Exit
  48.  
  49. /* find DOS bundle files in \IBMLAN\DOSLAN\DOS and build BAT file */
  50. Call Build_BAT_file
  51. If result <> 0 Then Exit
  52.  
  53. /* launch DOS box and call d:\IBMLAN\DOSLAN\DOS\UNPACK7.BAT */
  54. Call Run_BAT_file
  55. If result <> 0 Then Exit
  56.  
  57. /* set Access Control Profiles for new subdirs under IBMLAN\DOSLAN\DOS */
  58. Call Set_ACLs
  59. If result <> 0 Then Exit
  60.  
  61. Say ' '
  62. Say 'Installation of IBM PC DOS 7.0 for remote IPL is complete.'
  63. Say ' '
  64. Say 'NOTE:  Remote IPL DOS images file must be rebuilt to include this DOS version.'
  65.  
  66. return
  67. /* end of main function */
  68.  
  69.  
  70. /* find path to CONFIG.SYS and \IBMLAN directory tree */
  71. Find_Path_info:
  72.    os2path = value('PATH',,'OS2ENVIRONMENT')
  73.  
  74.    ibmlanp = pos(':\IBMLAN', translate(os2path))
  75.    if ibmlanp = 0 Then Do
  76.       Say 'Could not determine location of \IBMLAN directory.'
  77.       Beep(100,500)
  78.       return 4
  79.    end
  80.  
  81.    os2p = pos(':\OS2', translate(os2path))
  82.    if os2p = 0 Then Do
  83.       Say 'Could not determine OS/2 boot drive letter.'
  84.       Beep(100,500)
  85.       return 4
  86.    end
  87.  
  88.    /* set up paths required for this program */
  89.    landrv      = substr(os2path, ibmlanp-1, 1)
  90.    lanpath     = landrv':\IBMLAN'
  91.    imagespath  = lanpath'\DCDB\IMAGES'
  92.    dospath     = lanpath'\DOSLAN\DOS'
  93.    installpath = lanpath'\INSTALL'
  94.    rib2path    = installpath'\RIB2.EXE'
  95.    pkunzippath = installpath'\PKUNZIP2.EXE'
  96.    unpackpath  = dospath'\UNPACK2'
  97.    batfile     = dospath'\UNPACK7.BAT'
  98.  
  99.    os2drv      = substr(os2path, os2p-1, 1)
  100.    configsys   = os2drv':\CONFIG.SYS'
  101.  
  102. return 0
  103.  
  104.  
  105. /* check for PROTECTONLY=NO and BASEDEV=XDFLOPPY.FLT in CONFIG.SYS  */
  106. Check_CONFIG_SYS:
  107.  
  108.    retf = 0
  109.    protectonly_found = FALSE
  110.    xdfloppy_found = FALSE
  111.  
  112.    do until lines(configsys) = 0
  113.       data = linein(configsys)
  114.       /* read CONFIG.SYS looking for the PROTECTONLY entry */
  115.       protectonly = pos('PROTECTONLY=NO', translate(data))
  116.       /* read CONFIG.SYS looking for the BASEDEV=XDFLOPPY entry */
  117.       basedev = pos('XDFLOPPY.FLT', translate(data))
  118.       if protectonly <> 0 then do
  119.          protectonly_found = TRUE;
  120.       end
  121.       if basedev <> 0 then do
  122.          xdfloppy_found = TRUE;
  123.       end
  124.       if protectonly_found = TRUE & xdfloppy_found = TRUE then do
  125.          leave
  126.       end
  127.    end
  128.    Call stream configsys,C,'close'
  129.  
  130.    if protectonly_found = FALSE then do
  131.       Say 'VDM support was not found.'
  132.       Beep(100,500)
  133.       retf = 4
  134.    end
  135.  
  136.    if xdfloppy_found = FALSE then do
  137.       Say 'Support for XDF formatted diskettes was not found.'
  138.       Beep(100,500)
  139.       retf = 4
  140.    end
  141.  
  142. return retf
  143.  
  144.  
  145. /* Get the version of LAN Server installed on the Remote IPL server. */
  146. Get_LAN_Server_Version:
  147.    /* Read the first 60 bytes of SYSLEVEL.SRV and check the current server level*/
  148.    filename = lanpath'\SYSLEVEL.SRV'
  149.    syslevel = ''
  150.    /* read syslevel file, try to get it with a single linein call */
  151.    syslevel = Linein(filename)
  152.    Call Lineout filename   /* close file */
  153.    If Length(syslevel) < 60 Then Do
  154.       /* single linein did not get enought of file, get syslevel */
  155.       /* character at a time */
  156.       syslevel = ''
  157.       Do i = 1 to 60
  158.          syslevel = syslevel || charin(filename)
  159.       end
  160.       Call Charout filename
  161.    end
  162.    verp = pos('IP', syslevel)
  163.    If verp <> 0 Then LS_version = substr(syslevel, verp+3, 4)
  164.    If LS_version = '' Then Do
  165.       Say 'Could not determine IBM LAN Server version.'
  166.       Beep(100,500)
  167.       return 4
  168.    end
  169.    Else do
  170.       If substr(LS_version, 1, 1) = '8' Then LS_Version_4 = TRUE
  171.       Else LS_Version_4 = FALSE
  172.    end
  173.  
  174. return 0
  175.  
  176.  
  177. /* verify server started, must set ACL's on new directories */
  178. Verify_Server_Started:
  179.    '@NET CONFIG SERVER 1>NUL'
  180.    If rc <> 0 Then Do
  181.       Say 'The SERVER service must be started to set Access Control Profiles.'
  182.       Beep(100,500)
  183.       return 4
  184.    end
  185. return 0
  186.  
  187.  
  188. /* verify administrator privilege, must set ACL's on new directories */
  189. Verify_Admin_Privilege:
  190.    /* issue NET SESS which requires administrator privilege */
  191.    '@NET SESS 1>NUL'
  192.    If rc <> 0 Then Do
  193.       Say 'You must be logged on with Administrator privilege to set Access Control Profiles.'
  194.       Beep(100,500)
  195.       return 4
  196.    end
  197. return 0
  198.  
  199.  
  200. /* Copy required LAN Server installation files if not found */
  201. Get_RIB2_EXE:
  202.  
  203.    If stream(rib2path, 'C', 'QUERY EXISTS') = '' | stream(pkunzippath, 'C', 'QUERY EXISTS') = ''  Then Do
  204.       /* make sure IBMLAN\INSTALL directory exists */
  205.       Call SysMkDir installpath
  206.       /* prompt for SERVER 1 diskette */
  207.       Say 'Insert LAN Server diskette SERVER 1 into drive' drive
  208.       Beep(1000,300)
  209.       Pull dummy .
  210.       /* copy PKUNZIP2.EXE and then unzip RIB2.EXE from SRVRINST.ZIP */
  211.       '@copy ' || drive || ':\PKUNZIP2.EXE ' || installpath || nuloutput
  212.       '@' || pkunzippath || ' -o ' || drive || ':\SRVRINST.ZIP ' || installpath || ' IBMLAN\INSTALL\RIB2.EXE' || nuloutput
  213.  
  214.    end
  215.  
  216. return 0
  217.  
  218.  
  219. /* copy all files from the DOS diskettes */
  220. Copy_DOS_disks:
  221.  
  222.    Do i = 1 to numdosdiskettes
  223.       /* process DOS diskette i */
  224.       diskettevalid = 0
  225.       Do while diskettevalid = 0
  226.          srcfile = drive || ':'
  227.          Say 'Insert IBM PC DOS 7.0 diskette' i 'into drive' drive
  228.          Beep(1000,300)
  229.          Pull dummy .
  230.          driveinfo = SysDriveInfo(srcfile)
  231.          drivelabel = word(driveinfo, 4) || ' ' || word(driveinfo, 5)
  232.          If drivelabel = ('DISK ' || i) Then diskettevalid = 1
  233.       end
  234.  
  235.       Say 'Copying files . . .'
  236.  
  237.       '@copy ' || drive || ':\*.* ' || dospath || nuloutput
  238.  
  239.       If i = 1 Then Do
  240.          /* call RIB2.EXE to get system files and boot sector */
  241.          '@' || rib2path || ' ' || imagespath || nuloutput
  242.       end
  243.  
  244.       Say ' '
  245.  
  246.    end
  247. return 0
  248.  
  249.  
  250. /* find DOS bundle files in \IBMLAN\DOSLAN\DOS and build BAT file */
  251. Build_BAT_File:
  252.  
  253.    /* get list of all DOS bundle files in \IBMLAN\DOSLAN\DOS directory */
  254.    srcdir = dospath || '\*.'
  255.    Call SysFileTree srcdir, filelist, 'FO'
  256.  
  257.    If filelist.0 <> 0 Then Do
  258.       /* build \IBMLAN\DOSLAN\DOS\UNPACK7.BAT file */
  259.  
  260.       Call stream batfile,'c','open write'
  261.  
  262.       /* put REM statements in BAT file */
  263.       Call lineout batfile, 'REM ****************************************************************'
  264.       Call lineout batfile, 'REM *  This file is used by LAN Server Installation/Configuration  *'
  265.       Call lineout batfile, 'REM *  Program(LANINST) to decompress DOS files for remote IPL.    *'
  266.       Call lineout batfile, 'REM ****************************************************************'
  267.       /* put APPEND /PATH:OFF in BAT file to prevent overwrite of OS/2 files */
  268.       Call lineout batfile, 'APPEND /PATH:OFF'
  269.  
  270.       Do j = 1 to filelist.0
  271.  
  272.          /*build unpack bundle file lines into the BAT file */
  273.          bundlefile = translate(filelist.j)
  274.          batfilestring = unpackpath || ' ' || bundlefile || ' ' || dospath || unpackflags
  275.          Call lineout batfile, batfilestring
  276.  
  277.       end /* end of record scan */
  278.  
  279.       Call lineout batfile, 'EXIT'
  280.  
  281.       /* close the BAT file */
  282.       Call stream batfile,'c','close'
  283.  
  284.    end
  285.    else Do
  286.       Say 'DOS bundle files could not be found.'
  287.       Beep(100,500)
  288.       return 4
  289.    end
  290. return 0
  291.  
  292.  
  293. /* launch DOS box and call d:\IBMLAN\DOSLAN\DOS\UNPACK7.BAT */
  294. Run_BAT_file:
  295.  
  296.       Say 'Starting a DOS session to decompress DOS bundle files . . .'
  297.  
  298.       /* start a VDM to run UNPACK7.BAT file to decompress bundles */
  299.       '@' || batfile
  300.  
  301. return 0
  302.  
  303.  
  304. /* must set ACL's on new directories under \IBMLAN\DOSLAN\DOS */
  305. Set_ACLs:
  306.  
  307.    Say ' '
  308.    Say 'Creating Access Control Profiles for RPLGROUP . . .'
  309.  
  310.    '@NET ACCESS ' || dospath || ' /ADD ' || 'RPLGROUP:RX 1>NUL 2>' || retmsg
  311.    If rc <> 0 Then Do
  312.       data = linein(retmsg)
  313.       If substr(data, 1, 3) = 'NET' Then Do
  314.          errornum = substr(data, 4, 4)
  315.          /* error NET2225 is OK, access controls already exist */
  316.          If errornum <> '2225' Then Do
  317.             Say 'Error NET' errornum 'occurred while creating Access Control Profiles.'
  318.             Beep(100,500)
  319.             return 4
  320.          end
  321.       end
  322.       Else do
  323.          errornum = substr(data, 4, 4)
  324.          Say 'Error' errornum 'occurred while creating Access Control Profiles.'
  325.          Beep(100,500)
  326.          return 4
  327.       end
  328.    end
  329.  
  330.    /* apply access controls to all new subdirs under \IBMLAN\DOSLAN\DOS */
  331.  
  332.    If LS_Version_4 = TRUE Then
  333.       '@NET ACCESS ' || dospath || ' /APPLY  1>NUL 2>' || retmsg
  334.    Else
  335.  
  336.  
  337.    If rc <> 0 Then Do
  338.       data = linein(retmsg)
  339.       If substr(data, 1, 3) = 'NET' Then Do
  340.          errornum = substr(data, 4, 4)
  341.          Say 'Error NET' errornum 'occurred while creating Access Control Profiles.'
  342.          Beep(100,500)
  343.          return 4
  344.       end
  345.       Else do
  346.          errornum = substr(data, 4, 4)
  347.          Say 'Error' errornum 'occurred while creating Access Control Profiles.'
  348.          Beep(100,500)
  349.          return 4
  350.       end
  351.    end
  352. return 0
  353.  
  354.  
  355. /* Process any command line parameters, none required - all optional */
  356. Get_Input_Parameters:
  357.    Do i = 1 to 3
  358.       If parm.i = '' Then Leave
  359.       parmtype = translate(substr(parm.i,1,2))
  360.       select
  361.          when parmtype = '/?' Then Call Display_Syntax
  362.  
  363.          when parmtype = '?'  Then Call Display_Syntax
  364.  
  365.          when parmtype = '/D' Then Do
  366.             if substr(parm.i, 3, 1) = ':' Then drive = substr(parm.i, 4)
  367.             else drive = substr(parm.i, 3)
  368.             drive = translate(drive)
  369.          end
  370.  
  371.          when parmtype = '/N' Then Do
  372.             if substr(parm.i, 3, 1) = ':' Then numdosdiskettes = substr(parm.i, 4)
  373.             else numdosdiskettes = substr(parm.i, 3)
  374.          end
  375.  
  376.          otherwise Do
  377.            Say parm.i 'is not a valid option.'
  378.            Beep(100,500)
  379.            return 4
  380.          end
  381.       end
  382.    end
  383. return 0
  384.  
  385.  
  386. /* Display the command syntax for this program */
  387. Display_Syntax:
  388.      Say ' '
  389.      Say 'RPLDOS7  [/D:source_drive_letter]  [/N:number_dos_diskettes]'
  390.      Say '         default source_drive_letter  = A:'
  391.      Say '         default number_dos_diskettes = 5'
  392.      Say ' '
  393.      exit 0
  394.  
  395.