1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742
|
#!/usr/bin/perl -w
$|=1;
# Copyright (C) 1997-1998 Johnie Ingram <johnie@debian.org>.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$HTTPD_CONF="/etc/apache/httpd.conf";
$HTTPD_EX="/usr/doc/apache/examples/httpd.conf";
$ACCESS_CONF="/etc/apache/access.conf";
$ACCESS_EX="/usr/doc/apache/examples/access.conf";
$SRM_CONF="/etc/apache/srm.conf";
$SRM_EX="/usr/doc/apache/examples/srm.conf";
$CRON_CONF="/etc/apache/cron.conf";
$CRON_EX="/usr/doc/apache/examples/cron.conf";
$MIME_CONF="/etc/apache/mime.types";
$MAILNAME_CONF="/etc/mailname";
$ALIASES_CONF="/etc/aliases";
$HOME_EX="/usr/doc/apache/intro.html";
$SERVER_ROOT="/etc/apache";
$PID_FILE="/var/run/apache.pid";
$write_httpdconf = 0;
$write_accessconf = 0;
$write_srmconf = 0;
$write_aliasesconf = 0;
$fix_webmaster = 0;
$changed = 0;
$q = 1;
use Getopt::Long;
$opt_assert_perl = 0;
$opt_force = 0;
$opt_force_modules = 0;
$opt_update = 0;
chomp ($arch = `dpkg --print-installation-architecture`);
chomp ($mailname = (-e $MAILNAME_CONF)
? `cat $MAILNAME_CONF` : "localhost");
###########################################################################
sub load_config_files ()
{
$main::httpdconf = `cat $HTTPD_CONF`;
$main::accessconf = `cat $ACCESS_CONF`;
$main::srmconf = `cat $SRM_CONF`;
$main::allconf = "$httpdconf\n$accessconf\n$srmconf";
($main::nonvirtconf = $allconf) =~ s/\n\s*<Virtual.*VirtualHost>//gs;
$main::aliasesconf = `cat $ALIASES_CONF 2> /dev/null`;
$main::servername = loadconf ("ServerName", "localhost");
$main::serveradmin = loadconf ("ServerAdmin", "webmaster");
$main::serveruser = loadconf ("User", "www-data");
$main::servergroup = loadconf ("Group", "www-data");
chomp (my $tmproot = `egrep "^www-data:" /etc/passwd | cut -f 6 -d :`);
$tmproot = "/var/www" if ($tmproot eq "");
$main::documentroot = loadconf ("DocumentRoot",
$tmproot, $SRM_CONF);
$main::serverport = loadconf ("Port", "80");
$main::version = system ("apache -l > /dev/null 2>&1")
? "1.1" : "1.3";
$main::version = "1.3" if (-f "/usr/lib/apache/1.3/libhttpd.so");
$main::serveruser =~ s/\#//g;
$main::servergroup =~ s/\#//g;
$main::servergroup = "www-data" if $main::servergroup =~ m/-/;
}
sub yorn ($;$)
{
$main::changed = 0;
my $result = $_[0];
my $morearg = "";
print $_[1] if defined $_[1];
($result) ? print " [Y/n] " : print " [y/N] ";
$arg = <STDIN>;
$result = 1 if ($arg =~ /^y/i);
$result = 0 if ($arg =~ /^n/i);
$q = 0 if ($arg =~ /q/i);
$main::changed = 1 unless ($result == $_[0]);
return $result;
}
sub answer ($;$)
{
$main::changed = 0;
my $arg;
my $default = $_[0];
print $_[1] if defined $_[1];
print " [$default] " if (defined ($default) && $default ne "");
chomp ($arg = `read REPLY; echo \$REPLY`);
if ($arg ne "")
{
$main::changed = 1;
return $arg;
}
return $default;
}
sub loadconf ($$;$)
{
my $parameter = $_[0];
my $default = $_[1];
my $file = (defined ($_[2]) ? $_[2] : "$HTTPD_CONF");
my $in = `egrep "^[:space:]*$parameter " $file 2> /dev/null| head -1`;
$in =~ s/\s*$parameter //;
chomp ($in);
return $in if ($in ne "");
return $default;
}
sub ensure_files ()
{
system ("mkdir -m 755 --parents /etc/apache");
if (! -e $HTTPD_CONF)
{
print "Installing new configuration file $HTTPD_CONF ...\n";
system ("cp $HTTPD_EX $HTTPD_CONF") && exit 1;
}
if (! -e $ACCESS_CONF)
{
print "Installing new configuration file $ACCESS_CONF ...\n";
system ("cp $ACCESS_EX $ACCESS_CONF") && exit 1;
}
if (! -e $SRM_CONF)
{
print "Installing new configuration file $SRM_CONF ...\n";
system ("cp $SRM_EX $SRM_CONF") && exit 1;
}
if (! -e $CRON_CONF)
{
print "Installing new configuration file $CRON_CONF ...\n";
system ("cp $CRON_EX $CRON_CONF") && exit 1;
}
if (! -e $MIME_CONF)
{
print "\nError: $MIME_CONF not found.\n";
print "Install the mime-support package, or copy the mime.types ";
print "from\n/usr/doc/apache/conf/mime.types.\n\n";
exit 1;
}
if (! -x "/usr/bin/savelog")
{
print "\nError: /usr/bin/savelog not found.\n";
print "Are you sure you're running a Debian system? :-)\n\n";
exit 1;
}
if (! -w $HTTPD_CONF)
{
print "\nError: $HTTPD_CONF not writable by userid.\n";
print "Who do you think you are, root? :-)\n\n";
exit 1;
}
}
sub make_corrections ()
{
my $icons = "/usr/share/apache/icons/";
my $oldcbin = "/usr/lib/httpd/cgi-bin";
my $cbin = "/usr/lib/cgi-bin";
my $doc = "/usr/doc/";
if (! ($httpdconf =~ m/^\s*ServerRoot\s+$SERVER_ROOT/m))
{
print "Correcting ServerRoot to $SERVER_ROOT in httpd.conf.\n";
$httpdconf =~ s/^\s*ServerRoot.*/ServerRoot $SERVER_ROOT/m;
$write_httpdconf++;
}
if (! ($srmconf =~ m/^\s*Alias\s+\/icons\/\s+$icons/m))
{
if (yorn (1, "\nThe icons Alias specifed in srm.conf is non-standard. Fix?"))
{
print "Correcting Alias to $icons in srm.conf.\n";
$srmconf =~ s/^\s*Alias\s+\/icons\/.*/Alias \/icons\/ $icons/m;
$write_srmconf++;
}
}
if (! ($srmconf =~ m/^\s*ScriptAlias\s+\/cgi-bin\/\s+$cbin\//m))
{
if (yorn (1, "\nThe cgi-bin ScriptAlias specifed in srm.conf is non-standard. Fix?"))
{
print "Correcting ScriptAlias to $cbin/ in srm.conf.\n";
$srmconf =~
s/^\s*ScriptAlias\s+\/cgi-bin\/.*/ScriptAlias \/cgi-bin\/ $cbin\//m;
$write_srmconf++;
}
}
if (! ($srmconf =~ m/.*Alias\s+\/doc\/\s+$doc/m))
{
if ($srmconf =~ m/^\s*Alias\s+\/doc/m)
{
print "Disabling...you need to rename your existing \/doc alias in srm.conf!\n";
$srmconf =~ s/^\s*Alias\s+\/doc(.*)/\n\#\# FIXME \#\# Alias \/doc$1\n\#\# The above line conflicts with webstandard 3.0, which specifies that \/doc\n\#\# refers to \/usr\/doc. Some packages may not work otherwise. -- apacheconfig\n\n/m;
}
print "Adding alias /doc/ -> $doc to srm.conf (for Debian docs).\n";
$srmconf =~ s/$/\n\n\# Added for Debian GNU\/Linux docs (webstandard 3.0).\n/s;
$srmconf =~ s/$/Alias \/doc\/ $doc\n/s;
$write_srmconf++;
}
if ($accessconf =~ m/.*Directory $oldcbin/m)
{
print "Correcting $oldcbin to $cbin in access.conf.\n";
$accessconf =~ s/$oldcbin/$cbin/mg;
$write_accessconf++;
}
if ($httpdconf =~ m/.*\/var\/log\/apache-httpd/m)
{
print "Correcting /var/log/apache-httpd to /var/log/apache in httpd.conf.\n";
$httpdconf =~ s/\/var\/log\/apache-httpd/\/var\/log\/apache/mg;
$write_httpdconf++;
}
if ($httpdconf =~ m/.*mod_browser/m)
{
print "Removing obsolete module mod_browser from httpd.conf.\n";
$httpdconf =~ s/^.*mod_browser.*\n//mg;
$write_httpdconf++;
}
if ($allconf =~ m/^\s*ScoreBoardFile/m)
{
print "Removing obsolecent directive ScoreBoardFile from httpd.conf.";
print " (Apache 1.3 uses shared memory)"
if ($main::version eq "1.3");
$httpdconf =~ s/.*ScoreBoardFile.*\n//mg;
$write_httpdconf++;
print ".\n";
}
if (! ($httpdconf =~ m/^\s*PidFile\s+$PID_FILE/m))
{
print "Correcting PidFile to $PID_FILE in httpd.conf.\n";
$httpdconf =~ s/^\s*PidFile.*/PidFile $PID_FILE/m;
$write_httpdconf++;
}
if ($httpdconf =~ m/Please keep this ClearModuleList: line/m)
{
print "Correcting magic ClearModuleList line to LoadModule.\n";
$httpdconf =~ s/Please keep this ClearModuleList: line/Please keep this LoadModule: line/m;
$write_httpdconf++;
}
if ($httpdconf =~ m/^\s*ServerAdmin\s*you.*address/mi)
{
$write_httpdconf++;
$fix_webmaster++;
}
$write_httpdconf++ if ($httpdconf =~ m/mod_browser/mi);
}
sub make_directory ($)
{
if (! -d $_[0])
{
system ("mkdir --parents --mode=755 $_[0]")
|| print "Created directory $_[0].\n";
}
print "Fixing: ";
system ("chown --verbose root.$main::servergroup $_[0]");
}
sub config_documentroot ()
{
if (! defined ($opt_documentroot))
{
print "\nThe Apache server will serve documents from a directory called ";
print "the\ndocument root or server root. You must specify such a ";
print "directory for\nthe server to work: /var/www is recommended.\n\n";
do {
$documentroot = answer ($documentroot,
"What should the DocumentRoot be?");
$srmconf =~ s/^\s*DocumentRoot.*/DocumentRoot $documentroot/m;
$write_srmconf++ if $changed;
make_directory ($documentroot) if (! -x $documentroot);
} until (-d $documentroot);
}
else
{
$documentroot = $opt_documentroot;
$main::srmconf =~ s/^\s*DocumentRoot.*/DocumentRoot $documentroot/m;
print "The DocumentRoot is set to $documentroot.\n";
make_directory ($documentroot) if (! -x $documentroot);
$write_srmconf++;
}
chomp ($indexfile = `ls $documentroot/index.* 2> /dev/null | head -1`);
if ($indexfile eq "")
{
print "Installing your new homepage in $documentroot.\n";
system ("cp -p -i $HOME_EX $documentroot/index.html && chmod 644 $documentroot/index.html");
}
else
{
print "Leaving existing site $indexfile untouched.\n";
}
}
sub config_serveradmin ()
{
if (! defined ($opt_serveradmin))
{
print "\nEnter the email address of your server administrator. This ";
print "address \nwill be used in error messages allowing users to submit ";
print "reports of\nfaulty links or misconfigured cgi-programs to you. ";
print "It should be an email\naddress that corresponds to a human.\n\n";
$main::serveradmin = "$main::serveradmin\@$mailname"
if (! $main::serveradmin =~ m/@/);
$main::serveradmin = answer ($main::serveradmin,
"Who should the ServerAdmin be?");
}
else
{
$main::serveradmin = $opt_serveradmin;
print "The ServerAdmin is set to $main::serveradmin.\n";
$changed++;
}
$httpdconf =~ s/^\s*ServerAdmin.*/ServerAdmin $main::serveradmin/m;
$write_httpdconf++ if $changed;
# if ($aliasesconf =~ m/^\s*webmaster/im)
# {
# if (! ($aliasesconf =~ m/^\s*webmaster.*$main::serveradmin/im))
# {
# if (yorn (1, "Correct the webmaster mail alias to this address?"))
# {
# $aliasesconf =~
# s/^\s*webmaster.*/webmaster: $main::serveradmin/m;
# $write_aliasesconf++;
# }
# }
# }
# else
# {
# if (yorn (1, "Create a webmaster mail alias for this address?"))
# {
# $write_aliasesconf++;
# $aliasesconf =~ s/$/\n\n\# Maintainer of the Web server\n/s;
# $aliasesconf =~ s/$/webmaster: $main::serveradmin\n/s;
# }
# }
}
sub config_servername ()
{
return unless $main::nonvirtconf =~ /^\s*ServerName /m;
if (! defined ($opt_servername))
{
print "\nYou may want to choose the publicized name for your server. ";
print "This name\nis used to make the server report itself as being ";
print "someone else, for\nexample to replace $mailname by www.$mailname ";
print "which looks nicer.\nPlease note that you may still need to make ";
print "sure this alternative name\nwill be recognized by the Domain Name ";
print "Service if you want your\nserver to be reached!\n\n";
$servername = answer ($servername, "What should the ServerName be?");
}
else
{
$servername = $opt_servername;
print "The ServerName is set to $servername.\n";
$changed++;
}
$httpdconf =~ s/^\s*ServerName.*/ServerName $servername/m;
$write_httpdconf++ if $changed;
}
sub config_serverport ()
{
if (! defined ($opt_port))
{
print "\nPlease choose a port number on which the Apache server will ";
print "listen\nfor incoming connections. This port number is usually ";
print "80, but you\nmay want to choose another one if you have another ";
print "server already\nlistening on that port, or if you want to listen ";
print "on an unprivileged\nport; in this case, the port 8080 might be a ";
print "good choice.\n\n";
$serverport = answer ($serverport, "What port should Apache listen on?");
}
else
{
$serverport = $opt_port;
print "The Port is set to $serverport.\n";
$changed++;
}
$httpdconf =~ s/^\s*Port.*/Port $serverport/m;
$write_httpdconf++ if $changed;
}
sub find_suitable_modules (;$)
{
$v = (defined ($_[0])) ? $_[0] : $main::version;
my $d = ($v eq "1.3") ? "/usr/lib/apache/1.3" : "/usr/lib/apache/modules";
my $k= ($v eq "1.3") ? "LoadModule.*apache/1.3|AddModule" : "LoadModule.*apache/module";
my $m = `egrep -l "$k" $d/*.info 2> /dev/null`;
return split ("\n", $m);
}
sub module_required ($;$)
{
my $l;
my $directives = 0;
my $handles = 0;
my $types = 0;
my $needed = 0;
my $verbose = (defined ($_[1])) ? $_[1] : 0;
(-f $_[0]) || return 0;
my @file = split ("\n", `cat $_[0]`);
print "$_[0]\n" if $verbose;
foreach $l (@file)
{
chomp ($l);
($directives = 1, next) if ($l =~ m/^Directives:/);
($directives = 0, next) if ($l =~ m/^\w/);
if ($directives && $l =~ m/^ \w/)
{
$l =~ s/^ //;
$l =~ s/ .*//;
print " directive: \"$l\"" if $verbose;
if ($main::allconf =~ m/^\s*$l\W/m)
{
$needed++ ;
print " *" if $verbose;
}
print "\n" if $verbose;
}
}
foreach $l (@file)
{
chomp ($l);
($handles = 1, next) if ($l =~ m/^Handles:/);
($handles = 0, next) if ($l =~ m/^\w/);
if ($handles && $l =~ m/^ \w/)
{
$l =~ s/^ //;
$l =~ s/ .*//;
print " handler: \"$l\"" if $verbose;
if ($main::allconf =~ m/^\s*\w*Handler\s*$l/m)
{
$needed++;
print " *" if $verbose;
}
print "\n" if $verbose;
}
}
foreach $l (@file)
{
chomp ($l);
($types = 1, next) if ($l =~ m/^MimeTypes:/);
($types = 0, next) if ($l =~ m/^\w/);
if ($types && $l =~ m/^ \w/)
{
$l =~ s/^ //;
$l =~ s/ .*//;
print " type: \"$l\"" if $verbose;
if ($main::allconf =~ m/^\s\w*Type\s*$l\W/m)
{
$needed++;
print " *" if $verbose;
}
print "\n" if $verbose;
}
}
return $needed;
}
sub get_description ($)
{
chomp (my $desc = `egrep "^Description: " $_[0]`);
$desc =~ s/Description: //;
return $desc;
}
sub get_module_line ($)
{
my $k= ($main::version eq "1.3") ?
"LoadModule.*apache/1.3|AddModule" : "LoadModule.*apache/module";
chomp (my $l = `egrep "^$k" $_[0]`);
$l =~ s/LoadModule: /LoadModule /;
$l =~ s/AddModule: /AddModule /;
return $l;
}
sub update_modules ($)
{
$_[0] =~ s/^\n//m;
if ($main::httpdconf =~ m/The way lines are.*Debian.*such hashes\./s)
{
$main::httpdconf =~
s/\# The way lines.*will use such hashes\.\n\#\n//s;
}
print "Pondering.";
foreach $m (find_suitable_modules ("1.1"))
{
chomp (my $l = `egrep "^LoadModule:.*\/1.3\/" $m | cut -f 2 -d " "`);
$main::httpdconf =~ s/.*LoadModule .*$l.*\n//mg;
print ".";
}
foreach $m (find_suitable_modules ("1.3"))
{
chomp ($l = `egrep "^AddModule: " $m`);
$l =~ s/AddModule: //;
$main::httpdconf =~ s/.*AddModule $l.*\n//mg;
print ".";
}
print "done.\n";
my $l = "LoadModule";
$main::httpdconf =~ s/^\s*ClearModuleList.*\n//m;
$main::httpdconf =~ s/^\s*AddModule.*\n//mg; # NEW
$main::httpdconf =~ s/^\s*LoadModule.*\n//mg; # NEW
$main::httpdconf =~ s/^\# LoadModule.*\n//mg; # NEW
$main::httpdconf =~
s/Please keep.*$l.*installation.\n/Please keep this $l: line here, it is needed for installation\.\n$_[0]/s;
$main::write_httpdconf++;
}
sub module_standard ($)
{
return 1 if $_[0] =~ m/mod_auth\./;
return 1 if $_[0] =~ m/mod_expires\./;
return 1 if (($_[0] =~ m/mod_rewrite\./) && ($arch ne "sparc"));
return 1 if $_[0] =~ m/mod_dlopen\./;
return 1 if $_[0] =~ m/mod_so\./;
return 1 if $_[0] =~ m/mod_unique_id\./;
return 0;
}
sub config_modules ()
{
my $moddl = 0;
# my $mlist = ($main::version eq "1.3") ? "ClearModuleList\n\n" : "\n";
$mlist = "\n";
if (! $opt_force_modules)
{
print "\nThis release of the Apache server can be configured to load ";
print "only certain\nmodules into memory. This program can automagically ";
print "configure Apache\nso only modules that are actually needed are ";
print "loaded.\n\n";
}
else
{
print "\n";
}
$q = yorn (0, "Do you want to manually choose which modules to load?");
($q) ? print "\n" : print "Working magic.";
foreach $m (find_suitable_modules ())
{
print "." unless $q;
my $x = module_required ($m, 0);
my $std = module_standard ($m);
my $l = get_module_line ($m);
next if ($moddl && $l =~ /mod_dl/);
if ($q)
{
my $t = get_description ($m);
my $r = ($x) ? " [required]" : "";
$r = ($std) ? " [standard]" : $r;
(yorn (($x + $std), "$t$r?"))
? $mlist =~ s/$/$l\n/ : $mlist =~ s/$/\# $l\n/;
}
else
{
($x || $std)
? $mlist =~ s/$/$l\n/ : $mlist =~ s/$/\# $l\n/;
}
$moddl = 1 if ($l =~ /mod_dl/);
}
print "done." unless $q;
print "\n\n$mlist\n";
update_modules ($mlist);
}
sub offer_early_exit ()
{
return if ($opt_force || $opt_force_modules);
if (! $write_httpdconf && ! $write_accessconf && ! $write_srmconf)
{
if (yorn (1, "A valid Apache configuration exists. Use it?"))
{
if (yorn (1, "Restart Apache now?"))
{
if (-x "/usr/sbin/apachectl")
{
system ("/usr/sbin/apachectl stop");
sleep 10;
system ("/usr/sbin/apachectl start");
}
else
{
system ("/etc/init.d/apache reload-modules");
}
}
exit 0;
}
$opt_update = 0;
}
print "An Apache configuration exists, but needs some tweaking.\n"
if ($write_httpdconf);
}
###########################################################################
GetOptions ("force!",
"assert-perl!",
"force-modules!",
"update!",
"serveradmin=s",
"servername=s",
"documentroot=s",
"port=i");
exit 0 if $opt_assert_perl;
ensure_files ();
load_config_files ();
make_corrections ();
offer_early_exit () if ($opt_update);
if (! $opt_force_modules)
{
print "\nYour config files will not be modified until you select Y at \"save changes.\"\n";
config_serveradmin () unless ($opt_update && !$fix_webmaster);
config_documentroot ()
unless ($write_httpdconf + $write_accessconf + $write_srmconf == 0);
config_servername () unless ($opt_update);
config_serverport () unless ($opt_update);
}
config_modules ();
if (! yorn (1, "\nSave these changes to the configuration files?"))
{
print "\nWhew! No changes were made.\n\n";
exit 0;
}
print "\n";
if ($write_httpdconf)
{
system ("savelog -c 100 $HTTPD_CONF")
&& die ("couldn't rotate $HTTPD_CONF");
open (CONF, ">$HTTPD_CONF") || die ("couldn't open $HTTPD_CONF");
print CONF $httpdconf;
close (CONF);
}
if ($write_accessconf)
{
system ("savelog -c 100 $ACCESS_CONF")
&& die ("couldn't rotate $ACCESS_CONF");
open (CONF, ">$ACCESS_CONF") || die ("couldn't open $ACCESS_CONF");
print CONF $accessconf;
close (CONF);
}
if ($write_srmconf)
{
system ("savelog -c 100 $SRM_CONF")
&& die ("couldn't rotate $SRM_CONF");
open (CONF, ">$SRM_CONF") || die ("couldn't open $SRM_CONF");
print CONF $srmconf;
close (CONF);
}
if ($write_aliasesconf)
{
print "Writing $main::serveradmin to $ALIASES_CONF ...\n";
system ("savelog -c 100 $ALIASES_CONF")
&& die ("couldn't rotate $ALIASES_CONF");
open (CONF, ">$ALIASES_CONF") || die ("couldn't open $ALIASES_CONF");
print CONF $aliasesconf;
close (CONF);
if (-x "/usr/bin/newaliases" || -x "/usr/sbin/newaliases")
{
system ("newaliases");
}
elsif (-x "/usr/bin/mkaliases" || -x "/usr/sbin/mkaliases")
{
system ("mkaliases");
}
else
{
print "Could not guess how to update aliases -- rebuild manually!\n";
}
}
if (yorn (1, "Restart Apache now?"))
{
if (-x "/usr/sbin/apachectl")
{
exec ("/usr/sbin/apachectl graceful");
}
else
{
exec ("/etc/init.d/apache reload-modules");
}
}
exit 0;
|