home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 25 / CDROM25.iso / Share / linux / apache / contrib / misc / ns2apache.pl next >
Encoding:
Perl Script  |  1998-06-11  |  22.6 KB  |  780 lines

  1. #!/usr/local/bin/perl
  2. #
  3. # Date: Fri, 21 Jun 1996 14:48:20 -0400 (EDT)
  4. # From: "Mark A. Imbriaco" <mark@itribe.net>
  5. # Subject: Netscape->Apache Configuration File Convertor.
  6. #
  7. #
  8. #    Well, here's the script that I made to convert from Netscape
  9. #    to Apache.  This doesn't handle all of the Configuration directives,
  10. #    but it does to a reasonable subset, and is useable in it's current
  11. #    form.  Some modifications will still have to be made to the Apache
  12. #    configuration files, but things like Aliases, ScriptAliases, 
  13. #    Redirects, Document Root, etc. are all inserted based on the 
  14. #    Netsc(r)ape config files..  Feel free to hack this to pieces.
  15. #    It's not real pretty, but it doesn't depend on any modules that
  16. #    don't come standard with perl5.
  17. #
  18. #    BTW:  While I was writing this, I was struck with an idea that I 
  19. #          think would be damned cool for the configuration files.  
  20. #          An Include directive.  It'd be handy for putting Aliases
  21. #          or ScriptAliases and things like that in their own file..
  22. #          What do you guys think?
  23. #
  24. #    -Mark
  25. #
  26. # ===========================================================================
  27.  
  28. use Getopt::Long;
  29.  
  30. # ===========================================================================
  31.  
  32. $res = GetOptions('magnus:s', 'obj:s', 'httpd:s', 'srm:s', 'access:s', 'h');
  33.  
  34. $MAGNUS_CONF = $opt_magnus;
  35. $OBJ_CONF    = $opt_obj;
  36. $HTTPD_CONF  = $opt_httpd;
  37. $SRM_CONF    = $opt_srm;
  38. $ACCESS_CONF = $opt_access;
  39. $|           = 1;
  40.  
  41. if (!defined($opt_magnus)) {
  42.   $MAGNUS_CONF = "magnus.conf";
  43. }
  44. if (!defined($opt_magnus)) {
  45.   $OBJ_CONF = "obj.conf";
  46. }
  47. if (!defined($opt_httpd)) {
  48.   $HTTPD_CONF = "httpd.conf";
  49. }
  50. if (!defined($opt_srm)) {
  51.   $SRM_CONF = "srm.conf";
  52. }
  53. if (!defined($opt_access)) {
  54.   $ACCESS_CONF = "access.conf";
  55. }
  56. if (defined($opt_h)) {
  57.   print qq|
  58.   Usage: $0 [-magnus <file>] [-obj <file>] [-httpd <file>]
  59.             [-srm <file>] [-access <file>]
  60.  
  61.     -magnus:  name of the Netscape magnus.conf file. (defaults to magnus.conf)
  62.     -obj: name of the Netscape obj.conf file.        (defaults to obj.conf)
  63.  
  64.     -httpd: name for the Apache httpd.conf file.     (defaults to httpd.conf)
  65.     -srm: name for the Apache srm.conf file.         (defaults to srm.conf)
  66.     -access: name for the Apache access.conf file.   (defaults to access.conf)
  67.  
  68. |;
  69.   exit;
  70. }
  71.  
  72. # ===========================================================================
  73.  
  74. # GLOBALS: %serv, %obj_struct, @alias, @scriptalias, @redirect
  75.  
  76. sub read_magnus {
  77.   my $fn = shift;
  78.   my (@keywords) = ('port','address','errorlog','pidlog','user','servername',
  79.             'minprocs','maxprocs','dns');
  80.   my ($keyword, $tmp1, $tmp2, $tmp3);
  81.  
  82.   print "[Netscape] Reading server configuration file: $fn...\n";
  83.   open (MAG_IN, "$fn") || die "Couldn't open server configuration file: $fn\n";
  84.   while (<MAG_IN>) {
  85.     chop;
  86.     ( $tmp1, $tmp2 ) = split(/\s+/, $_, 2);
  87.     foreach $keyword (@keywords) {
  88.       if ($tmp1 =~ m/$keyword/i) {
  89.     $serv{$keyword} = $tmp2;
  90.       }      
  91.     }
  92.  
  93.     if (($tmp1 =~ m/init/i) && ($tmp2 =~ m/init-clf/i)) {
  94.       if ( $tmp2 =~ m/(global.+\")/i ) {
  95.     $tmp3 = $1;
  96.     $tmp3 =~ s/global=//g;
  97.     $tmp3 =~ s/\"//g;
  98.     $serv{transferlog} = $tmp3;
  99.       }
  100.     }
  101.   }
  102.   close (MAG_IN);
  103.   return (1);
  104. }
  105.  
  106. sub read_objs {
  107.   my $fn = shift;
  108.   my ($in_obj) = 0;
  109.   my ($obj_type, $obj_name, $docroot, $indexfn, $realm, $auth_user, $dbm_file);
  110.   
  111.   my ($scount) = 0;
  112.   my ($acount) = 0;
  113.   my ($rcount) = 0;
  114.  
  115.   print "[Netscape] Reading object configuration file: $fn...\n";
  116.   open (OBJ_CONF, $fn) || die "Counldn't open object configuration file:
  117. $fn\n";
  118.   while (<OBJ_CONF>) {
  119.     if ($in_obj) {  # are we inside of an <object></object> block?
  120.       if (/<\/object>/i) {  # is this the end of the <object></object> block?
  121.     $in_obj = 0;
  122.       } else {
  123.     if (/^nametrans/i) {  # handle nametrans lines.
  124.       my ($type, $from, $dest);
  125.  
  126.       if (/(from=\")(\S+)(\")/i) {
  127.         $from = $2;
  128.       }
  129.  
  130.       if (/(name=\")(cgi)(\")/i) {
  131.         $type = "scriptalias";
  132.       } elsif (/(fn=\")(redirect)(\")/i) {
  133.         $type = "redirect";
  134.       } elsif (/(fn=\")(document-root)(\")/i) {
  135.         $type = "docroot";
  136.         if (/(root=\")(\S+)(\")/i) {
  137.           $docroot = $2;
  138.         }
  139.       } else {
  140.         $type = "alias";
  141.       }
  142.       
  143.       if (/([dir|url]=\")(\S+)(\")/i) {
  144.         $dest = $2;
  145.       }
  146.       
  147.     SWITCH: for($type) {
  148.         /scriptalias/ && do { 
  149.           $scriptalias[$scount]{from} = $from; 
  150.           $scriptalias[$scount]{dest} = $dest;
  151.           $scount++;
  152.           last SWITCH;
  153.         };
  154.         /alias/ && do {
  155.           $alias[$acount]{from} = $from; 
  156.           $alias[$acount]{dest} = $dest;
  157.           $acount++;
  158.           last SWITCH;
  159.         };
  160.         /redirect/ && do {
  161.           $redirect[$rcount]{from} = $from; 
  162.           $redirect[$rcount]{dest} = $dest;
  163.           $rcount++;
  164.           last SWITCH;
  165.         };
  166.       }
  167.     } elsif (/^pathcheck/i) {  # handle pathcheck lines. (look for index filenames)
  168.       if (/(index-names=\")(\S+)(\")/i) {
  169.         $indexfn = $2;
  170.         $indexfn =~ s/,/ /g;
  171.       } elsif (/require-auth/) {
  172.         $obj_struct{$obj_name}{require_auth} = 1;
  173.         if (/(realm=\")([\w|\s]+)(\")/i) {
  174.           $realm = $2;
  175.           $obj_struct{$obj_name}{realm} = $realm;
  176.         }
  177.         if (/(auth-user=\")(.+)/i) {
  178.           $auth_user = $2;
  179.           $auth_user =~ s/\".*//g;
  180.           $auth_user =~ s/\(|\)//g;
  181.           $auth_user =~ s/\|/ /g;
  182.           $obj_struct{$obj_name}{authuser} = $auth_user;
  183.         }
  184.       }
  185.     } elsif (/^authtrans/i) {
  186.       if (/fn=\"basic-ncsa\"/i) {
  187.         if (/(dbm=\")([\w|\W]+\s)/i) {
  188.           $dbm_file = $2;
  189.           $dbm_file =~ s/\".*|\s//g;
  190.           $obj_struct{$obj_name}{dbm_file} = $dbm_file;
  191.         }
  192.         
  193.       }
  194.     } elsif (/^objecttype/i) {  # look to see if server parsed html should be turned on.
  195.       if (/(fn=\")(shtml-hacktype)(\")/i) {
  196.         $serv{servparse} = 1;
  197.       }
  198.     }
  199.       } 
  200.     } elsif (/(<object\s)(\w+=\")(.+)(\")>/i ) {   # Is this the beginning of an <object></object> block.
  201.       $in_obj = 1;
  202.       $obj_type = $2;
  203.       $obj_name = $3;
  204.       $obj_name =~ s/\*//g;
  205.       $obj_type =~ s/=\"//;
  206.       
  207.       if ($obj_type =~ m/ppath/i) {
  208.     $obj_struct{$obj_name}{ppath} = 1;
  209.       }
  210.     }
  211.   }
  212.   close (OBJ_CONF);
  213.  
  214.   $obj_struct{docroot} = $docroot;
  215.   $obj_struct{indexfn} = $indexfn;
  216.  
  217.   return(1);
  218. }
  219.  
  220. sub write_httpdconf {
  221.   my $fn = shift;
  222.  
  223.   print "[Apache] Writing httpd configuration file: $fn...\n";
  224.   open(OUT, ">$fn") || die "Couldn't open $fn for output.\n";
  225.   print OUT qq|
  226. # This is the main server configuration file. See URL http://www.apache.org/
  227. # for instructions.
  228.  
  229. # Do NOT simply read the instructions in here without understanding
  230. # what they do, if you are unsure consult the online docs. You have been
  231. # warned.  
  232.  
  233. # Originally by Rob McCool
  234.  
  235. # ServerType is either inetd, or standalone.
  236.  
  237. ServerType standalone
  238.  
  239. # If you are running from inetd, go to "ServerAdmin".
  240.  
  241. # Port: The port the standalone listens to. For ports < 1023, you will
  242. # need httpd to be run as root initially.
  243.  
  244. Port 80
  245.  
  246. # HostnameLookups: Log the names of clients or just their IP numbers
  247. #   e.g.   www.apache.org (on) or 204.62.129.132 (off)
  248.  
  249. HostnameLookups $serv{dns}
  250.  
  251. # If you wish httpd to run as a different user or group, you must run
  252. # httpd as root initially and it will switch.  
  253.  
  254. # User/Group: The name (or #number) of the user/group to run httpd as.
  255. #  On SCO (ODT 3) use User nouser and Group nogroup
  256. User $serv{user}
  257. Group #-1
  258.  
  259. # ServerAdmin: Your address, where problems with the server should be
  260. # e-mailed.
  261.  
  262. ServerAdmin you\@your.address
  263.  
  264. # ServerRoot: The directory the server's config, error, and log files
  265. # are kept in
  266.  
  267. ServerRoot /usr/local/etc/httpd
  268.  
  269. # BindAddress: You can support virtual hosts with this option. This option
  270. # is used to tell the server which IP address to listen to. It can either
  271. # contain "*", an IP address, or a fully qualified Internet domain name.
  272. # See also the VirtualHost directive.
  273.  
  274. BindAddress $serv{address}
  275. |;
  276.   if ($LOG_TO_OLD) {
  277.     print OUT qq|
  278.  
  279. # ErrorLog: The location of the error log file. If this does not start
  280. # with /, ServerRoot is prepended to it.
  281.  
  282. ErrorLog $serv{errorlog}\n
  283.  
  284. # TransferLog: The location of the transfer log file. If this does not
  285. # start with /, ServerRoot is prepended to it.
  286.  
  287. TransferLog $serv{transferlog}
  288.  
  289. # PidFile: The file the server should log its pid to
  290. PidFile $serv{pidlog}
  291.  
  292. |;
  293.   } else {
  294.     print OUT qq|
  295.  
  296. # ErrorLog: The location of the error log file. If this does not start
  297. # with /, ServerRoot is prepended to it.
  298.  
  299. ErrorLog logs/error_log
  300.  
  301. # TransferLog: The location of the transfer log file. If this does not
  302. # start with /, ServerRoot is prepended to it.
  303.  
  304. TransferLog logs/access_log
  305.  
  306. # PidFile: The file the server should log its pid to
  307. PidFile logs/httpd.pid
  308.  
  309. |;
  310.   }
  311.   print OUT qq|
  312. # ScoreBoardFile: File used to store internal server process information
  313. ScoreBoardFile logs/apache_status
  314.  
  315. # ServerName allows you to set a host name which is sent back to clients for
  316. # your server if it's different than the one the program would get (i.e. use
  317. # "www" instead of the host's real name).
  318. #
  319. # Note: You cannot just invent host names and hope they work. The name you 
  320. # define here must be a valid DNS name for your host. If you don't understand
  321. # this, ask your network administrator.
  322.  
  323. #ServerName new.host.name
  324.  
  325. # CacheNegotiatedDocs: By default, Apache sends Pragma: no-cache with each
  326. # document that was negotiated on the basis of content. This asks proxy
  327. # servers not to cache the document. Uncommenting the following line disables
  328. # this behavior, and proxies will be allowed to cache the documents.
  329.  
  330. #CacheNegotiatedDocs
  331.  
  332. # Timeout: The number of seconds before receives and sends time out
  333. #  n.b. the compiled default is 1200 (20 minutes !)
  334.  
  335. Timeout 400
  336.  
  337. # KeepAlive: The number of Keep-Alive persistent requests to accept
  338. # per connection. Set to 0 to deactivate Keep-Alive support
  339.  
  340. KeepAlive 5
  341.  
  342. # KeepAliveTimeout: Number of seconds to wait for the next request
  343.  
  344. KeepAliveTimeout 15
  345.  
  346. # Server-pool size regulation.  Rather than making you guess how many
  347. # server processes you need, Apache dynamically adapts to the load it
  348. # sees --- that is, it tries to maintain enough server processes to
  349. # handle the current load, plus a few spare servers to handle transient
  350. # load spikes (e.g., multiple simultaneous requests from a single
  351. # Netscape browser).
  352.  
  353. # It does this by periodically checking how many servers are waiting
  354. # for a request.  If there are fewer than MinSpareServers, it creates
  355. # a new spare.  If there are more than MaxSpareServers, some of the
  356. # spares die off.  These values are probably OK for most sites ---
  357.  
  358. MinSpareServers 5
  359. MaxSpareServers 10
  360.  
  361. # Number of servers to start --- should be a reasonable ballpark figure.
  362.  
  363. StartServers $serv{minprocs}
  364.  
  365. # Limit on total number of servers running, i.e., limit on the number
  366. # of clients who can simultaneously connect --- if this limit is ever
  367. # reached, clients will be LOCKED OUT, so it should NOT BE SET TOO LOW.
  368. # It is intended mainly as a brake to keep a runaway server from taking
  369. # Unix with it as it spirals down...
  370.  
  371. MaxClients 150
  372.  
  373. # MaxRequestsPerChild: the number of requests each child process is
  374. #  allowed to process before the child dies.
  375. #  The child will exit so as to avoid problems after prolonged use when
  376. #  Apache (and maybe the libraries it uses) leak.  On most systems, this
  377. #  isn't really needed, but a few (such as Solaris) do have notable leaks
  378. #  in the libraries.
  379.  
  380. MaxRequestsPerChild 30
  381.  
  382. # Proxy Server directives. Uncomment the following line to
  383. # enable the proxy server:
  384.  
  385. #ProxyRequests On
  386.  
  387. # To enable the cache as well, edit and uncomment the following lines:
  388.  
  389. #CacheRoot /usr/local/etc/httpd/proxy
  390. #CacheSize 5
  391. #CacheGcInterval 4
  392. #CacheMaxExpire 24
  393. #CacheLastModifiedFactor 0.1
  394. #CacheDefaultExpire 1
  395. #NoCache adomain.com anotherdomain.edu joes.garage.com
  396.  
  397. # Listen: Allows you to bind Apache to specific IP addresses and/or
  398. # ports, in addition to the default. See also the VirtualHost command
  399.  
  400. #Listen 3000
  401. #Listen 12.34.56.78:80
  402.  
  403. # VirtualHost: Allows the daemon to respond to requests for more than one
  404. # server address, if your server machine is configured to accept IP packets
  405. # for multiple addresses. This can be accomplished with the ifconfig 
  406. # alias flag, or through kernel patches like VIF.
  407.  
  408. # Any httpd.conf or srm.conf directive may go into a VirtualHost command.
  409. # See alto the BindAddress entry.
  410.  
  411. #<VirtualHost host.foo.com>
  412. #ServerAdmin webmaster\@host.foo.com
  413. #DocumentRoot /www/docs/host.foo.com
  414. #ServerName host.foo.com
  415. #ErrorLog logs/host.foo.com-error_log
  416. #TransferLog logs/host.foo.com-access_log
  417. #</VirtualHost>
  418. |;
  419.   close(OUT);
  420.   return(1);
  421. }
  422.  
  423. sub write_srmconf {
  424.   my $fn = shift;
  425.   my $curr_alias;
  426.  
  427.   print "[Apache] Writing srm configuration file: $fn...\n";
  428.   open(OUT, ">$fn") || die "Couldn't open $fn for output.\n";
  429.   print OUT qq|
  430. # With this document, you define the name space that users see of your http
  431. # server.  This file also defines server settings which affect how requests are
  432. # serviced, and how results should be formatted. 
  433.   
  434. # See the tutorials at http://www.apache.org/ for
  435. # more information.
  436.  
  437. # Originally by Rob McCool; Adapted for Apache
  438.  
  439.  
  440. # DocumentRoot: The directory out of which you will serve your
  441. # documents. By default, all requests are taken from this directory, but
  442. # symbolic links and aliases may be used to point to other locations.
  443.  
  444. DocumentRoot $obj_struct{docroot}
  445.  
  446. # UserDir: The name of the directory which is appended onto a user's home
  447. # directory if a ~user request is recieved.
  448.  
  449. UserDir public_html
  450.  
  451. # DirectoryIndex: Name of the file or files to use as a pre-written HTML
  452. # directory index.  Separate multiple entries with spaces.
  453.  
  454. DirectoryIndex $obj_struct{indexfn}
  455.  
  456. # FancyIndexing is whether you want fancy directory indexing or standard
  457.  
  458. FancyIndexing on
  459.  
  460. # AddIcon tells the server which icon to show for different files or filename
  461. # extensions
  462.  
  463. AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip
  464.  
  465. AddIconByType (TXT,/icons/text.gif) text/*
  466. AddIconByType (IMG,/icons/image2.gif) image/*
  467. AddIconByType (SND,/icons/sound2.gif) audio/*
  468. AddIconByType (VID,/icons/movie.gif) video/*
  469.  
  470. AddIcon /icons/binary.gif .bin .exe
  471. AddIcon /icons/binhex.gif .hqx
  472. AddIcon /icons/tar.gif .tar
  473. AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
  474. AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
  475. AddIcon /icons/a.gif .ps .ai .eps
  476. AddIcon /icons/layout.gif .html .shtml .htm .pdf
  477. AddIcon /icons/text.gif .txt
  478. AddIcon /icons/c.gif .c
  479. AddIcon /icons/p.gif .pl .py
  480. AddIcon /icons/f.gif .for
  481. AddIcon /icons/dvi.gif .dvi
  482. AddIcon /icons/uuencoded.gif .uu
  483. AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
  484. AddIcon /icons/tex.gif .tex
  485. AddIcon /icons/bomb.gif core
  486.  
  487. AddIcon /icons/back.gif ..
  488. AddIcon /icons/hand.right.gif README
  489. AddIcon /icons/folder.gif ^^DIRECTORY^^
  490. AddIcon /icons/blank.gif ^^BLANKICON^^
  491.  
  492. # DefaultIcon is which icon to show for files which do not have an icon
  493. # explicitly set.
  494.  
  495. DefaultIcon /icons/unknown.gif
  496.  
  497. # AddDescription allows you to place a short description after a file in
  498. # server-generated indexes.
  499. # Format: AddDescription "description" filename
  500.  
  501. # ReadmeName is the name of the README file the server will look for by
  502. # default. Format: ReadmeName name
  503. #
  504. # The server will first look for name.html, include it if found, and it will
  505. # then look for name and include it as plaintext if found.
  506. #
  507. # HeaderName is the name of a file which should be prepended to
  508. # directory indexes. 
  509.  
  510. ReadmeName README
  511. HeaderName HEADER
  512.  
  513. # IndexIgnore is a set of filenames which directory indexing should ignore
  514. # Format: IndexIgnore name1 name2...
  515.  
  516. IndexIgnore */.??* *~ *# */HEADER* */README* */RCS
  517.  
  518. # AccessFileName: The name of the file to look for in each directory
  519. # for access control information.
  520.  
  521. AccessFileName .htaccess
  522.  
  523. # DefaultType is the default MIME type for documents which the server
  524. # cannot find the type of from filename extensions.
  525.  
  526. DefaultType text/plain
  527.  
  528. # AddEncoding allows you to have certain browsers (Mosaic/X 2.1+) uncompress
  529. # information on the fly. Note: Not all browsers support this.
  530.  
  531. AddEncoding x-compress Z
  532. AddEncoding x-gzip gz
  533.  
  534. # AddLanguage allows you to specify the language of a document. You can
  535. # then use content negotiation to give a browser a file in a language
  536. # it can understand.  Note that the suffix does not have to be the same
  537. # as the language keyword --- those with documents in Polish (whose
  538. # net-standard language code is pl) may wish to use "AddLanguage pl .po" 
  539. # to avoid the ambiguity with the common suffix for perl scripts.
  540.  
  541. AddLanguage en .en
  542. AddLanguage fr .fr
  543. AddLanguage de .de
  544. AddLanguage da .da
  545. AddLanguage el .el
  546. AddLanguage it .it
  547.  
  548. # LanguagePriority allows you to give precedence to some languages
  549. # in case of a tie during content negotiation.
  550. # Just list the languages in decreasing order of preference.
  551.  
  552. LanguagePriority en fr de
  553.  
  554. # Redirect allows you to tell clients about documents which used to exist in
  555. # your server's namespace, but do not anymore. This allows you to tell the
  556. # clients where to look for the relocated document.
  557. # Format: Redirect fakename url
  558.  
  559. |;
  560.  
  561.   for $curr_alias (1 .. $#redirect) {
  562.     print OUT "Redirect $redirect[$curr_alias]{from}
  563. $redirect[$curr_alias]{dest}\n";
  564.   }
  565.  
  566.   print OUT qq|
  567. # ScriptAlias: This controls which directories contain server scripts.
  568. # Format: ScriptAlias fakename realname
  569.  
  570. #ScriptAlias /cgi-bin/ /usr/local/etc/httpd/cgi-bin/
  571.  
  572. |;
  573.  
  574.   foreach $curr_alias (1 .. $#scriptalias) {
  575.     print OUT "ScriptAlias $scriptalias[$curr_alias]{from}
  576. $scriptalias[$curr_alias]{dest}\n";
  577.   }
  578.  
  579.   print OUT qq|
  580. # Aliases: Add here as many aliases as you need (with no limit). The format is 
  581. # Alias fakename realname
  582. #Alias /icons/ /usr/local/etc/httpd/icons/
  583.  
  584. |;
  585.  
  586.   for $curr_alias (1 .. $#alias) {
  587.     print OUT "Alias $alias[$curr_alias]{from} $alias[$curr_alias]{dest}\n";
  588.   }
  589.  
  590.   print OUT qq|
  591. # If you want to use server side includes, or CGI outside
  592. # ScriptAliased directories, uncomment the following lines.
  593.  
  594. # AddType allows you to tweak mime.types without actually editing it, or to
  595. # make certain files to be certain types.
  596. # Format: AddType type/subtype ext1
  597.  
  598. # AddHandler allows you to map certain file extensions to "handlers",
  599. # actions unrelated to filetype. These can be either built into the server
  600. # or added with the Action command (see below)
  601. # Format: AddHandler action-name ext1
  602.  
  603. # To use CGI scripts:
  604. #AddHandler cgi-script .cgi
  605.  
  606. # To use server-parsed HTML files
  607. |;
  608.   if ($serv{servparse}) {
  609.     print OUT qq|
  610. AddType text/html .shtml
  611. AddHandler server-parsed .shtml
  612. |;
  613.   } else {
  614.      print OUT qq|
  615. #AddType text/html .shtml
  616. #AddHandler server-parsed .shtml
  617. |;
  618.   }
  619.   print OUT qq|
  620.  
  621. # Uncomment the following line to enable Apache's send-asis HTTP file
  622. # feature
  623. #AddHandler send-as-is asis
  624.  
  625. # If you wish to use server-parsed imagemap files, use
  626. AddHandler imap-file map
  627.  
  628. # To enable type maps, you might want to use
  629. AddHandler type-map var
  630.  
  631. # Action lets you define media types that will execute a script whenever
  632. # a matching file is called. This eliminates the need for repeated URL
  633. # pathnames for oft-used CGI file processors.
  634. # Format: Action media/type /cgi-script/location
  635. # Format: Action handler-name /cgi-script/location
  636.  
  637. # For example to add a footer (footer.html in your document root) to
  638. # files with extension .foot (e.g. foo.html.foot), you could use:
  639. #AddHandler foot-action foot
  640. #Action foot-action /cgi-bin/footer
  641.  
  642. # Or to do this for all HTML files, for example, use:
  643. #Action text/html /cgi-bin/footer
  644.  
  645. # MetaDir: specifies the name of the directory in which Apache can find
  646. # meta information files. These files contain additional HTTP headers
  647. # to include when sending the document
  648.  
  649. #MetaDir .web
  650.  
  651. # MetaSuffix: specifies the file name suffix for the file containing the
  652. # meta information.
  653.  
  654. #MetaSuffix .meta
  655.  
  656. # Customizable error response (Apache style)
  657. #  these come in three flavors
  658. #
  659. #    1) plain text
  660. #ErrorDocument 500 "The server made a boo boo.
  661. #  n.b.  the (") marks it as text, it does not get output
  662. #
  663. #    2) local redirects
  664. #ErrorDocument 404 /missing.html
  665. #  to redirect to local url /missing.html
  666. #ErrorDocument 404 /cgi-bin/missing_handler.pl
  667. #  n.b. can redirect to a script or a document using server-side-includes.
  668. #
  669. #    3) external redirects
  670. #ErrorDocument 402 http://other.server.com/subscription_info.html
  671. #
  672. |;
  673.   close(OUT);
  674.   return(1);
  675. }
  676.  
  677. sub write_accessconf {
  678.   my $fn = shift;
  679.  
  680.   print "[Apache] Writing access configuration file: $fn...\n";
  681.   open(OUT, ">$fn") || die "Couldn't open $fn for output.\n";
  682.   print OUT qq|
  683. # access.conf: Global access configuration
  684. # Online docs at http://www.apache.org/
  685.  
  686. # This file defines server settings which affect which types of services
  687. # are allowed, and in what circumstances. 
  688.  
  689. # Each directory to which Apache has access, can be configured with respect
  690. # to which services and features are allowed and/or disabled in that
  691. # directory (and its subdirectories). 
  692.  
  693. # Originally by Rob McCool
  694.  
  695. # /usr/local/etc/httpd/ should be changed to whatever you set ServerRoot to.
  696. #<Directory /usr/local/etc/httpd/cgi-bin>
  697. #Options Indexes FollowSymLinks
  698. #</Directory>
  699.  
  700. # This should be changed to whatever you set DocumentRoot to.
  701.  
  702. <Directory $serv{docroot}>
  703.  
  704. # This may also be "None", "All", or any combination of "Indexes",
  705. # "Includes", "FollowSymLinks", "ExecCGI", or "MultiViews".
  706.  
  707. # Note that "MultiViews" must be named *explicitly* --- "Options All"
  708. # doesn't give it to you (or at least, not yet).
  709.  
  710. Options Indexes FollowSymLinks
  711.  
  712. # This option allows you to turn on the XBitHack behavior, which allows you
  713. # to make text/html server-parsed by activating the owner x bit with chmod. 
  714. # This directive may be used wherever Options may, and has three
  715. # possible arguments: Off, On or Full. If set to full, Apache will also
  716. # add a Last-Modified header to the document if the group x bit is set.
  717.  
  718. # Unless the server has been compiled with -DXBITHACK, this function is
  719. # off by default. To use, uncomment the following line:
  720.  
  721. #XBitHack Full
  722.  
  723. # This controls which options the .htaccess files in directories can
  724. # override. Can also be "None", or any combination of "Options", "FileInfo", 
  725. # "AuthConfig", and "Limit"
  726.  
  727. AllowOverride All
  728.  
  729. # Controls who can get stuff from this server.
  730.  
  731. <Limit GET>
  732. order allow,deny
  733. allow from all
  734. </Limit>
  735. </Directory>
  736.  
  737. # Allow server status reports, with the URL of http://servername/status
  738. # Change the ".nowhere.com" to match your domain to enable.
  739.  
  740. <Location /status>
  741. SetHandler server-status
  742.  
  743. <Limit GET>
  744. order deny,allow
  745. deny from all
  746. allow from .nowhere.com
  747. </Limit>
  748. </Location>
  749.  
  750. # You may place any other directories or locations you wish to have
  751. # access information for after this one.
  752. |;
  753.   for (keys %obj_struct) {
  754.     next if (/default/i);
  755.     next if (/cgi/i);
  756.     next unless ($obj_struct{$_}{require_auth});
  757.     print OUT qq|
  758. <Directory $_>
  759. AuthName $obj_struct{$_}{realm}
  760. AuthDBMUserFile $obj_struct{$_}{dbm_file}
  761. <Limit GET POST>
  762. require user $obj_struct{$_}{authuser}
  763. </Limit>
  764. </Directory>
  765. |;
  766.   }
  767.   close(OUT);
  768.   return(1);
  769. }
  770.  
  771. &read_magnus($MAGNUS_CONF);
  772. &read_objs($OBJ_CONF);
  773. &write_httpdconf($HTTPD_CONF);
  774. &write_srmconf($SRM_CONF);
  775. &write_accessconf($ACCESS_CONF);
  776. exit;
  777.  
  778.  
  779.  
  780.