summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorent Villard <warly@mandriva.com>2003-02-28 12:02:14 +0000
committerFlorent Villard <warly@mandriva.com>2003-02-28 12:02:14 +0000
commite50ac7719ada4befb44f5e5ae57f5c3cd4ff2e68 (patch)
tree542ea2e5e5f74b5be4941ae7e93b702c86a7064d
parent74b7c7d175e148500cf987f8d18ea8f7c981d848 (diff)
downloaddrakwizard-e50ac7719ada4befb44f5e5ae57f5c3cd4ff2e68.tar
drakwizard-e50ac7719ada4befb44f5e5ae57f5c3cd4ff2e68.tar.gz
drakwizard-e50ac7719ada4befb44f5e5ae57f5c3cd4ff2e68.tar.bz2
drakwizard-e50ac7719ada4befb44f5e5ae57f5c3cd4ff2e68.tar.xz
drakwizard-e50ac7719ada4befb44f5e5ae57f5c3cd4ff2e68.zip
try to add apache2 module and fix apache one
-rw-r--r--web_wizard/Makefile1
-rw-r--r--web_wizard/apache2.wiz2
-rw-r--r--web_wizard/scripts/Apache2conf.pm119
-rw-r--r--web_wizard/scripts/Webconf.pm14
4 files changed, 133 insertions, 3 deletions
diff --git a/web_wizard/Makefile b/web_wizard/Makefile
index b105f592..e9bb39b2 100644
--- a/web_wizard/Makefile
+++ b/web_wizard/Makefile
@@ -17,4 +17,5 @@ install:
install --mode=a=r -p ./images/apache.png ${prefix}/share/wizards/web_wizard/images
install --mode=u=rwx,g=rx,o=rx -p scripts/*.sh ${prefix}/share/wizards/web_wizard/scripts
install --mode=u=rw,g=r,o=r -p scripts/Webconf.pm ${prefix}/share/wizards/web_wizard/scripts
+ install --mode=u=rw,g=r,o=r -p scripts/Apache2conf.pm ${prefix}/share/wizards/web_wizard/scripts
diff --git a/web_wizard/apache2.wiz b/web_wizard/apache2.wiz
index bb7ec2c3..51de8c9a 100644
--- a/web_wizard/apache2.wiz
+++ b/web_wizard/apache2.wiz
@@ -7,7 +7,7 @@
wizardTitle="Web wizard"
imagePosition="top"
defaultImage="__WIZ_HOME__/web_wizard/images/apache.png"
- perlModule="__WIZ_HOME__/web_wizard/scripts/Webconf.pm"
+ perlModule="__WIZ_HOME__/web_wizard/scripts/Apache2conf.pm"
rpm="apache2"
summaryFunc="do_it"
>
diff --git a/web_wizard/scripts/Apache2conf.pm b/web_wizard/scripts/Apache2conf.pm
new file mode 100644
index 00000000..b538fe74
--- /dev/null
+++ b/web_wizard/scripts/Apache2conf.pm
@@ -0,0 +1,119 @@
+#!/usr/bin/perl
+
+package Apache2conf;
+require "__WIZ_HOME__/common/scripts/Varspaceval.pm";
+require "__WIZ_HOME__/common/scripts/IFCFG.pm";
+use MDK::Common;
+
+use strict;
+
+my $o = IFCFG->new();
+
+sub check {
+ $> and return 1;
+ $o->is_dhcp() and return 2;
+ 0;
+}
+
+my $file = "/etc/httpd/conf/httpd2.conf";
+my $root;
+
+if (-f $file) {
+ open(FH, "< $file") or die "$! ($file)";
+ while (<FH>) {
+ if (/^\s*\#?\s*DocumentRoot\s+(.*)/) {
+ close(FH);
+ $root = "$1";
+ last;
+ }
+ }
+ close(FH);
+}
+
+sub get_docroot {
+ $root;
+}
+
+sub check_dir {
+ -d ($ENV{wiz_dir}) and return 10;
+ 1;
+}
+
+sub chg_docroot {
+ my $old;
+ substInFile {
+ s|(^\s*\#?\s*DocumentRoot\s*)(\S*).*|$1$ENV{wiz_dir}| and $old ||=$2;
+ } "/etc/httpd/conf/httpd2.conf";
+
+ print "DEBUG $old";
+ substInFile {
+ s|^\s*<Directory\s*$old/?>|<Directory $ENV{wiz_dir}>|;
+ } "/etc/httpd/conf/commonhttpd.conf" if $old;
+
+ substInFile {
+ s|^\s*<Directory\s*/var/www/html/?>|<Directory $ENV{wiz_dir}>|;
+ } "/etc/httpd/conf/commonhttpd.conf";
+}
+
+sub is_user_mod {
+ if ($ENV{wiz_user_mod}) {
+ return 1;
+ }
+ $ENV{wiz_user_dir} = "disabled";
+ 0;
+}
+
+sub is_last_user_mod {
+ my $root = get_user_dir();
+ chomp($root);
+ !($root eq 'disabled');
+}
+
+sub get_user_dir {
+ my %conf = Varspaceval->get("/etc/httpd/conf/commonhttpd.conf");
+ $conf{UserDir};
+}
+
+sub chg_user_dir {
+ my $root = get_user_dir();
+ if ($ENV{wiz_user_mod}) {
+ substInFile {
+ s|(/home/\*/)$root(/?)|$1$ENV{wiz_user_dir}$2|g;
+ } "/etc/httpd/conf/commonhttpd.conf";
+ substInFile {
+ s|(\s*)UserDir\s*$root(/?)|$1UserDir $ENV{wiz_user_dir}$2|g;
+ s|(/home/\*/)$root(/?)|$1$ENV{wiz_user_dir}$2|g;
+ } "/etc/httpd/conf/commonhttpd.conf";
+ }
+ else {
+ substInFile {
+ s|(\s*)UserDir\s*$root(/?)|$1UserDir disabled$2|g;
+ } "/etc/httpd/conf/commonhttpd.conf";
+ }
+ 10;
+}
+
+sub do_it {
+ my $file = "/etc/httpd/conf/commonhttpd.conf";
+ my $that = "localhost";
+
+ if ($ENV{wiz_web_external} eq "1") {
+ $that = "all";
+ }
+ elsif ($ENV{wiz_web_internal} eq "1") {
+ ($that) = $o->itf_get("IPADDR") =~ qr/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.)\d{1,3}$/;
+ $that .= " 127.0.0.1";
+ }
+ cp_af($file, $file.".orig");
+ substInFile {
+ if( m /^\s*<Directory.*>/s...m/^\s*<\/Directory>/s ) {
+ { s /^\s*Allow .*$/ Allow from $that\n/s;}
+ ;}
+ } $file;
+ chg_docroot();
+ chg_user_dir();
+ system("/etc/rc.d/init.d/httpd restart");
+ 10;
+}
+
+1;
diff --git a/web_wizard/scripts/Webconf.pm b/web_wizard/scripts/Webconf.pm
index 4da50a82..a787ac37 100644
--- a/web_wizard/scripts/Webconf.pm
+++ b/web_wizard/scripts/Webconf.pm
@@ -15,7 +15,7 @@ sub check {
0;
}
-my $file = "/etc/httpd/conf/commonhttpd.conf";
+my $file = "/etc/httpd/conf/httpd.conf";
my $root;
if (-f $file) {
@@ -40,8 +40,18 @@ sub check_dir {
}
sub chg_docroot {
+ my $old;
substInFile {
- s|(^\s*\#?\s*DocumentRoot\s*).*|$1$ENV{wiz_dir}|;
+ s|(^\s*\#?\s*DocumentRoot\s*)(\S*).*|$1$ENV{wiz_dir}| and $old ||=$2;
+ } "/etc/httpd/conf/httpd.conf";
+
+ print "DEBUG $old";
+ substInFile {
+ s|^\s*<Directory\s*$old/?>|<Directory $ENV{wiz_dir}>|;
+ } "/etc/httpd/conf/commonhttpd.conf" if $old;
+
+ substInFile {
+ s|^\s*<Directory\s*/var/www/html/?>|<Directory $ENV{wiz_dir}>|;
} "/etc/httpd/conf/commonhttpd.conf";
}