Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 2539338d7c
Fetching contributors…

Cannot retrieve contributors at this time

327 lines (255 sloc) 10.316 kb
$DEF_MDEMONIC = 0;
$DEF_MSTUNNEL = 0;
$DEF_MGENERIC = 0;
$DEF_CONF_TYPE = "inetd";
eval 'require "./consubs.pl";'; die(<<"EOF") if ($@);
Could not load consubs.pl, which is required for running the configure script.
Please make sure it's in the current directory.
($@)
EOF
&prompt(<<"EOF", "") unless ($DEFAULT);
Configure (inetd) for HTTPi/$ACTUAL_VERSION
This is the configure script for inetd systems (most Unix boxen).
DO NOT RUN THIS IF:
* you want to run HTTPi as a >> daemon << (run configure.demonic)
* you have xinetd or launchd (run configure.xinetd or
configure.launchd instead)
* you want to use SSL (run configure.stunnel)
* you have NO inetd or an unsupported one (run configure.generic)
If you don't know what you have, but you're running on Unix, chances are
this is the right script. (I'll stop you if it isn't.)
In the current version, Win32 and Classic Mac inetds, if any, are not supported
directly. YOU MUST RUN configure.generic for these systems if you want your
inetd to control HTTPi.
Press ENTER to continue or BREAK/CTRL-C to bail out:
EOF
print "\nChecking system defaults ...\n\n";
$DEF_ROOT = &yncheck("Are we running as root?", "die if ($<);");
if (!$DEF_ROOT && !$DEFAULT) {
&prompt(<<"EOF", "");
You will only be able to write out the object file, and you might not be
able to even do that without appropriate permissions. Consider running this
Configure script as root if you want to install HTTPi fully.
Press ENTER to continue.
EOF
$DO_INSTALL = 0;
} else {
$DO_INSTALL = &prompt(<<"EOF", "y") unless ($DEFAULT);
You're running as root, so we can do the whole caboodle, including write out
the object file and patch your inetd's configuration files. If you say "n"
to this question, we'll just write out the object file.
If you are just patching an already existing and running HTTPi installation
(i.e. the changes are already in /etc/services and /etc/inetd.conf, and it's
going to go to the same install path), you should probably answer "n".
If you are starting from scratch -- nothing installed -- answer "y" unless
you really don't want inetd to know about HTTPi yet.
Do everything, including inetd.conf and services modifications?
EOF
$DO_INSTALL = ($DO_INSTALL eq 'y' && !$DEFAULT) ? 1 : 0;
}
if (!$DO_INSTALL) {
print <<"EOF";
Questions pertaining to inetd installation won't be asked by this script.
EOF
}
&firstchecks;
$DEF_SERV = &wherecheck("Verifying /etc/services", "/etc/services", <<"EOF");
Without /etc/services, your inetd won't know what port to run HTTPi on. You
*do* have inetd, don't you?
EOF
$DEF_INCONF = &wherecheck("Verifying /etc/inetd.conf", "/etc/inetd.conf",
<<"EOF");
Without /etc/inetd.conf, your inetd won't know what services should be
running and active. You *do* have inetd, don't you?
EOF
eval 'require "./conquests.pl";'; die(<<"EOF") if ($@);
Could not load conquests.pl, which is required as part of the standard
questions suite for all of the configure scripts. Please make sure it's in
the current directory.
($@)
EOF
if ($DO_INSTALL) {
print <<"EOF";
Now we're up to the inetd-relevant section. First, let's check to see if
you have NIS or YP here, because that can cause some trouble.
EOF
$j = &wherecheck("Finding domainname", "domainname");
if ($j) {
print "Phooey. Does it return anything? ...";
$q = '';
if(open(S, "$j|")) {
while(<S>) { chomp; $q .= $_ if ($_ ne '(none)'); }
}
if ($q ne '') {
$q = &prompt(<<"EOF", "");
yup ($q).
Blast and botheration.
Since I, a mere Perl programmer, am not versed in the mystical ways of NIS,
you're going to have to make sure that your NIS services file, if your
/etc/services file is kept in NIS, is properly updated with whatever service
name and port you choose to run this under. If /etc/inetd.conf is also kept
this way (!!!!!), then make analogous changes. Sorry.
Press ENTER to continue:
EOF
} else {
print <<"EOF";
nope. Well, that's a relief.
Still, there exists the possibility that I didn't detect things right. If you
are running NIS here, you may need to make changes to /etc/services and
/etc/inetd.conf, depending on your configuration, yourself.
EOF
}
} else {
print <<"EOF";
Just make sure you're not running NIS anyway, because any automated changes
I might make to your /etc/inetd.conf and /etc/services files if requested
might not stick otherwise. But if domainname isn't in your path, you probably
aren't.
EOF
}
}
$USER_ID = &prompt(<<"EOF", $ENV{'SUDO_USER'} || $ENV{'USER'} || 'nobody') unless (!$DO_INSTALL);
What user do you want the server to run as? If you select someone other than
'root', the server will not be able to change (e)uid to an executable's owner,
and you'll need to make sure the access log is writeable by that user.
On the other hand, if you select 'root', be forewarned this is a potential
security hole (to run *any* webserver as root, not just HTTPi).
What user do you want the script to run as?
EOF
$WAIT_MODE = &prompt(<<"EOF", "n") unless (!$DO_INSTALL);
A further bonus to slow systems is, because HTTPi runs out of inetd, the
ability to restrict the number of simultaneous HTTPis that can run. With
this set to a single process, the webserver can be practically invisible.
However, if you intend to put a little strain on HTTPi, this will not help
(and in fact make it worse on inetd), particularly with rude clients like
Netscape that insist on opening up multiple connections to a server.
The default is to have inetd open up one HTTPi process per open socket, and
kill each one off after it completes its job (answer no to this question).
Unless you're masochistic or have a real anal-retentive streak about CPU time
usage, the default is probably just fine.
Some inetds may not like the way HTTPi forks out client handlers, even though
it's still functionally a 'single instance'. If you answer 'y' and your HTTPi
hangs when you try to access it, you must disable this restriction ('n').
Restrict HTTPi to a single process?
EOF
$DEF_TCP_PORT = $PORT_NO = &prompt(<<"EOF", "80") unless (!$DO_INSTALL);
What numerical TCP port do you want the webserver to run on? 80 is the default
but if you're using configure to build multiple HTTPis on multiple ports,
make sure you give a different answer this time.
Which TCP port number?
EOF
if ($DO_INSTALL) {
print "Seeing what services you have for that port number ... ";
open(S, "/etc/services") || die(
"\n\nYou lied! I can't read /etc/services after all!\n\n");
while(<S>) {
chomp;
($serv, $port, $junk) = split(/\s+/, $_);
if ($port eq "$PORT_NO/tcp") {
print "$serv\nSo we'll use that.\n\n";
$SERV_NAME = $serv;
last;
}
}
if (!$SERV_NAME) {
$serv = 0; # so we remember
$SERV_NAME =
&prompt(<<"EOF", ($PORT_NO eq '80')?"www":"www$PORT_NO");
not found.
We must create one for you.
To run properly in inetd, /etc/services must contain a service mapped to
the TCP port number you chose ($PORT_NO). Each name must be unique to its
port number so that inetd can unambiguously decipher which goes where.
Avoid having multiple services mapped to the same port number -- it's really
very confusing.
Which service name?
EOF
}
print "Checking /etc/inetd.conf for competing services ... ";
open(S, "/etc/inetd.conf") || die("\nNo read access.\n\n");
$j = 0; while(<S>) {
/^$SERV_NAME\b/ && ($j = $_);
}
if ($j) {
print <<"EOF";
ack! I found one!:
$j
YOU WILL NEED TO EDIT /etc/inetd.conf AFTERWARDS, BEFORE YOU START THE
WEBSERVER UP! Otherwise, inetd will be very confused. Make sure you select
ONLY ONE -- either HTTPi's line or this one. You may need to re-run
configure and select a new port (configure will build the service for you).
EOF
} else {
print "none found.\nWhew!\n\n";
}
}
$j = &prompt(<<"EOF", "") unless (!$DO_INSTALL);
LAST CHANCE BEFORE CHANGES ARE COMMITTED!
If you continue beyond this point, configure will alter your /etc/services,
/etc/inetd.conf and place the new HTTPi build in $INSTALL_PATH.
If you want to continue, just press ENTER.
If you don't, press CTRL-C NOW!
EOF
$j = &prompt(<<"EOF", "") unless ($DO_INSTALL);
LAST CHANCE BEFORE CHANGES ARE COMMITTED!
If you continue beyond this point, configure will build your HTTPi and
overwrite any file currently at $INSTALL_PATH.
If you want to continue, just press ENTER.
If you don't, press CTRL-C NOW!
EOF
$INSTALL_PATH = &detaint($INSTALL_PATH);
print "Writing out the configured httpi to $INSTALL_PATH ... ";
(open(S, "httpi.in") && open(T, ">$INSTALL_PATH")) || die(<<"EOF");
Couldn't write out the new httpi. Check permissions on httpi.in in the
current directory and the destination path.
EOF
print T &preproc(\*S); close(T); close(S);
print "done.\n\n";
if ($DO_INSTALL) {
print "Need changes to /etc/services? ... ";
if (!$serv) {
print "yes, working ... ";
open(S, ">>/etc/services") || die(
"\n\nShee, still no write access.\n");
print S <<"EOF";
$SERV_NAME $PORT_NO/tcp # added by HTTPi install
$SERV_NAME $PORT_NO/udp # added by HTTPi install
EOF
close(S);
print "done.";
} else { print "no"; }
print "\n\nWriting changes to /etc/inetd.conf ... ";
open(S, ">>/etc/inetd.conf") || die(
"\n\nAre you really root? I can't write to this file.\n");
(@x) = split(/\//, $INSTALL_PATH);
$j = pop(@x);
$wmode = ($WAIT_MODE eq 'n') ? 'nowait' : 'wait';
print S <<"EOF";
# added by HTTPi install
$SERV_NAME stream tcp $wmode $USER_ID $INSTALL_PATH $j
EOF
close(S);
print "done.\n\nchmod()ding $INSTALL_PATH to 0755 ... ";
chmod 0755, "$INSTALL_PATH" || die("\n\nWhat the heck? Can't do it.\n");
print "done.\n\n";
print <<"EOF";
Successfully configured!
Now, you must send a HUP signal to your inetd process to enable the webserver.
AIX: refresh -s inetd
Most Un*xy things: killall -HUP inetd
If you don't have killall, find the PID with ps and kill -HUP that.
Remember to read the documentation for last minute information! Bye now.
EOF
exit; } else {
print <<"EOF";
Done.
IF THIS IS A FIRST-TIME INSTALL:
Note that no changes have been made to inetd, so the webserver will not
actually run yet. You will need to re-run as root and answer yes to the
first question for that to happen, or connect HTTPi in yourself.
IF NOT:
The changes should take effect on the webserver's next access (assuming it's
running).
Remember to read the documentation file for last minute information. Bye!
EOF
}
Jump to Line
Something went wrong with that request. Please try again.