home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 29 Fixes_o / 29-Fixes_o.zip / umf21004.zip / INSTALL.CMD < prev    next >
OS/2 REXX Batch file  |  1996-04-09  |  13KB  |  330 lines

  1. /* ------------------------------------------------------------------------ */
  2. /* INSTALL.CMD - Install UltiMail from Diskettes                            */
  3. /* ------------------------------------------------------------------------ */
  4. /*                                                                          */
  5. /* Version: 1.00                                                            */
  6. /*                                                                          */
  7. /* ------------------------------------------------------------------------ */
  8. CALL RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  9. CALL SysLoadFuncs
  10.  
  11. /* test for TCP/IP home directory */
  12. TCP_Program = ''
  13. if TCP_Program = '' then TCP_Program = SysSearchPath("PATH",'FTP.EXE')
  14. if TCP_Program = '' then do
  15.   say "Fatal Error!!  I cannot find the TCPIP\bin directory!  Install terminated."
  16.   /* exit 1 */
  17. end
  18.  
  19. tcpipBin=FileSpec("Drive", TCP_Program) || FileSpec("Path", TCP_Program)
  20. if right(tcpipBin,1) <> "\" then tcpipBin = tcpipBin || "\"
  21.  
  22. TargetPath = LEFT(tcpipBin, LASTPOS('\',tcpipBin)-1)
  23. TargetPath = LEFT(TargetPath, LASTPOS('\',TargetPath))
  24.  
  25. parse source os2 com fullpath .
  26. Drive = FileSpec( "Drive", fullpath )
  27. Path  = FileSpec( "Path", fullpath )
  28. if length(Path) <> 1 then do
  29.   Path=substr(Path,1,length(path)-1)
  30. end
  31. SourcePath = Drive||Path||"."
  32. OrigDir = Directory()
  33. call Directory SourcePath
  34.  
  35. CurDir = DIRECTORY();
  36. RespPath = CurDir
  37. IF RIGHT(RespPath, 1) <> '\' THEN RespPath = RespPath || '\'
  38. RespFile = RespPath'default.rsp'
  39. RespOpt='/R:'RespFile
  40. CurDrive=FileSpec("Drive",CurDir)
  41. if CurDrive='A:'|CurDrive='B:' then do
  42.   Source=''
  43.   RespOpt=''
  44.   TestLanLk = 0
  45. end; else do
  46.   Source='/s:'CurDir
  47.   TestLanLk = 1
  48. end  /* Do */
  49. umail=SysSearchPath('PATH','UMAIL.EXE')
  50. if umail <> '' then do
  51.   td=FileSpec("Drive",umail)
  52.   tp=FileSpec("Path",umail)
  53.   Target='/t:'td''tp
  54.   Attend='N'
  55. end; else do
  56.   Attend='Y'
  57.   Target=''
  58. end  /* Do */
  59.  
  60. /* removed attended variable setting since unattended mode does not work!!!
  61. if RespOpt <> '' then do
  62.   n = VALUE('ATTENDED', attend,'OS2ENVIRONMENT')
  63. end
  64. */
  65.  
  66. /* test the Lan Locked device drivers */
  67. IF TestLanLk = 1 THEN DO
  68.   /* we are running on a 'hard drive', create the LANLK directory */
  69.   ADDRESS CMD '@md LANLK 1>nul 2>&1'
  70.   ADDRESS CMD '@copy IBMLANLK.EXE LANLK 1>nul 2>&1'
  71.   ADDRESS CMD '@copy IBMLANLK.SYS LANLK 1>nul 2>&1'
  72. END
  73.  
  74. lf=d2c(10) || d2c(13)
  75.  
  76. TitleError="UltiMail Lite Install Error"
  77. TitleWarning="UltiMail Lite Install Warning"
  78. TitleInformation="UltiMail Lite Install Information"
  79.  
  80. env='OS2ENVIRONMENT'
  81. etc = VALUE('ETC',,env)
  82. if etc='' then do
  83.   text='The ETC environment variable is not set.'lf
  84.   text=text'The UltiMail Install exit has not been run.'
  85.   n = RxMessageBox( text, TitleError, "OK", "ERROR" )
  86.   return 1
  87. end  /* Do */
  88.  
  89. if etc <> '' then do
  90.   /* copy the sendmail.uml file to the etc directory */
  91.   call ReplaceSendMailUML
  92.  
  93.   /* replace the sendmail.exe in the tcpip\bin directory */
  94.   OldSendmail = tcpipBin || "sendmail.exe"
  95.   NewSendmail = "sendmail.exe"
  96.   call SysFileTree OldSendmail, 'OldFileInfo', "FT"
  97.   call SysFileTree NewSendmail, 'NewFileInfo', "FT"
  98.   if OldFileInfo.0 > 0
  99.     then Old_sendmail_date = word(OldFileInfo.1,1);
  100.     else Old_sendmail_date = '0';    /* Old version does not exist! */
  101.   if NewFileInfo.0 > 0
  102.     then New_sendmail_date = word(NewFileInfo.1,1);
  103.     else New_sendmail_date = '0';    /* New version does not exist! */
  104.   if Old_sendmail_date < New_sendmail_date then do
  105.     ADDRESS CMD '@MkDir' TargetPath"UMail                  1>nul 2>&1"
  106.     ADDRESS CMD '@copy' OldSendmail tcpipBin"*.ex0         1>nul 2>&1"  /* backup copy, in case user actually prefers downlevel version */
  107.     ADDRESS CMD '@copy' NewSendmail TargetPath"UMAIL\*.ex1 1>nul 2>&1"  /* backup copy, in case user later re-installs old TCP/IP */
  108.     ADDRESS CMD '@copy' NewSendmail OldSendmail           "1>nul 2>&1"
  109.     text1='A new sendmail.exe was installed in the 'tcpipBin' directory.'
  110.     if rc = 0 then do
  111.       /* address cmd '@del sendmail.exe 1>nul 2>&1' */
  112.       n = RxMessageBox( text1, TitleInformation, "OK", "INFORMATION" )
  113.     end; else do
  114.       text='Unable to copy sendmail.exe to the directory 'tcpipBin || lf'Sendmail might be running.  If so, stop the running copy and then type Retry, or Cancel to continue.'
  115.       n = RxMessageBox( text, TitleWarning, "RETRYCANCEL", "WARNING" )
  116.       if n = 4 then do
  117.         /* retry to copy */
  118.         ADDRESS CMD '@copy sendmail.exe 'tcpipBin'sendmail.exe 1>nul 2>&1'
  119.         if rc = 0 then do
  120.           /* address cmd '@del sendmail.exe 1>nul 2>&1' */
  121.           n = RxMessageBox( text1, TitleInformation, "OK", "INFORMATION" )
  122.         end
  123.       end
  124.       if rc <> 0 then do
  125.         address cmd '@copy sendmail.exe 'TargetPath"UMAIL\*.ex1 1>nul 2>&1"
  126.         /* address cmd '@del sendmail.exe 1>nul 2>&1' */
  127.         text='Unable to copy sendmail.exe to the directory 'tcpipBin || lf
  128.         text=text'The new sendmail.exe is renamed 'TargetPath'UMAIL\sendmail.ex1'  /* tell user about backup copy */
  129.         n = RxMessageBox( text, TitleWarning, "OK", "WARNING" )
  130.       end
  131.     end  /* if */
  132.   end  /* if */
  133.  
  134.   /* replace the iak.txt if we install on top of the old IAK */
  135.   LANClient=SysSearchPath('PATH','TCPCFG.EXE')  /* test for old iak */
  136.   if LANClient = '' then do
  137.     ftp=SysSearchPath('PATH','FTP.EXE')
  138.     if ftp <> '' then do
  139.       iakdir = FileSpec("Drive", ftp) || FileSpec("Path", ftp)
  140.       ADDRESS CMD '@copy IAK.TXT' iakdir'IAK.TXT 1>nul 2>&1'
  141.       text1='A new IAK.TXT was installed in the 'iakdir' directory.'
  142.       if rc = 0 then do
  143.         n = RxMessageBox( text1, TitleInformation, "OK", "INFORMATION" )
  144.       end  /* if */
  145.     end  /* if */
  146.   end
  147.  
  148.   /* install a cleanup rexx command file into the startup folder */
  149.   cmdFile = TargetPath'UMClean.Cmd'
  150.   n = SysFileDelete(cmdFile)
  151.   n = LineOut(cmdFile, "/* UltiMail Lite 2.10 software download cleanup after reboot */")
  152.   n = LineOut(cmdFile, "call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'")
  153.   n = LineOut(cmdFile, "call SysLoadFuncs")
  154.   n = LineOut(cmdFile, "curDir = Directory()")
  155.   n = LineOut(cmdFile, "call Directory '"TargetPath"UMAIL'")
  156.   n = LineOut(cmdFile, "call '"TargetPath"UMAIL\MAKEWPS.CMD'")
  157.   n = LineOut(cmdFile, "call Directory CurDir ")
  158.   n = LineOut(cmdFile, "call SysDestroyObject '<UMAIL_LITE_CLEANUP>'")
  159.   n = LineOut(cmdFile, "call SysFileDelete '"cmdFile"'")
  160.   n = LineOut(cmdFile, "address 'CMD' 'exit'")
  161.   n = Stream(cmdFile, 'c', 'close')
  162.   n = SysCreateObject('WPProgram', 'UltiMail Lite Install Clean Up', '<WP_START>', 'OBJECTID=<UMAIL_LITE_CLEANUP>;EXENAME='cmdFile';', 'ReplaceIfExists');
  163. end
  164.  
  165. if CurDrive='A:'|CurDrive='B:' then do
  166.   text1 = "If installing from diskettes, please remove the final diskette only *AFTER*" || lf || 'exiting from this installation program.'
  167.   n = RxMessageBox( text1, TitleInformation, "OK", "INFORMATION" )
  168. end  /* Do */
  169.  
  170. ADDRESS CMD '@CALL TCPINST' RespOpt Source Target '/L1:'TargetPath'TCPINST.LOG 1>'TargetPath'UMailXt.LOG 2>&1'
  171. exitrc=rc
  172. if exitrc <> 0 then do
  173.   text='The UltiMail Install exit failed with a return code of 'exitrc
  174.   n = RxMessageBox( text, TitleError, "OK", "ERROR" )
  175. end
  176.  
  177. return exitrc
  178.  
  179. /* ------------------------------------------------------------------------ */
  180. /* Procedures                                                               */
  181. /* ------------------------------------------------------------------------ */
  182.  
  183. /*--- delete files ---------------------------------------------------------*/
  184. DeleteFiles:
  185.   PARSE ARG File
  186.   CALL SysFileTree File, 'file', 'FO'
  187.   DO idf = 1 TO file.0
  188.     CALL SysFileDelete(file.idf)
  189.   END
  190.   RETURN 0
  191.  
  192. /*--- replace sendmail.uml file --------------------------------------------*/
  193. ReplaceSendMailUML: procedure expose etc TargetPath TitleWarning TitleInformation lf
  194.   newSendMailUML = translate('sendmail.uml')
  195.   oldSendMailUML = translate(etc'\sendmail.uml')
  196.   bakSendMailUML = translate(etc'\sendmail.um0')
  197.   umlSendMailUML = translate(TargetPath'UMAIL\sendmail.uml')
  198.  
  199.   docopy = 1
  200.   sendMailUMLexists = 0
  201.  
  202.   if stream( oldSendMailUML, 'c', 'Query Exists') <> '' then do
  203.     sendMailUMLexists = 1
  204.     call SysFileSearch "DZ", oldSendMailUML, 'dz.'
  205.     if dz.0 <> 0 then
  206.       do i=1 to dz.0
  207.         first2char = substr(dz.i,1,2)
  208.         if first2char="DZ" then do
  209.           parse var dz.i 'DZ' majorversion '.' rest
  210.           j = verify( rest, '0123456789' )
  211.           restletter=''
  212.           select
  213.             when j=0 then minorversion = rest  /* only number where found */
  214.             when j=1 then do
  215.               minorversion = 0
  216.               restletter = rest
  217.             end  /* Do */
  218.           otherwise do
  219.             minorversion = substr(rest,1,j-1)
  220.             restletter = substr(rest,j)
  221.             minorversion = minorversion+0
  222.             end /* enddo */
  223.           end  /* select */
  224.           if restletter='um' then do
  225.             select
  226.               when majorversion<"2" then nop
  227.               when majorversion>"2" then docopy=0
  228.             otherwise do
  229.               select
  230.                 when minorversion<"12" then nop
  231.                 when minorversion>"12" then docopy=0
  232.               otherwise do
  233.                 docopy=0
  234.                 end /* do */
  235.               end  /* select */
  236.               end /* Do */
  237.             end  /* select */
  238.           end  /* Do */
  239.  
  240.           leave
  241.         end  /* Do */
  242.       end /* do */
  243.  
  244.     call stream oldSendMailUML, 'c', 'close'
  245.   end  /* Do */
  246.  
  247.   if docopy then do
  248.     /* copy the sendmail.uml file to the etc directory */
  249.     if sendMailUMLexists then do
  250.       address cmd '@copy 'oldSendMailUML bakSendMailUML' >nul 2>&1'
  251.     end  /* Do */
  252.     address cmd '@copy 'newSendMailUML oldSendMailUML' >nul 2>&1'
  253.     if rc = 0 then do
  254.       /* address cmd '@del 'newSendMailUML' >nul 2>&1' */
  255.       text='A new sendmail.uml was copied to the 'etc' directory.'lf
  256.       LANClient=SysSearchPath('PATH','TCPCFG.EXE')  /* test for lan client */
  257.       if LANClient <> '' then do
  258.         text=text'Please open the TCP/IP configuration notebook in the TCP/IP folder and check all the sendmail parameters.'
  259.       end;
  260.       n = RxMessageBox( text, TitleWarning, "OK", "WARNING" )
  261.     end; else do
  262.       address cmd '@copy 'newSendMailUML umlSendMailUML' >nul 2>&1'
  263.       /* address cmd '@del 'newSendMailUML' >nul 2>&1' */
  264.       text='Unable to copy sendmail.uml to the ETC directory'lf
  265.       text=text'The new sendmail.uml is in 'umlSendMailUML
  266.       n = RxMessageBox( text, TitleWarning, "OK", "WARNING" )
  267.     end  /* Do */
  268.  
  269.   end
  270.  
  271.   ftp=SysSearchPath('PATH','FTP.EXE')  /* test for tcpip */
  272.   if ftp <> '' then do
  273.     tcpip=FileSpec("Drive", ftp)||FileSpec("Path", ftp)
  274.     curDir=Directory()
  275.     tcp=Directory( tcpip'..' )
  276.     call Directory curDir
  277.     if tcp <> '' then do
  278.       address cmd '@mkdir 'tcp'\SAMPLES >nul 2>&1'
  279.       address cmd '@mkdir 'tcp'\SAMPLES\ETC >nul 2>&1'
  280.       address cmd '@copy 'newSendMailUML tcp'\SAMPLES\ETC >nul 2>&1'
  281.       /* address cmd '@del 'newSendMailUML' >nul 2>&1' */
  282.       /* text='A sendmail.uml template was copied to the 'tcp'\SAMPLES\ETC directory.' */
  283.       /* n = RxMessageBox( text, TitleInformation, "OK", "INFORMATION" ) */
  284.     end /* do */
  285.   end /* do */
  286.  
  287.   return 0
  288.  
  289.  
  290. /*--- Non-PM RxMessageBox replacement --------------------------------------*/
  291. RxMessageBox: procedure expose Attend
  292.   PARSE ARG TextString, TitleString, Buttons, Level
  293.   ActionOK     = 1
  294.   ActionCancel = 2
  295.   ActionRetry  = 4
  296.   ActionRC = ReturnOK
  297.   select
  298.     when Level = 'WARNING' then do
  299.       szSepStar    = LEFT('*', 78, '*')
  300.       Text = '*** '|| LEFT('WARNING:', 70, ' ')
  301.       Text = Text || ' ***'
  302.     end
  303.     when Level = 'ERROR' then do
  304.       szSepStar    = LEFT('*', 78, '*')
  305.       Text = '*** '|| LEFT('ERROR:', 70, ' ')
  306.       Text = Text || ' ***'
  307.     end
  308.     otherwise do
  309.       szSepStar    = LEFT('+-', 77, '-')
  310.       szSepStar    = szSepStar || '+'
  311.       Text = '|   '|| LEFT('Information:', 70, ' ')
  312.       Text = Text || '   |'
  313.     end
  314.   end
  315.   say szSepStar
  316.   say Text
  317.   say szSepStar
  318.   say TextString
  319.   say ''
  320.   if Buttons = 'RETRYCANCEL' then do
  321.     pull answer
  322.     answer = strip(answer)
  323.     if (abbrev('RETRY', answer, 1)) then do
  324.       ActionRC = ActionRetry
  325.     end
  326.   end
  327.   return ActionRC
  328.  
  329. /* --- end of file -------------------------------------------------------- */
  330.