home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / patches / tcpip121 / pmx / installx.cmd next >
Encoding:
Text File  |  1992-07-15  |  4.8 KB  |  145 lines

  1. /*
  2.  * Installx.cmd installs the PMX server updates from disk or diskette.
  3.  * This must be run from the disk or diskette e.g. "a:installx".
  4.  * This version checks that XFILES environment variable has been
  5.  * set up properly and both TCPBASE and TCPPMX have already been installed.
  6.  */
  7. ENV = 'OS2ENVIRONMENT'
  8. XFILES = VALUE('XFILES',,ENV)
  9. if XFILES = '' then
  10.     do
  11.     say ""
  12.     say "WARNING!"
  13.     say "You do NOT have the environment variable XFILES defined!"
  14.     say "You should have already installed the OS/2 TCP/IP 1.2 base and"
  15.     say "the X Window System option.  This update package only provides"
  16.     say "changes and additions to the already installed product."
  17.     say "Installation will not continue."
  18.     say ""
  19.     exit 1
  20.     end
  21. BASE=filespec("drive",XFILES)||filespec("path",XFILES)
  22. if substr(BASE, length(BASE), 1) = '\' then
  23.     BASE = substr(BASE, 1, length(BASE) - 1)
  24. call dircheck XFILES
  25. call dircheck BASE
  26. BINDIR = dircheck(BASE'\BIN')
  27. call dircheck BASE'\DLL'
  28. call dircheck BASE'\HELP'
  29. call dircheck BASE'\X11\MISC'
  30. call dircheck BASE'\X11\75DPI'
  31. call dircheck BASE'\X11\DEFAULTS'
  32. cmdloc = getinstalldir()
  33. call runcheckanderase BASE'\BIN\PMX.EXE'
  34. call runcheckanderase BASE'\DLL\PMXHKDLL.DLL'
  35. call runcheckanderase BASE'\DLL\PMXRES.DLL'
  36. call backupfile BASE'\BIN\XINIT.CMD' 'XINITBAK.CMD'
  37. /* now updating the CSD level info */
  38. 'attrib' BASE'\syslevel.pmx -r'
  39. 'copy' cmdloc'syslevel.pmx' BASE'\syslevel.pmx'
  40. 'attrib' BASE'\syslevel.pmx +r'
  41. /* currentdir = directory() */
  42. /* call directory BINDIR */
  43. say ""
  44. say "Now loading from the update files."
  45. say ""
  46. cmdloc'loadram2 'cmdloc'pmxmain.fls 'BASE' /sr /c /d'
  47. /* call directory(currentdir) */
  48. say ""
  49. say "Loading from the update files is complete."
  50. say ""
  51. exit 0
  52.  
  53.  
  54. dircheck: procedure
  55. arg dir
  56. curdir = directory()
  57. newdir = directory(dir)
  58. call directory(curdir)
  59. if newdir \= '' then
  60.     do
  61.     return newdir
  62.     end
  63. else
  64.     do
  65.     say ""
  66.     say "Directory '"dir"' could not be found even though the XFILES"
  67.     say "environment variable is defined as '"XFILES"'!"
  68.     say "The directory was supposed to be created by ICAT when the TCP/IP 1.2.1"
  69.     say "base and X Window System 1.2.1 option were installed."
  70.     say "Installation is terminated!"
  71.     exit 1
  72.     end
  73.  
  74. getinstalldir: procedure
  75. parse source system calltype cmdloc
  76. cmddir = filespec("drive",cmdloc)||filespec("path",cmdloc)
  77. return cmddir
  78.  
  79. runcheckanderase: procedure
  80. arg dir
  81. progname = STREAM(dir, 'C', 'QUERY EXISTS')
  82. if progname \= '' then do
  83.     'ERASE' progname
  84.     if STREAM(dir, 'C', 'QUERY EXISTS') \= '' then do
  85.         say ""
  86.         say "The file '"progname"' could not be erased."
  87.         say "You probably have not stopped the PMX server."
  88.         say "Please do so before you install this update."
  89.         say ""
  90.         exit 1
  91.         end
  92.     end
  93. return
  94.  
  95. /* typical call: call backupfile BASE'\BIN\XINIT.CMD' 'XINITBAK.CMD' */
  96. backupfile: procedure
  97. arg oldfile firstbackname
  98. backname = firstbackname
  99. if STREAM(oldfile, "C", "QUERY EXISTS") \= '' then do
  100.     oldloc = filespec("drive",oldfile)||filespec("path", oldfile)
  101.     do forever
  102.         backfile = oldloc||backname
  103.         if STREAM(backfile, "C", "QUERY EXISTS") \= '' then do
  104.             say "A new version of '"oldfile"' will be loaded. For backup,"
  105.             say "the old version would have been renamed to '"backname"'."
  106.             say "However, the backup file '"backfile"' already exists."
  107.             backname = getnewbackname(oldfile)
  108.             if backname = '' then
  109.                 return  /* no backup wanted, old file will be replaced */
  110.             iterate
  111.             end /* if */
  112.         else
  113.             do
  114.             say "A new version of '"oldfile"' will be loaded. For backup,"
  115.             say "the old version will be renamed to '"backname"'."
  116.             'rename' oldfile backname
  117.             if STREAM(backfile, "C", "QUERY EXISTS") \= '' then do
  118.                 'PAUSE'
  119.                 leave
  120.                 end
  121.             say "Error! Renaming '"oldfile"' to '"backname"' did not work!"
  122.             say "RC="rc 'from the rename command.'
  123.             exit 1
  124.             end /* else */
  125.         end /* do forever */
  126.     end /* if */
  127. return
  128.  
  129. /* typical call
  130.     backname = getnewbackname(oldfile)
  131.  */
  132. getnewbackname: procedure
  133. arg oldfile
  134. do forever
  135.     say "Please enter a new name to rename '"oldfile"' to;"
  136.     say "or else press Enter without any name, if you do not want a backup;"
  137.     say "or else press ctrl-c and then Enter if you want to end the update."
  138.     pull enteredfilename
  139.     newfilename = filespec("name", enteredfilename)
  140.     if newfilename = enteredfilename then
  141.         return newfilename
  142.     say "Try again, please. You should have entered a simple filename."
  143.     say ''
  144.     end /* do forever */
  145.