home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / urlget10.zip / INSTALL.CMD next >
OS/2 REXX Batch file  |  1997-04-02  |  7KB  |  202 lines

  1. /*
  2. **                       UrlGet Install Script
  3. **                     copyright 1997 Ed Blackman
  4. **
  5. ** Acknowledgments:
  6. **  Originally by edgewood@pobox.com (Ed Blackman)
  7. **
  8. ** Change log:
  9. **  Who:   When:        What was done:
  10. **  EBB    1997/Mar/31  initial version
  11. **  EBB    1997/Apr/01  added code to allow choice of URL object class
  12. **  EBB    1997/Apr/01  now checks to see if URL object classes are installed
  13. **  EBB    1997/Apr/01  added code to allow choice of .INI file placement
  14. **  EBB    1997/Apr/02  reworked initial install choices
  15. **                      - doesn't prompt for install if already installed
  16. **                      - allows modifying a current installation
  17. */
  18.  
  19. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  20. call SysLoadFuncs
  21.  
  22. userapp='URLCommander'
  23. app='URLGet'
  24. urlpath='<WP_NEWURL>'
  25.  
  26. call SysCls
  27. call install
  28. exit
  29.  
  30. queryclass: procedure
  31.     objclass.0 = 2
  32.     objclass.1 = "WebExplorer_Url"
  33.     objclass.2 = "WPUrl"
  34.     
  35.     call SysQueryClassList 'class.'
  36.     found = 0
  37.     do i = 1 to class.0
  38.         parse upper var class.i classname .
  39.         do j = 1 to objclass.0            
  40.             if classname = translate(objclass.j) then
  41.                 found = 1
  42.         end j
  43.     end i
  44.     if \found then
  45.     do
  46.         say
  47.         say "URLGet creates URL objects.  In order for it to be able to do so,"
  48.         say "at least one of the following object classes must be registered"
  49.         say "with the WPS: "
  50.         do i = 1 to objclass.0
  51.             say "        " || objclass.i
  52.         end i    
  53.         call quit "None of these classes are registered on your system."
  54.     end
  55.     return
  56.  
  57. install: procedure expose userapp app urlpath 
  58.     inifile = SysIni("USER", userapp, "IniFile")
  59.  
  60.     say "                             UrlGet Install"
  61.     say "                       copyright 1997 Ed Blackman"
  62.     say
  63.     call queryclass
  64.  
  65.     say "This is the install script for URLGet.  URLGet parses text files passed"
  66.     say "to it on the command line, finding valid URLs and using them to create"
  67.     say "URL objects in a folder on the Desktop."
  68.     say
  69.  
  70.     if(inifile == 'ERROR:') then
  71.     do
  72.         call charout ,"Would you like to continue installing URLGet? "
  73.         key = translate(SysGetKey("noecho"))
  74.         if key \= 'Y' then
  75.             call quit
  76.     end
  77.     else /* already installed */
  78.     do
  79.         say "URLGet is already installed."
  80.         call charout ,"Would you like to uninstall URLGet? "
  81.         key = translate(SysGetKey("noecho"))
  82.         if key == 'Y' then
  83.             call uninstall inifile
  84.         else
  85.         do
  86.             say
  87.             say "Modifying the existing URLGet installation..."
  88.         end /* do */
  89.     end /* do */
  90.  
  91.     if inifile == "ERROR:" then
  92.         inifile = getini()
  93.     
  94.     call getmode inifile
  95.     call urlclass inifile
  96.     call urlpath inifile
  97.     say
  98.     say "Install completed.  Copy URLGET.CMD to a directory on your path."
  99. return
  100.  
  101. getini: procedure expose userapp
  102.     say
  103.     do until \SysFileTree(inipath, 'f.', 'DO') & f.0 == 1
  104.         say "Please enter a directory where URLGet can keep its .INI file:"
  105.         inipath = linein()
  106.     end /* do until */
  107.  
  108.     inifile = inipath || "\URLCOMM.INI"
  109.     
  110.     if(SysIni("USER", userapp, 'IniFile', inifile) == 'ERROR:') then
  111.         call quit "Could not write URLGet .INI file path to OS2.INI"
  112.     return inifile
  113.  
  114.     
  115. getmode: procedure expose app
  116.     parse arg inifile
  117.     key=''
  118.     say
  119.     say "In interactive mode, URLGet displays the URL and prompts the user for"
  120.     say "a description.  If the user enters a description, it creates a URL"
  121.     say "object, using the description and the current date and time as the"
  122.     say "title of the URL object."
  123.     say
  124.     say "In batch mode, all of the valid URLs in the file are turned into URL"
  125.     say "objects."
  126.     say
  127.     do until key=='B' | key=='I'
  128.         call charout ,"Would you like URLGet to run in batch or interactive mode? (B/I) "
  129.         key = translate(SysGetKey("noecho"))
  130.         say
  131.     end /* do */
  132.     if key=='B' then mode='BATCH'
  133.     else /* key=='I' */ mode='INTERACTIVE'
  134.  
  135.     if(SysIni(inifile, app, 'Mode', mode) == 'ERROR:') then
  136.         call quit "Could not write URLGet mode to" inifile
  137.     return
  138.  
  139. urlclass: procedure expose app
  140.     parse arg inifile
  141.     key=''
  142.     do until key=='E' | key=='4'
  143.         say "Would you like URLGet to create WebExplorer URL objects, or Warp"
  144.         call charout ,"4 URL objects? (E/4) "
  145.         key = translate(SysGetKey("noecho"))
  146.         say
  147.     end /* do */
  148.     if key=='E' then do; objclass='WebExplorer_URL'; setupstr='LOCATOR='; end;
  149.     else /* key=='4' */ do; objclass='WPUrl'; setupstr='URL='; end;
  150.  
  151.     if(SysIni(inifile, app, 'ObjectClass', objclass) == 'ERROR:') then
  152.         call quit "Could not write URLGet object class to" inifile
  153.     if(SysIni(inifile, app, 'SetupString', setupstr) == 'ERROR:') then
  154.         call quit "Could not write URLGet setup string to" inifile
  155.     return
  156.  
  157. urlpath: procedure expose urlpath app
  158.     parse arg inifile
  159.     if \SysSaveObject(urlpath, 1) then /* object doesn't exist */
  160.     do
  161.         say "Creating a folder on the Desktop to hold new URL objects..."
  162.         if(\SysCreateObject("WPFolder", "New URLs", "<WP_DESKTOP>", "OBJECTID="urlpath, "replace")) then
  163.             call quit "Could not create URL object folder"
  164.     end
  165.     if(SysIni(inifile, app, 'URLPath', urlpath) == 'ERROR:') then
  166.         call quit "Could not write URLGet URL folder path to" inifile
  167.     return
  168.    
  169. uninstall: procedure expose userapp app
  170.     parse arg inifile
  171.     call SysIni inifile, app, 'DELETE:'
  172.     say
  173.     say "Application keys for" app "deleted from" inifile
  174.     
  175.     call SysINI inifile, 'ALL:', 's.'
  176.     if(s.0 = 0) then
  177.     do
  178.         call SysFileDelete inifile
  179.         say "There are no more application keys in" inifile
  180.         say inifile "deleted"
  181.  
  182.         call SysIni "USER", userapp, 'DELETE:'
  183.         say "The reference to" inifile "in OS2.INI has been removed"
  184.     end
  185.     else
  186.     do
  187.         say "There are" s.0 "application keys remaining in" inifile
  188.         say inifile "not deleted"
  189.         say "The reference to" inifile "in OS2.INI has not been removed"
  190.     end
  191.     call quit
  192.     return
  193.     
  194. quit: procedure
  195.     parse arg message
  196.     if message \= "" then
  197.         say message
  198.     say
  199.     say "Quitting URLGet install..."
  200.     exit
  201.     
  202.