summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile26
-rwxr-xr-xWiztemplate.pm95
-rwxr-xr-xclient_wizard/Bind_client.pm181
-rw-r--r--client_wizard/Makefile15
-rw-r--r--common/IFCFG.pm88
-rw-r--r--common/Varspaceval.pm88
-rw-r--r--common/Wizcommon.pm39
-rw-r--r--data/Client.desktop.in4
-rw-r--r--data/DHCP.desktop.in4
-rw-r--r--data/DNS.desktop.in4
-rw-r--r--data/Time.desktop.in4
-rw-r--r--data/Web.desktop.in4
-rw-r--r--data/ftp.desktop.in4
-rw-r--r--data/news.desktop.in4
-rw-r--r--data/postfix.desktop.in4
-rw-r--r--data/proxy.desktop.in4
-rw-r--r--data/samba.desktop.in4
-rwxr-xr-xdhcp_wizard/Dhcp.pm230
-rw-r--r--dhcp_wizard/scripts/Dhcpconf.pm4
-rwxr-xr-xdrakwizard.pl508
-rw-r--r--drakwizard.spec11
-rwxr-xr-xftp_wizard/Proftpd.pm95
-rwxr-xr-xnews_wizard/Inn.pm95
-rwxr-xr-xpostfix_wizard/Postfix.pm187
-rwxr-xr-xproxy_wizard/Squid.pm95
-rwxr-xr-xsamba_wizard/Samba.pm95
-rwxr-xr-xweb_wizard/Apache.pm242
-rw-r--r--web_wizard/scripts/Apache2conf.pm1
28 files changed, 1648 insertions, 487 deletions
diff --git a/Makefile b/Makefile
index 212a342f..a4a8ceeb 100644
--- a/Makefile
+++ b/Makefile
@@ -5,9 +5,11 @@ TAR = $(NAME).tar.bz2
# TODO: get WIZ_HOME take care of usr prefix
WIZ_HOME=/usr/share/wizards
-WIZ = common\
- server_wizard\
- dhcp_wizard\
+PERL_VENDORLIB=$(shell eval "`perl -V:installvendorlib`"; installvendorlib=$${installvendorlib\#/usr}; echo $$installvendorlib)
+
+WIZ = dhcp_wizard\
+ client_wizard\
+ server_wizard\
dns_wizard\
postfix_wizard\
samba_wizard\
@@ -15,12 +17,11 @@ WIZ = common\
web_wizard\
ftp_wizard\
news_wizard\
- client_wizard\
- db_wizard\
proxy_wizard\
- nfs_wizard\
- data\
- po
+ nfs_wizard
+
+OTHER = data\
+ po
all:
@@ -28,10 +29,17 @@ all:
install:
mkdir -p ${prefix}/sbin
+ mkdir -p --mode=u=rwx,g=rx,o=rx ${prefix}/share/wizards/client_wizard/images
+ mkdir -p ${prefix}/$(PERL_VENDORLIB)/MDK/Wizard/
install -p drakwizard.pl ${prefix}/sbin/drakwizard
perl -i -pe "s|__WIZ_HOME__|$(WIZ_HOME)/|g" ${prefix}/sbin/drakwizard
+ for l in $(OTHER); do \
+ $(MAKE) -C $$l $@; \
+ done
+ install --mode=u=rw,g=r,o=r -p common/*.pm ${prefix}/$(PERL_VENDORLIB)/MDK/Wizard/; \
for l in $(WIZ); do \
- $(MAKE) -C $$l $@; \
+ install --mode=u=rw,g=r,o=r -p $$l/*.pm ${prefix}/$(PERL_VENDORLIB)/MDK/Wizard/; \
+ install --mode=a=r -p $$l/images/*.png ${prefix}/share/wizards/client_wizard/images; \
done
find ${prefix}/share/wizards -type f -regex ".*\.wiz$$\|.*.pm$$\|.*\.sh$$" -exec \
perl -i -pe "s|__WIZ_HOME__|$(WIZ_HOME)|g" \{\} \;
diff --git a/Wiztemplate.pm b/Wiztemplate.pm
new file mode 100755
index 00000000..9392ce03
--- /dev/null
+++ b/Wiztemplate.pm
@@ -0,0 +1,95 @@
+#!/usr/bin/perl
+
+# Drakwizard
+
+# Copyright (C) 2002 Arnaud Desmons <adesmons@mandrakesoft.com>
+# Copyright (C) 2003 Florent Villard <warly@mandrakesoft.com>
+#
+# 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+package WizTemplate;
+use strict;
+
+use standalone;
+use interactive;
+use common;
+require "MDK/Wizard/IFCFG.pm";
+
+my $net = new IFCFG;
+
+my $o = {
+ name => N('configuration wizard'),
+ var => {
+ ip1 => '',
+ ip2 => ''
+ }
+ };
+
+$o->{pages} = {
+ welcome => {
+ name => N('') . "\n\n" . N('') . "\n\n" . N(''),
+ no_back => 1,
+ next => 'config'
+ },
+ confige => {
+ name => N('') . "\n\n" . N('') . "\n\n" . N(''),
+ pre => sub {
+ $o->{var}{ip1} ||= f1();
+ $o->{var}{ip2} ||= f2();
+ },
+ post => \&check,
+ data => [
+ { label => '' },
+ { label => N(''), val => \$o->{var}{ip1} },
+ { label => N(''), val => \$o->{var}{ip2} },
+ ],
+ next => 'summary'
+ },
+ warning => {
+ name => N('Warning.'),
+ data => [ { label => N('') } ],
+ next => 'summary'
+ },
+ error => {
+ name => N('Error.'),
+ data => [ { label => N('') } ],
+ next => 'config'
+ },
+ summary => {
+ name => N('') . "\n\n" . N('') . "\n\n" . N(''),
+ data => [
+ { label => N(''), fixed_val => \$o->{var}{ip1} },
+ { label => '' },
+ { label => N(''), fixed_val => \$o->{var}{ip2} },
+ ],
+ post => \&do_it,
+ next => 'end'
+ },
+ end => {
+ name => N('Congratulation'),
+ data => [ { label => N('') } ],
+ end => 1,
+ next => 0
+ },
+};
+
+sub new {
+ my ($class, $conf) = @_;
+ bless {
+ o => $o,
+ }, $class;
+}
+
+1;
diff --git a/client_wizard/Bind_client.pm b/client_wizard/Bind_client.pm
new file mode 100755
index 00000000..4eff26d8
--- /dev/null
+++ b/client_wizard/Bind_client.pm
@@ -0,0 +1,181 @@
+#!/usr/bin/perl
+
+# Drakwizard
+
+# Copyright (C) 2002 Arnaud Desmons <adesmons@mandrakesoft.com>
+# 2003 Florent Villard <warly@mandrakesoft.com>
+#
+# 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+package Bind_client;
+use strict;
+
+use standalone;
+use interactive;
+use common;
+use MDK::Wizard::Wizcommon;
+
+my $wiz = new Wizcommon;
+my $wiz_ip_server = $wiz->{net}->itf_get("IPADDR");
+my $wiz_domain_name = $wiz->{net}->network_get("DOMAINNAME");
+
+my $o = {
+ name => N('DNS Client Wizard'),
+ var => {
+ client_ip => '',
+ client_name => ''
+ },
+ needed_rpm => [ ]
+ };
+
+$o->{pages} = {
+ welcome => {
+ name => N('DNS Client Wizard') . "\n\n" . N('A client of your local network is a machine connected to the network having its own name and IP number.') . "\n\n" . N('This wizard will help you in adding a new client in your local DNS.') . "\n\n" . N('The server will use the informations you enter here to make the name of the client available to other machines into your network.') . "\n\n" . N('Press next to begin, or Cancel to leave this wizard.'),
+ post => sub { $wiz->check_dhcp },
+ no_back => 1,
+ next => 'client_id'
+ },
+ client_id => {
+ name => N('Client identification:') . "\n\n" . N('Your client on the network will be identified by name, as in clientname.company.net. Every machine on the network must have a (unique) IP address, in the usual dotted syntax.') . "\n\n" . N("(you don't need to type the domain after the name)") . "\n\n" . N('Note that the given IP number and client name should be unique in the network.'),
+ pre => sub {
+ $o->{var}{client_ip} = ip();
+ $o->{var}{client_name} = name();
+ },
+ post => \&check,
+ data => [
+ { label => '' },
+ { label => N('Name of the machine:'), val => \$o->{var}{client_name} },
+ { label => N('IP number of the machine:'), val => \$o->{var}{client_ip} },
+ ],
+ next => 'summary'
+ },
+ dhcp_warning => {
+ name => N('Warning'),
+ data => [ { label => N('You are in dhcp, server may not work with your configuration.') } ],
+ next => 'client_id'
+ },
+ system_error => {
+ name => N('Error'),
+ data => [ { label => N('System error, no configuration done') } ],
+ next => 'client_id'
+ },
+ error => {
+ name => N('Error'),
+ data => [ { label => N('This is not a valid address... press next to continue') } ],
+ next => 'client_id'
+ },
+ summary => {
+ name => N('Adding a new client to your network') . "\n\n" . N('The wizard collected the following parameters needed to add a client to your network:') . "\n\n" . N('To accept these values, and add your client, click the Next button or use the Back button to correct them.'),
+ data => [
+ { label => N('Client name'), fixed_val => \$o->{var}{client_name} },
+ { label => '' },
+ { label => N('Client IP:'), fixed_val => \$o->{var}{client_ip} },
+ ],
+ post => \&do_it,
+ next => 'end'
+ },
+ end => {
+ name => N('Congratulations'),
+ data => [ { label => N('The wizard successfully added the client.') } ],
+ end => 1,
+ next => 0
+ },
+};
+
+sub check_dhcp {
+ $wiz->{net}->is_dhcp() and return 'dhcp_warning';
+}
+
+sub name {
+ $wiz->{net}->network_get("HOSTNAME");
+}
+
+sub ip {
+ $wiz_ip_server;
+}
+
+sub get_root {
+ my $file = "/etc/sysconfig/named";
+ if (-f $file) {
+ my %mdk = Vareqval->get($file);
+ return $mdk{ROOTDIR};
+ }
+ "";
+}
+
+sub up_serial {
+ my ($file) = @_;
+
+ my (undef, undef, undef, $mday, $mon, $year) = gmtime(time);
+ $year += 1900;
+ my $serial_nbm = sprintf "%4dY%2dm%2d00", $year, $mon, $mday;
+ output($file, map {
+ my $line = $_;
+ if (/^(\s*)(\d*)(\s*;\s*Serial.*)$/) {
+ my $serial_f = $2;
+ $serial_f++;
+ if ($serial_f <= $serial_nbm) {
+ $serial_f = $serial_nbm;
+ chomp($serial_f);
+ $line = "$1$serial_f$3\n";
+ }
+ }
+ $line;
+ } cat_($file));
+}
+
+sub test {
+ !$o->{client_name} and return 1;
+ !$o->{client_ip} and return 1;
+ my $s_trunc = "$1.$2.$3" if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
+ my $ds = "$4" if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
+ my $dc = "$4" if $ENV{wiz_client_ip} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
+ my $sc_trunc = "$1.$2.$3" if $ENV{wiz_client_ip} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
+ (!$sc_trunc || !$dc || !$ds || !$s_trunc || ($s_trunc != $sc_trunc) || ($dc == $ds || $dc < 0 || $dc > 255)) and return 'error';
+}
+
+sub do_it {
+ $::DEBUG and return;
+ my $date = `date`;
+ chomp($date);
+ my $wiz_ip_net = "$1.$2.$3.0" if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
+ my $s_trunc = "$1.$2.$3" if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
+ my $ds = "$4" if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
+ my $dc = "$4" if $ENV{wiz_client_ip} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
+
+ my $file="/var/named/$wiz_domain_name.db";
+ MDK::Common::cp_af($file, $file.".orig");
+ open(NEW, ">> $file") or die "can not open $file";
+ print NEW "\n$ENV{wiz_client_name} IN A $ENV{wiz_client_ip} ; $date";
+ close(NEW) or die "can not close $file";
+ up_serial($file);
+
+ my $file="/var/named/$s_trunc.rev";
+ MDK::Common::cp_af($file, $file.".orig");
+ open(NEW, ">> $file") or die "can not open $file";
+ print NEW "\n$dc IN PTR $ENV{wiz_client_name}. ; $date";
+ close(NEW) or die "can not close $file";
+ up_serial($file);
+ system("/etc/rc.d/init.d/named restart");
+}
+
+sub new {
+ my ($class, $conf) = @_;
+ bless {
+ o => $o,
+ }, $class;
+}
+
+1;
diff --git a/client_wizard/Makefile b/client_wizard/Makefile
index 24472efe..bf0d1746 100644
--- a/client_wizard/Makefile
+++ b/client_wizard/Makefile
@@ -1,17 +1,8 @@
-
install2:
su -c 'make install'
install:
- mkdir -p --mode=u=rwx,g=rx,o=rx ${prefix}/share/wizards
- mkdir -p --mode=u=rwx,g=rx,o=rx ${prefix}/share/wizards/client_wizard
- mkdir -p --mode=u=rwx,g=rx,o=rx ${prefix}/share/wizards/client_wizard/scripts
mkdir -p --mode=u=rwx,g=rx,o=rx ${prefix}/share/wizards/client_wizard/images
- install --mode=u=rw,g=r,o=r -p client.wiz ${prefix}/share/wizards/client_wizard
-
-
-
- install --mode=a=r -p ./images/DNS.png ${prefix}/share/wizards/client_wizard/images
- install --mode=u=rwx,g=rx,o=rx -p scripts/*.sh ${prefix}/share/wizards/client_wizard/scripts
- install --mode=u=rw,g=r,o=r -p scripts/Clientconf.pm ${prefix}/share/wizards/client_wizard/scripts
-
+ mkdir -p --mode=u=rwx,g=rx,o=rx ${prefix}/$(PERL_VENDORLIB)/MDK/Wizard
+ install --mode=u=rw,g=r,o=r -p *.pm ${prefix}/$(PERL_VENDORLIB)/MDK/Wizard/
+ install --mode=a=r -p ./images/*.png ${prefix}/share/wizards/client_wizard/images
diff --git a/common/IFCFG.pm b/common/IFCFG.pm
new file mode 100644
index 00000000..e86128d1
--- /dev/null
+++ b/common/IFCFG.pm
@@ -0,0 +1,88 @@
+#!/usr/bin/perl
+
+# Interfaces Conf Parser
+
+# Copyright (C) 2002 MandrakeSoft Arnaud Desmons <adesmons@mandrakesoft.com>
+#
+# 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+package IFCFG;
+use strict;
+use lib qw(/usr/lib/libDrakX);
+use Data::Dumper;
+use MDK::Common;
+use network::network;
+
+#my $file = "/etc/sysconfig/network-scripts/drakconnect_conf";
+#!-f $file and die "no such $file";
+sub new {
+ my $self = {};
+
+ $ENV{PATH} = "";
+ my $ifconfig = `LC_ALL=C /sbin/ifconfig -a`;
+ my $device = 'NONE';
+ my @interfaces;
+ foreach (split('\n', $ifconfig)) {
+ my ($temp) = /(^eth[0-9]*:?[0-9]*).*/;
+ $device = $temp if defined $temp;
+ my ($ip, $bcast, $netmask) = /\s*inet addr:([0-9\.]*)\s*Bcast:([0-9\.]*)\s*Mask:([0-9\.]*).*/;
+ if (defined $ip && defined $bcast && defined $netmask) {
+ $self->{itf}{$device} = {IPADDR => $ip, BROADCAST => $bcast, NETMASK => $netmask};
+ my %conf = getVarsFromSh("/etc/sysconfig/network-scripts/ifcfg-$device");
+ $self->{itf}{$device}{$_} = $conf{$_} foreach ('BOOTPROTO');
+ }
+ }
+ %{$self->{network}} = getVarsFromSh("/etc/sysconfig/network");
+ my $r = read_resolv_conf();
+ foreach my $k (keys %$r) {
+ $self->{network}{$k} ||= $r->{$k}
+ }
+ $self->{network}{HOSTNAME} ||= `/bin/hostname` and chomp $self->{network}{HOSTNAME};
+ ($self->{network}{DOMAINNAME}) = $self->{network}{HOSTNAME} =~ /\.(.*)/;
+ $self->{network}{DOMAINNAME} ||= `/bin/dnsdomainname` and chomp $self->{network}{DOMAINNAME};
+ bless $self;
+}
+
+sub is_dhcp {
+ my $self = shift;
+ my ($itf) = @_;
+
+ $itf ||= default_itf();
+ $self->{itf}{$itf}{BOOTPROTO} eq 'dhcp';
+}
+
+#- TODO : return the main interface
+sub default_itf {
+ "eth0";
+}
+
+sub itf_get {
+ my $self = shift;
+ my ($key, $itf) = @_;
+
+ $itf ||= default_itf;
+ exists $self->{itf}{$itf}{$key} or die "no $key field in $itf hash";
+ $self->{itf}{$itf}{$key}
+}
+
+sub network_get {
+ my $self = shift;
+ my ($key) = @_;
+
+ exists $self->{network}{$key} or die "no $key field in network hash";
+ $self->{network}{$key};
+}
+
+10;
diff --git a/common/Varspaceval.pm b/common/Varspaceval.pm
new file mode 100644
index 00000000..61a31cff
--- /dev/null
+++ b/common/Varspaceval.pm
@@ -0,0 +1,88 @@
+#!/usr/bin/perl -w
+
+# Author Philippe Hétroy, phetroy@mandrakesoft.com
+# $Id: Varspaceval.pm,v 1.1 2003-08-22 19:59:47 warly Exp $
+
+# Module for loding and committing informations in a VAR = value file type
+
+package Varspaceval;
+use lib('./');
+use strict;
+use Data::Dumper;
+
+
+# Get all useful content of the config file
+# Return a hash containg the key and the value
+# ATTENTION : in the conf file, an empty value is returnes as a spaced value (mandatory because of XML compatibility)
+sub get {
+ my $self = shift;
+ my $file = shift;
+ my %l;
+ local *F; open F, $file or return;
+ local $_;
+
+ while (<F>) {
+
+ my ($v, $val, $val2) =
+ /^\s* # leading space
+ (\w+)\s* # variable
+ (
+ "(.*)" # double-quoted text
+ | '(.*)' # single-quoted text
+ | [^'"\s]* # normal text
+ )
+ \s*$ # end of line
+ /x;
+ no warnings;
+ $l{$v} = defined $val2 ? $val2 : $val;
+ }
+
+ %l;
+}
+
+# Commits changes in conf files and ifconfig
+sub commit {
+ my $self = shift;
+ my ($file, $hash) = @_;
+ local *F;
+
+ my $output = "";
+ if (open(F, $file)) {
+ local $_;
+
+ while (<F>) {
+ my ($pre, $key, $eq, $val, $rest) = /(^\s*)(\w+)(\s*"*'*)([^'"\s]*)(.*)/x;
+
+ if (!defined $key) {
+ $output .= $_;
+ next;
+ };
+ next if (!exists $hash->{$key}); #Elt has been removed
+ no warnings;
+ $val = $hash->{$key};
+ delete $hash->{$key};
+ $output .= defined $val ? $pre . $key . $eq . $val . $rest . "\n" : $pre . $key . $eq . $val . $rest;
+# $output .= $pre . $key . $eq . $val . $rest . "\n";
+ }
+ #appending added parameters
+ foreach (keys %$hash) {
+ $output .= $_ . " " . $hash->{$_} . "\n";
+ }
+
+ } else { #the file does not exist
+ print STDERR "File $file will be created\n";
+ foreach (keys %$hash) {
+ $output .= defined $hash->{$_} ? $_ . "=" . $hash->{$_} . "\n" : $_ . "=\n";
+ }
+ }
+
+#print $output;
+#print "\n------------------\n";
+
+ # outputing the new conf
+ open(F, "> $file") or return;
+ print F $output;
+ close(F);
+}
+
+1;
diff --git a/common/Wizcommon.pm b/common/Wizcommon.pm
new file mode 100644
index 00000000..847f41f9
--- /dev/null
+++ b/common/Wizcommon.pm
@@ -0,0 +1,39 @@
+#!/usr/bin/perl
+
+# Interfaces Conf Parser
+
+# Copyright (C) 2003 Florent Villard <warly@mandrakesoft.com>
+#
+# 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+package Wizcommon;
+use strict;
+use MDK::Wizard::IFCFG;
+
+my $net;
+
+sub check_dhcp {
+ $net->is_dhcp() and return 'dhcp_warning';
+}
+
+sub new {
+ my ($class, $conf) = @_;
+ $net = new IFCFG;
+ bless {
+ net => $net,
+ }, $class;
+}
+
+1
diff --git a/data/Client.desktop.in b/data/Client.desktop.in
index fa56d0a7..0f0083ca 100644
--- a/data/Client.desktop.in
+++ b/data/Client.desktop.in
@@ -1,7 +1,7 @@
[Desktop Entry]
_Name=DNS Client
Icon=/usr/share/mcc/themes/default/server-mdk.png
-Exec=/usr/sbin/drakwizard /usr/share/wizards/client_wizard/client.wiz
+Exec=/usr/sbin/drakwizard Bind_client
Terminal=0
Type=Application
-Categories=System;X-Mandrake-ServerSettings \ No newline at end of file
+Categories=System;X-Mandrake-ServerSettings
diff --git a/data/DHCP.desktop.in b/data/DHCP.desktop.in
index de310bde..83d71186 100644
--- a/data/DHCP.desktop.in
+++ b/data/DHCP.desktop.in
@@ -1,7 +1,7 @@
[Desktop Entry]
_Name=DHCP
Icon=internet-mdk.png
-Exec=/usr/sbin/drakwizard /usr/share/wizards/dhcp_wizard/dhcp.wiz
+Exec=/usr/sbin/drakwizard Dhcp
Terminal=0
Type=Application
-Categories=System;X-Mandrake-ServerSettings \ No newline at end of file
+Categories=System;X-Mandrake-ServerSettings
diff --git a/data/DNS.desktop.in b/data/DNS.desktop.in
index a5e381ce..c0347ddd 100644
--- a/data/DNS.desktop.in
+++ b/data/DNS.desktop.in
@@ -1,7 +1,7 @@
[Desktop Entry]
_Name=DNS
Icon=/usr/share/mcc/themes/default/server-mdk.png
-Exec=/usr/sbin/drakwizard /usr/share/wizards/dns_wizard/dns.wiz
+Exec=/usr/sbin/drakwizard Bind
Terminal=0
Type=Application
-Categories=System;X-Mandrake-ServerSettings \ No newline at end of file
+Categories=System;X-Mandrake-ServerSettings
diff --git a/data/Time.desktop.in b/data/Time.desktop.in
index e2353284..6f8b11ac 100644
--- a/data/Time.desktop.in
+++ b/data/Time.desktop.in
@@ -1,7 +1,7 @@
[Desktop Entry]
_Name=Time
Icon=/usr/share/mcc/themes/default/time-mdk.png
-Exec=/usr/sbin/drakwizard /usr/share/wizards/time_wizard/time.wiz
+Exec=/usr/sbin/drakwizard Ntp
Terminal=0
Type=Application
-Categories=System;X-Mandrake-ServerSettings \ No newline at end of file
+Categories=System;X-Mandrake-ServerSettings
diff --git a/data/Web.desktop.in b/data/Web.desktop.in
index acc9cbcc..06f8c71a 100644
--- a/data/Web.desktop.in
+++ b/data/Web.desktop.in
@@ -1,7 +1,7 @@
[Desktop Entry]
_Name=Web
Icon=internet-mdk.png
-Exec=/usr/sbin/drakwizard /usr/share/wizards/web_wizard/web.wiz
+Exec=/usr/sbin/drakwizard Apache
Terminal=0
Type=Application
-Categories=System;X-Mandrake-ServerSettings \ No newline at end of file
+Categories=System;X-Mandrake-ServerSettings
diff --git a/data/ftp.desktop.in b/data/ftp.desktop.in
index 61b40835..c2bfd0cc 100644
--- a/data/ftp.desktop.in
+++ b/data/ftp.desktop.in
@@ -1,7 +1,7 @@
[Desktop Entry]
_Name=FTP
Icon=/usr/share/mcc/themes/default/ftp-mdk.png
-Exec=/usr/sbin/drakwizard /usr/share/wizards/ftp_wizard/ftp.wiz
+Exec=/usr/sbin/drakwizard Proftpd
Terminal=0
Type=Application
-Categories=System;X-Mandrake-ServerSettings \ No newline at end of file
+Categories=System;X-Mandrake-ServerSettings
diff --git a/data/news.desktop.in b/data/news.desktop.in
index b6a28167..3ab6d8dc 100644
--- a/data/news.desktop.in
+++ b/data/news.desktop.in
@@ -1,7 +1,7 @@
[Desktop Entry]
_Name=News
Icon=/usr/share/mcc/themes/default/news-mdk.png
-Exec=/usr/sbin/drakwizard /usr/share/wizards/news_wizard/news.wiz
+Exec=/usr/sbin/drakwizard Inn
Terminal=0
Type=Application
-Categories=System;X-Mandrake-ServerSettings \ No newline at end of file
+Categories=System;X-Mandrake-ServerSettings
diff --git a/data/postfix.desktop.in b/data/postfix.desktop.in
index c571dfd4..7ea90ffd 100644
--- a/data/postfix.desktop.in
+++ b/data/postfix.desktop.in
@@ -1,7 +1,7 @@
[Desktop Entry]
_Name=Postfix
Icon=/usr/share/mcc/themes/default/postfix-mdk.png
-Exec=/usr/sbin/drakwizard /usr/share/wizards/postfix_wizard/postfix.wiz
+Exec=/usr/sbin/drakwizard Postfix
Terminal=0
Type=Application
-Categories=System;X-Mandrake-ServerSettings \ No newline at end of file
+Categories=System;X-Mandrake-ServerSettings
diff --git a/data/proxy.desktop.in b/data/proxy.desktop.in
index 2067e241..aef3d049 100644
--- a/data/proxy.desktop.in
+++ b/data/proxy.desktop.in
@@ -1,7 +1,7 @@
[Desktop Entry]
_Name=Proxy
Icon=internet-mdk.png
-Exec=/usr/sbin/drakwizard /usr/share/wizards/proxy_wizard/proxy.wiz
+Exec=/usr/sbin/drakwizard Squid
Terminal=0
Type=Application
-Categories=System;X-Mandrake-ServerSettings \ No newline at end of file
+Categories=System;X-Mandrake-ServerSettings
diff --git a/data/samba.desktop.in b/data/samba.desktop.in
index 1e8942ee..3fab77de 100644
--- a/data/samba.desktop.in
+++ b/data/samba.desktop.in
@@ -1,7 +1,7 @@
[Desktop Entry]
_Name=Samba
Icon=/usr/share/mcc/themes/default/diskdrake_samba.png
-Exec=/usr/sbin/drakwizard /usr/share/wizards/samba_wizard/samba.wiz
+Exec=/usr/sbin/drakwizard Samba
Terminal=0
Type=Application
-Categories=System;X-Mandrake-ServerSettings \ No newline at end of file
+Categories=System;X-Mandrake-ServerSettings
diff --git a/dhcp_wizard/Dhcp.pm b/dhcp_wizard/Dhcp.pm
new file mode 100755
index 00000000..831c5a38
--- /dev/null
+++ b/dhcp_wizard/Dhcp.pm
@@ -0,0 +1,230 @@
+#!/usr/bin/perl
+
+# Drakwizard
+
+# Copyright (C) 2002 Arnaud Desmons <adesmons@mandrakesoft.com>
+# 2003 Florent Villard <warly@mandrakesoft.com>
+#
+# 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+package Dhcp;
+use strict;
+
+use standalone;
+use interactive;
+use common;
+use MDK::Wizard::Wizcommon;
+
+my $wiz = new Wizcommon;
+my $wiz_ip_server = $wiz->{net}->itf_get("IPADDR");
+my $d = "$4" if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
+my $s = "$1.$2.$3" if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
+
+my $o = {
+ name => N('DHCP Wizard'),
+ var => {
+ ip1 => '',
+ ip2 => ''
+ },
+ needed_rpm => [ 'dhcp-server' ]
+ };
+
+$o->{pages} = {
+ welcome => {
+ name => N('DHCP Wizard') . "\n\n\n" . N('DHCP is a service that automatically assigns networking addresses to your workstations.') . "\n\n\n" . N('This wizard will help you configuring the DHCP services of your server.'),
+ post => sub { $wiz->check_dhcp },
+ no_back => 1,
+ next => 'ip_range'
+ },
+ ip_range => {
+ name => N('Range of addresses used by dhcp') . "\n\n\n" . N('Select the range of addresses assigned to the workstations by the DHCP service; unless you have special needs, you can safely accept the proposed values.'),
+ pre => sub {
+ $o->{var}{ip1} ||= compute_range();
+ $o->{var}{ip2} ||= compute_range2()
+ },
+ post => \&check,
+ data => [
+ { label => '' },
+ { label => N('Lowest IP Address:'), val => \$o->{var}{ip1} },
+ { label => N('Highest IP Address:'), val => \$o->{var}{ip2} },
+ ],
+ next => 'summary'
+ },
+ dhcp_warning => {
+ name => N('Warning'),
+ data => [ { label => N('You are in dhcp, server may not work with your configuration.') } ],
+ next => 'ip_range'
+ },
+ ip_range_error => {
+ name => N('Error'),
+ data => [ { label => N('The IP range specified is not correct.') } ],
+ next => 'ip_range'
+ },
+ ip_range_warning => {
+ name => N('Warning'),
+ data => [ { label => N('The IP range specified is not in server address range.') } ],
+ next => 'summary'
+ },
+ server_in_range => {
+ name => N('Error'),
+ data => [ { label => N('The IP of the server must not be in range.') } ],
+ next => 'ip_range'
+ },
+ summary => {
+ name => N('Configuring the DHCP Server') . "\n\n" . N('The wizard collected the following parameters needed to configure your DHCP service:'),
+ data => [
+ { label => N('Lowest IP Address:'), fixed_val => \$o->{var}{ip1} },
+ { label => '' },
+ { label => N('Highest IP Address:'), fixed_val => \$o->{var}{ip2} },
+ ],
+ post => \&do_it,
+ next => 'end'
+ },
+ end => {
+ name => N('Congratulations'),
+ data => [ { label => N('The wizard successfully configured the DHCP services of your server.') } ],
+ end => 1,
+ next => 0
+ },
+};
+
+sub compute_range {
+ my $n;
+ if ($d <= 64) { $n = "65" }
+ elsif ($d <= 128) { $n = "129" }
+ else { $n = "1"}
+ "$s.$n";
+}
+
+sub compute_range2 {
+ my $n;
+ if ($d <= 128) { $n = "254" }
+ elsif ($d > 192) { $n = "192" }
+ else { $n = "128"}
+ "$s.$n";
+}
+
+sub check {
+ my $r1_trunc = "$1.$2.$3" if $o->{var}{ip1} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
+ my $r2_trunc = "$1.$2.$3" if $o->{var}{ip2} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
+ my $d1 = "$4" if $o->{var}{ip1} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
+ my $d2 = "$4" if $o->{var}{ip2} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
+ my $s_trunc = "$1.$2.$3" if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
+ my $ds = "$4" if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
+ if (!$r1_trunc) { standalone::explanations("DHCP wizard : incorrect adress range 1"); return 'ip_range_error'}
+ if (!$r2_trunc) { standalone::explanations("DHCP wizard : incorrect adress range 2"); return 'ip_range_error'}
+ if ($r1_trunc ne $s_trunc || $r2_trunc ne $s_trunc) {
+ standalone::explanations("DHCP wizard : range not in network");
+ return 'ip_range_warning';
+ }
+ if (!$d1 || !$d2 || $d1 > $d2) { standalone::explanations("DHCP wizard : bad range"); return 'ip_range_error'}
+ if ($ds >= $d1 && $ds <= $d2) { standalone::explanations("DHCP wizard : server in range"); return 'server_in_range'}
+ 0
+}
+
+sub do_it {
+ $::DEBUG and return;
+ my $wiz_domain_name = $wiz->{net}->network_get("DOMAINNAME");
+ my $wiz_host_name = $wiz->{net}->network_get("HOSTNAME");
+ my $wiz_gateway = $wiz->{net}->network_get("GATEWAY");
+ my $wiz_dns = $wiz->{net}->network_get("dnsServer");
+ if ($wiz_dns eq '127.0.0.1') {
+ $wiz_dns = $wiz_ip_server
+ }
+ if (!$wiz_gateway) {
+ my $t = `LC_ALL=C /sbin/ip route list scope global`;
+ ($wiz_gateway) = $t =~ /default via (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) dev/;
+ }
+ my $wiz_ip_net = "$1.$2.$3.0" if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
+ my $err = check();
+ return $err if $err != 10;
+ my $wiz_ip_range1 = $o->{var}{ip1};
+ my $wiz_ip_range2 = $o->{var}{ip2};
+ my $wiz_ip_netmask = $wiz->{net}->itf_get("NETMASK");
+ my $wiz_device = $wiz->{net}->default_itf();
+# patch to rewrite when got new file about dhcp with INTERFACES value
+# currently, I put the device to configure as dhcp server
+# in /etc/sysconfig/dhcpd
+
+#[ -f /etc/sysconfig/dhcpd ] && cp -f /etc/sysconfig/dhcpd /var/tmp/wiz_bck/orig/dhcpd
+ my $file = "/etc/sysconfig/dhcpd";
+ -f $file and MDK::Common::cp_af($file, $file.".orig");
+
+ $file = "/etc/rc.d/init.d/dhcpd";
+# now patching etc/rc.d/init.d/dhcpd
+ standalone::explanations("now patching etc/rc.d/init.d/dhcpd");
+ if (!`grep INTERFACES $file`){
+ MDK::Common::append_to_file($file, "\nINTERFACES=$wiz_device");
+ MDK::Common::cp_af($file, $file . ".orig");
+ my $tmp = `/bin/mktemp /tmp/Dhcpconf.XXXXXX` or die "can't make a temp file: $!";
+ open(NEW, "> $tmp") or die "can't open $tmp: $!";
+ open(OLD, "< $file") or die "can't open default: $!";
+ while (<OLD>) {
+ if (m|daemon\s*/usr/sbin/dhcp|) {
+ print NEW "\tif [ -f /etc/sysconfig/dhcpd ]; then
+\t\t. /etc/sysconfig/dhcpd
+\t\tDEV=\$INTERFACES
+\tfi\n";
+ }
+ print NEW $_;
+ }
+ close(OLD);
+ close(NEW);
+ chomp($tmp);
+ system("mv $tmp $file");
+ }
+ $file = "/etc/dhcpd.conf";
+ -f $file and MDK::Common::cp_af($file, $file.".orig");
+ output($file, map {
+ s|__hname__|$wiz_host_name|g;
+ s|__dns__|$wiz_dns|g;
+ s|__net__|$wiz_ip_net|g;
+ s|__ip__|$wiz_ip_server|g;
+ s|__mask__|$wiz_ip_netmask|g;
+ s|__rng1__|$wiz_ip_range1|g;
+ s|__rng2__|$wiz_ip_range2|g;
+ s|__dname__|$wiz_domain_name|g;
+ s|__gateway__|$wiz_gateway|g;
+ $_;
+ } cat_ ("__WIZ_HOME__/dhcp_wizard/scripts/dhcpd.conf.default"));
+ standalone::explanations("$file: hname = $wiz_host_name, net = $wiz_ip_net, ip = $wiz_ip_server,
+mask = $wiz_ip_netmask, rng1 = $wiz_ip_range1, rng2 = $wiz_ip_range2, dname = $wiz_domain_name");
+ MDK::Common::touch("/var/dhcpd/dhcpd.leases");
+# modifying webmin config
+ $file="/etc/webmin/dhcpd/config";
+ if (-f $file) {
+ my %mdk = Vareqval->get($file);
+ $mdk{lease_file} = "/var/dhcpd/dhcpd.leases";
+ $mdk{interfaces} = $wiz_device;
+ standalone::explanations("$file: lease_file = $mdk{lease_file}, interfaces = $mdk{interfaces}");
+ Vareqval->commit($file, \%mdk);
+ !$ENV{wiz_authoritative} and output($file, map {
+ s|^\s*not\s*authoritative.*|\#$&|i;
+ $_
+ } cat_ ("/etc/dhcpd.conf"));
+ }
+
+ system("/etc/rc.d/init.d/dhcpd restart");
+ 10;
+}
+
+sub new {
+ my ($class, $conf) = @_;
+ bless {
+ o => $o,
+ }, $class;
+}
+
+1;
diff --git a/dhcp_wizard/scripts/Dhcpconf.pm b/dhcp_wizard/scripts/Dhcpconf.pm
index ea06660e..e75cd855 100644
--- a/dhcp_wizard/scripts/Dhcpconf.pm
+++ b/dhcp_wizard/scripts/Dhcpconf.pm
@@ -48,8 +48,8 @@ sub compute_range2 {
sub check {
# FIXME : see check_range.sh
- my $r1_trunc = "$1.$2.$3" if $ENV{wiz_ip_range1} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
- my $r2_trunc = "$1.$2.$3" if $ENV{wiz_ip_range2} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
+ my $r1_trunc = "$1.$2.$3" if $o->{var}{ip1} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
+ my $r2_trunc = "$1.$2.$3" if $o->{var}{ip2} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
my $d1 = "$4" if $ENV{wiz_ip_range1} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
my $d2 = "$4" if $ENV{wiz_ip_range2} =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
my $s_trunc = "$1.$2.$3" if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
diff --git a/drakwizard.pl b/drakwizard.pl
index fc2f734e..7e184f29 100755
--- a/drakwizard.pl
+++ b/drakwizard.pl
@@ -2,7 +2,7 @@
# Drakwizard
-# Copyright (C) 2002 MandrakeSoft Mael Dodin (mdodin@mandrakesoft.com)
+# Copyright (C) 2003 Florent Villard <warly@mandrakesoft.com>
#
# 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
@@ -20,9 +20,8 @@
use lib qw(/usr/lib/libDrakX);
use strict;
-use vars qw($Wizard_title $Wizard_pix_up $lib_script $perl_module %variable $in $rpm %chooser_hash $welcome $perl_module_name $verbose %description $summary $summary_func %disabled $current_page %bool);
+our ($Wizard_title, $Wizard_pix_up, $lib_script, $perl_module, %variable, $in, $rpm, %chooser_hash, $welcome, $perl_module_name, $verbose, %description, $summary, $summary_func, %disabled, $current_page, %bool);
-use XML::Parser;
use standalone;
use interactive;
use common;
@@ -30,106 +29,92 @@ use common;
#- I18N.
push @::textdomains, 'drakwizard';
+$::DEBUG = 1;
$::isWizard = 1;
-my $in = 'interactive'->vnew('su', 'default');
-$::direct = /-direct/;
$::Wizard_no_previous = 1;
$::Wizard_title = "Drakwizard";
+$::Wiz_dir = '__WIZ_HOME__';
+my $in = 'interactive'->vnew('/bin/su', 'default');
my $standalone = 1;
-# ! -r '/etc/sysconfig/network-scripts/drakconnect_conf' &&
-# ( -r '/etc/sysconfig/network-scripts/draknet_conf' ||
-# die "no drakconnect conf file found, install drakconnect and try again") &&
-# MDK::Common::cp_af('/etc/sysconfig/network-scripts/draknet_conf',
-# '/etc/sysconfig/network-scripts/drakconnect_conf');
-
-if (!defined($ARGV[0])) {
- my $prefix = "__WIZ_HOME__";
- my %wiz = (
- 1 => [$prefix."web_wizard/web.wiz", "Apache"],
- 2 => [$prefix."dhcp_wizard/dhcp.wiz", "Dhcp"],
- 3 => [$prefix."dns_wizard/dns.wiz", "Dns (configuration)"],
- 4 => [$prefix."client_wizard/client.wiz", "Dns (add client)"],
- 5 => [$prefix."news_wizard/news.wiz", "News"],
- 6 => [$prefix."nfs_wizard/nfs.wiz", "NFS"],
- 7 => [$prefix."postfix_wizard/postfix.wiz", "Postfix"],
- 8 => [$prefix."ftp_wizard/ftp.wiz", "Proftpd"],
- 9 => [$prefix."samba_wizard/samba.wiz", "Samba"],
- 10 => [$prefix."proxy_wizard/proxy.wiz", "Squid"],
- 11 => [$prefix."time_wizard/time.wiz", "Time"],
- 12 => [$prefix."web_wizard/apache2.wiz", "Apache2"]
- );
+my %wiz = (
+ apache => ['Apache', "Apache web server"],
+ dhcp => ['Dhcp', "Dhcp server"],
+ bind => ['Bind', "Dns (configuration)"],
+ bind_client => ['Bind_client', "Dns (add client)"],
+ inn => ['Inn', "News server"],
+ nfs => ['Nfs', "NFS server"],
+ postfix => ['Postfix', "Mail server"],
+ proftpd => ['Proftpd', "Ftp server"],
+ samba => ['Samba', "Samba server"],
+ squid => ['Squid', "Proxy"],
+ ntp => ['Ntp', "Time server"],
+ apache2 => ['Apache', "Apache2 web server", { ver => 2 }]
+ );
+
+if (!defined($wiz{$ARGV[0]})) {
$in->ask_from(
N("Drakwizard wizard selection"),
N("Please select a wizard"),
- [{ val => \$ARGV[0], list => [sort { $wiz{$a}[2] cmp $wiz{$b}[2] } keys %wiz], format => sub { $wiz{$_[0]}[1] }}]
+ [{ val => \$ARGV[0], list => [sort { $wiz{$a}[1] cmp $wiz{$b}[1] } keys %wiz], format => sub { $wiz{$_[0]}[1] }}]
);
- $ARGV[0] = $wiz{$ARGV[0]}[0];
-}
-
-my $o = [];
-my $o2 = [];
-my $xmltree = XML::Parser->new(Style => 'Tree')->parsefile($ARGV[0]);
-
-local $_ = join '', @ARGV;
- if (/-debug/) {
- $::verbose = 1;
+ push @ARGV, @{$wiz{$ARGV[0]}}[0,2];
}
-$::isWizard = 1;
+require "MDK/Wizard/$wiz{$ARGV[0]}[0].pm";
-if (/-summary/) {
- $::isSummary = 1;
- get_parameter($o2, $xmltree);
+my ($wiz, $err) = $wiz{$ARGV[0]}[0]->new($wiz{$ARGV[0]}[2]);
+if ($err) {
$::Wizard_finished = 1;
- get_summary($o2, $xmltree);
- is_disabled_summary($_[0], $o2->[0]);
- my $data = map_freetext($summary->{freetext});
- # workaround to get get the scrollbar
- while ($::isSummary--) {
- push @$data, '';
- }
-
- if ($in->ask_from(translate("summary"), translate($summary->{info}), $data)) {
- foreach (@{$summary->{freetext}}) {
- if ($_->{main_order} eq 'bool') {
- $ENV{$variable{$_->{variableName}}} = $ENV{$variable{$_->{variableName}}} ? 1 : 0;
- $description{$ENV{$variable{$_->{variableName}}}} = $ENV{$variable{$_->{variableName}}} ? N("enabled") : N("disabled");
- }
- elsif ($_->{main_order} eq 'combo') {
- $ENV{$variable{$_->{variableName}}} = $chooser_hash{$ENV{$variable{$_->{variableName}}}};
- }
- }
- $::{$perl_module_name."::"}{"$summary_func"}->();
- }
-}
-else {
- get_parameter($o, $xmltree);
- if (!$::verbose) {
- no warnings;
- navigation($o, $o->[0]);
- }
- else { navigation($o, $o->[0]) };
+ $in->ask_okcancel("error", N($err));
+ $in->exit;
}
-$in->exit;
+wizard($wiz->{o});
-sub member { my $e = shift; foreach (@_) { $e eq $_ and return 1 } 0 }
+$in->exit;
-sub xml_text {
- $_[0] =~ s/\\\'/\'/g;
- $_[0] =~ s/\\q/\"/g;
- $_[0] =~ s/\\a/\&/g;
- $_[0] =~ s/\\n/\n/g;
- $_[0];
+sub wizard {
+ my ($o) = @_;
+ my $page = $o->{pages}{welcome};
+ $::Wizard_title = $o->{name};
+ my $next = 'welcome';
+ my @steps;
+ check_rpm($o->{needed_rpm}) if $o->{needed_rpm};
+ while (1) {
+ undef $::Wizard_no_previous;
+ undef $::Wizard_no_cancel;
+ $::Wizard_no_previous = $page->{no_back};
+ $::Wizard_finished = $page->{end};
+ $::Wizard_no_cancel = $page->{no_cancel} || $page->{end};
+ defined $page->{pre} and $page->{pre}();
+ # FIXME or the displaying fails
+ my $data = defined $page->{data} ? ref $page->{data} ? $page->{data} : [ { label => '' } ] : [ { label => '' } ];
+ my $data2;
+ foreach my $d (@$data) {
+ $d->{fixed_val} and $d->{val} = ${$d->{fixed_val}};
+ push @{$data2}, $d
+ }
+ my $a = $in->ask_from($o->{name}, $page->{name}, $data2);
+ if ($a) {
+ push @steps, $next;
+ $next = defined $page->{post} ? $page->{post}() : 0;
+ defined $o->{pages}{$next} or $next = $page->{next};
+ } else {
+ $next = pop @steps
+ }
+ $next or return;
+ $page = $o->{pages}{$next}
+ }
}
-sub load_wizard {
- ($Wizard_title, $lib_script, $perl_module, $rpm, $Wizard_pix_up, $summary_func) = @_;
- if ($rpm) {
+sub check_rpm {
+ my ($rpms) = @_;
+ foreach my $rpm (@$rpms) {
if (!$in->do_pkgs->is_installed($rpm)) {
if ($in->ask_okcancel("error", N("%s is not installed\nClick \"Next\" to install or \"Cancel\" to quit", c::from_utf8($rpm)))) {
- if (!$in->do_pkgs->install($rpm eq 'bind' ? 'bind-9' : $rpm)) {
+ $::DEBUG and next;
+ if (!$in->do_pkgs->install($rpm)) {
$::Wizard_finished = 1;
$in->ask_okcancel("error", N("installation failed"));
$in->exit;
@@ -138,363 +123,4 @@ sub load_wizard {
else { $in->exit }
}
}
- if ($perl_module) {
- ($::perl_module_name) = ($perl_module =~ /.*\/(.*)\.pm/);
- require $perl_module;
- }
-}
-
-sub map_freetext {
- my @liste;
- my $valeur;
-
- my @data = map {
- my $str = $_->{variableName};
- my $page = $_;
-
- if ($_->{fillScript}) {
- $ENV{$variable{$_->{variableName}}} = `. $lib_script && $_->{fillScript}`;
- }
- if ($_->{main_order} eq 'entry') {
- if (!$ENV{$variable{$_->{variableName}}} && $_->{fillfunc}) {
- $ENV{$variable{$_->{variableName}}} = $::{$perl_module_name."::"}{"$_->{fillfunc}"}->();
- }
- { label => N($_->{helpText}),
- val => \$ENV{$variable{$_->{variableName}}}, type => $_->{main_order},
- disabled => $disabled{$_->{variableName}},
- help => $_->{help}}
- }
- elsif ($_->{main_order} eq 'field' && $_->{fillfunc}) {
- { label => N($_->{helpText}),
- val => $::{$perl_module_name."::"}{"$_->{fillfunc}"}->(), type => $_->{main_order},
- disabled => $disabled{$_->{variableName}},
- help => $_->{help}}
- }
- elsif ($_->{main_order} eq 'bool') {
- if (!$ENV{$variable{$_->{variableName}}} && $_->{fillfunc}) {
- $ENV{$variable{$_->{variableName}}} = $::{$perl_module_name."::"}{"$_->{fillfunc}"}->();
- }
- if ($_->{listfunc}) {
- my @checklist = $::{$perl_module_name."::"}{"$_->{listfunc}"}->();
- my $i = 21 - scalar @checklist;
- # workaround to get get the scrollbar
- if (!$::isSummary) {
- while ($i--) {
- push @checklist, '';
- }
- }
- else {
- while ($i--) {
- $::isSummary++;
- }
- }
- #
- map {
- if (length($_)) {
- $disabled{$str} = sub { callback($str)};
- { val => \$bool{$_},
- label => "",
- type => 'bool',
- text => "$_",
- help => "",
- disabled => $disabled{$str}
- }
- }
- } @checklist;
- }
- else {
- { val => \$ENV{$variable{$_->{variableName}}},
- label => "",
- type => $_->{main_order},
- text => translate($_->{helpText}),
- disabled => $disabled{$_->{variableName}},
- help => $_->{help} }
- }
- }
- elsif ($_->{main_order} eq 'combo') {
- if($_->{fillScript}){
- @liste = ();
- $valeur = `. $lib_script && $_->{fillScript}`;
- while( $valeur =~ /(.+)\n/g){
- push @liste, $1;
- $chooser_hash{$1} = $1;
- }
- }
- elsif ($_->{fillfunc}){
- @liste = $::{$perl_module_name."::"}{"$_->{fillfunc}"}->();
- }
- else {
- @liste = @{$_->{Option}};
- }
- { label => N($_->{helpText}),
- val => \$ENV{$variable{$_->{variableName}}},
- list => [@liste], type => $_->{main_order},
- disabled => $disabled{$_->{variableName}} }}
- elsif ($_->{main_order} eq 'field') {
- { val => $description{$ENV{$variable{$_->{variableName}}}} ?
- $description{$ENV{$variable{$_->{variableName}}}} :
- $ENV{$variable{$_->{variableName}}},
- label => $_->{helpText},
- help => $_->{help}} }
- } @{$_[0]};
- \@data;
-}
-
-sub get_parameter {
- my ($o, $tree, $tag ,$page) = @_;
-
- foreach my $leaf (@$tree) {
- if (ref($leaf) eq 'ARRAY') {
- $page = get_parameter($o, $leaf, $tag, $page);
- } elsif (ref($leaf) eq 'HASH') {
- my $common_freetext_chooser;
- my %actions = (
- Wizard => sub {
- load_wizard(@{$leaf}{qw(wizardTitle libScript perlModule rpm defaultImage)}) },
- Variable => sub {
- $variable{$leaf->{name}} = $leaf->{shellVariable};
- $ENV{$variable{$leaf->{name}}} = $leaf->{defaultValue};
- $disabled{$leaf->{name}} = sub { callback($leaf->{name})};
- },
- Page => sub {
- !$welcome and $welcome = $page;
- my $old_page = $page;
- push @$o, $page = { %$leaf };
- $old_page->{next_page} = $page;
- if ($leaf->{canBack} =~ /.*false.*/) { $page->{no_prev} = 1}
- if ($leaf->{canCancel} =~ /.*false.*/) { $page->{no_cancel} = 1}
- if ($leaf->{nextFinish} =~ /.*true.*/) { $page->{finish} = 1}
- },
- Target => sub {
- $page->{Target}->{jumpIndex}->{$leaf->{jumpIndex}} = $leaf->{targetName};
- },
- Info => sub {
- # This is to avoid monospaced text to be interpolated
- $leaf->{helpText} = translate($leaf->{helpText});
- if ($leaf->{fontName} eq "Monospaced") {
- chomp($leaf->{helpText});
- $leaf->{helpText} = $leaf->{helpText} ?
- "$leaf->{helpText}\n$leaf->{helpText}" : "$leaf->{helpText}\n";
- }
- $page->{info} = xml_text($leaf->{helpText} ?
- "$page->{info}\n$leaf->{helpText}" : "$page->{info}\n");
- #$page->{info} = c::from_utf8($page->{info});
- $page->{info} .= translate(`source $lib_script; $leaf->{fillScript}`) if
- ($leaf->{fillScript})
- },
- Freetext => $common_freetext_chooser = sub {
- my $main_order = ($tag eq 'Chooser') ? 'combo'
- : ($tag eq 'Boolean') ? 'bool'
- : ($leaf->{editable} eq 'true') ? 'entry'
- : 'field';
- push @{$page->{freetext}},
- {%$leaf, main_order => $main_order,
- help => xml_text($leaf->{help})} if $main_order ne 'hidden';
- },
- Chooser => \&$common_freetext_chooser,
- Boolean => \&$common_freetext_chooser,
- Option => sub {
- push @{${$page->{freetext}}[-1]->{Option}}, $leaf->{description};
- $chooser_hash{$leaf->{description}} = $leaf->{value};
- $description{$leaf->{value}} = $leaf->{description};
- $disabled{$leaf->{description}} = sub { callback($leaf->{description})};
- });
- $actions{$tag} and &{$actions{$tag}};
- }
- elsif($leaf=~ /\w\D/) {
- $tag = $leaf;
- }
- }
- $page;
-}
-
-sub find_page {
- my ($o, $name) = @_;
- $_->{name} eq $name and return $_ foreach @$o;
-}
-
-sub display {
- my ($o, $page) = @_;
- my $data;
-
- if ($page->{no_prev} || $page->{name} eq $welcome->{name}) {
- $::Wizard_no_previous = 1;
- }
- if ($page->{finish}) {
- $::Wizard_finished = 1;
- $::Wizard_no_cancel = 1;
- }
- if ($page->{nextFinish} eq 'true') {
- $::Wizard_no_previous = 1;
- $in->ask_okcancel(translate($page->{name}),
- translate($page->{info})); # or quit_global($in, 0);
- exit;
- }
- elsif (!$page->{freetext}) {
- $in->ask_okcancel(translate($page->{name}),
- translate($page->{info})) or navigation($o, $page->{old_page});
- }
- else {
- my $valeur;
- my @liste;
- if ($page->{executionLevel} eq 'NORMAL') {
- $data = map_freetext($page->{freetext});
- $in->ask_from($page->{name}, translate($page->{info}),
- $data) or navigation($o, $page->{old_page});
- foreach (@{$page->{freetext}}) {
- if ($_->{main_order} eq 'bool') {
- $ENV{$variable{$_->{variableName}}} = $ENV{$variable{$_->{variableName}}} ? 1 : 0;
- $description{$ENV{$variable{$_->{variableName}}}} = $ENV{$variable{$_->{variableName}}} ? N("enabled") : N("disabled");
- }
- elsif ($_->{main_order} eq 'combo') {
- $ENV{$variable{$_->{variableName}}} = $chooser_hash{$ENV{$variable{$_->{variableName}}}};
- }
- }
- }
- }
- undef $::Wizard_no_previous;
-}
-
-sub navigation {
- my ($o, $page, $previous_page) = @_;
- $page->{old_page} ||= $previous_page;
-
- $current_page = $page;
- display($o, $page);
- my ($next, $prev) = do {
- if (defined $perl_module_name && $page->{func}) {
- my @func_arg = split(/\s/, $page->{func});
- my $modStatus = $::{$perl_module_name."::"}{"$func_arg[0]"}->();
- if ($page->{Target}->{jumpIndex}) {
- find_page($o, $page->{Target}->{jumpIndex}->{int($modStatus)}), $page;
- }
- else {
- $page->{next_page}, $page->{old_page};
- }
- }
- elsif ($page->{jumpScript}) {
- system("source $lib_script ; $page->{jumpScript}");
- if ($page->{Target}->{jumpIndex}) {
- $? = $? >> 8;
- find_page($o, $page->{Target}->{jumpIndex}->{$?}), $page;
- }
- else {
- $page->{next_page}, $page;
- }
- }
- elsif ($page->{subWizard}) {
- my $sub_o = [];
- my $sub_xmltree = XML::Parser->new(Style => 'Tree')->parsefile($page->{subWizard});
- get_parameter($sub_o, $sub_xmltree);
- eval {navigation($sub_o, $sub_o->[0]); };
- $in->exit if $@ =~ /^wizcancel/;
- $page->{old_page}->{no_prev} = 1;
- $o->[0], $page, undef;
- }
- elsif ($page->{jumpPage}) {
- find_page($o, $page->{jumpPage}), $page;
- }
- else {
- $page->{next_page}, $page;
- }
- };
- navigation($o, $next, $prev);
-}
-
-sub is_disabled_summary {
- my ($widget, $page) = @_;
-
- if ($page->{is}) {
- my ($page_val, $page_arg) = split(/\s*?=\s*/, $page->{is});
- if ($page_val eq $widget) {
- foreach (@{$page->{freetext}}) {
- my ($val, $arg) = split(/\s*?=\s*/, $_->{is}) if ($_->{is});
- $disabled{$_->{variableName}} = defined $page_arg ? ($ENV{$variable{$page_val}} != $page_arg) : !$ENV{$variable{$page_val}};
- if ($_->{is} && !$disabled{$_->{variableName}}) {
- $disabled{$_->{variableName}} = defined $arg ? $ENV{$variable{$val}} != $arg : !$ENV{$variable{$val}};
- }
- }
- }
- }
- is_disabled_summary($widget, $page->{next_page}) if $page->{next_page};
-}
-
-# find in the page which widget to disable from "is" dependance key.
-sub is_disabled {
- my ($widget, $page) = @_;
- my $ret;
-
- foreach (@{$page->{freetext}}) {
- if ($_->{is}) {
- my ($val, $arg) = split(/\s*?=\s*/, $_->{is});
- $ret = defined $arg ? $ENV{$variable{$val}} != $arg : !$ENV{$variable{$val}};
- }
- $disabled{$_->{variableName}} = $ret;
- }
-}
-
-sub callback_common {
- return 1 if ($disabled{$_[0]} == 1);
- foreach (keys %variable) {
- my $str = $ENV{$variable{$_}};
- my $str2 = $_;
- foreach (keys %chooser_hash) {
- if ($str eq $_) {
- $ENV{$variable{$str2}} = $chooser_hash{$_};
- }
- }
- }
- 0;
-}
-
-sub callback_summary {
- return 1 if callback_common($_[0]);
- is_disabled_summary($_[0], $o2->[0]);
-}
-
-sub callback {
- return 1 if callback_common($_[0]);
- is_disabled($_[0], $current_page);
-}
-
-sub get_summary {
- my ($o, $tree, $tag, $page) = @_;
-
- foreach my $leaf (@$tree) {
- if (ref($leaf) eq 'ARRAY') {
- $page = get_summary($o, $leaf, $tag, $page);
- } elsif (ref($leaf) eq 'HASH') {
- my $common_freetext_chooser;
- my %actions = (
- Wizard => sub {
- load_wizard(@{$leaf}{
- qw(wizardTitle libScript perlModule rpm defaultImage summaryFunc)}) },
- Variable => sub {
- $variable{$leaf->{name}} = $leaf->{shellVariable};
- $ENV{$variable{$leaf->{name}}} = $leaf->{defaultValue};
- $disabled{$leaf->{name}} = sub { callback_summary($leaf->{name})};
- },
- Freetext => $common_freetext_chooser = sub {
- my $main_order = ($tag eq 'Chooser') ? 'combo'
- : ($tag eq 'Boolean') ? 'bool'
- : ($leaf->{editable} eq 'true') ? 'entry'
- : 'hidden';
- push @{$summary->{freetext}},
- {%$leaf, main_order => $main_order,
- help => xml_text($leaf->{help})} if $main_order ne 'hidden';
- },
- Chooser => \&$common_freetext_chooser,
- Boolean => \&$common_freetext_chooser,
- Option => sub {
- push @{${$summary->{freetext}}[-1]->{Option}}, $leaf->{description};
- $chooser_hash{$leaf->{description}} = $leaf->{value};
- $description{$leaf->{value}} = $leaf->{description};
- $disabled{$leaf->{description}} = sub {callback_summary($leaf->{description})};
- });
- $actions{$tag} and &{$actions{$tag}};
- } elsif ($leaf=~ /\w\D/){
- $tag = $leaf;
- }
- }
- $page;
}
diff --git a/drakwizard.spec b/drakwizard.spec
index c951d36e..de073d15 100644
--- a/drakwizard.spec
+++ b/drakwizard.spec
@@ -1,6 +1,6 @@
%define name drakwizard
-%define version 1.8
-%define release 2mdk
+%define version 2.0
+%define release 1mdk
Name: %{name}
Version: %{version}
@@ -45,12 +45,17 @@ rm -rf $RPM_BUILD_DIR/$RPM_PACKAGE_NAME
%files -f %{name}.lang
%defattr(-,root,root)
-%doc Wizard.dtd
%config(noreplace) %_sysconfdir/gnome-vfs-2.0/vfolders/*
%_sbindir/drakwizard
%_datadir/wizards*
+%{perl_vendorlib}/MDK/
%changelog
+* Fri Aug 22 2003 Warly <warly@mandrakesoft.com> 2.0-1mdk
+- remove all the XML/shell part, now it is just perl
+- everything should be broken
+- squid/proftpd/inn are not yet ported
+
* Fri Aug 08 2003 David Baudens <baudens@mandrakesoft.com> 1.8-2mdk
- Update banners
diff --git a/ftp_wizard/Proftpd.pm b/ftp_wizard/Proftpd.pm
new file mode 100755
index 00000000..fa1e13b9
--- /dev/null
+++ b/ftp_wizard/Proftpd.pm
@@ -0,0 +1,95 @@
+#!/usr/bin/perl
+
+# Drakwizard
+
+# Copyright (C) 2003 Florent Villard <warly@mandrakesoft.com>
+#
+# 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+package Proftpd;
+use lib qw(/usr/lib/libDrakX);
+use strict;
+
+use standalone;
+use interactive;
+use common;
+require "MDK/Wizard/IFCFG.pm";
+
+my $net = new IFCFG;
+
+my $o = {
+ name => 'configuration wizard',
+ var => {
+ ip1 => '',
+ ip2 => ''
+ }
+ };
+
+$o->{pages} = {
+ welcome => {
+ name => N('') . "\n\n" . N('') . "\n\n" . N(''),
+ no_back => 1,
+ next => 'ip_range'
+ },
+ confige => {
+ name => N('') . "\n\n" . N('') . "\n\n" . N(''),
+ pre => sub {
+ $o->{var}{ip1} ||= f1();
+ $o->{var}{ip2} ||= f2();
+ },
+ post => \&check,
+ data => [
+ { label => '' },
+ { label => N(''), val => \$o->{var}{ip1} },
+ { label => N(''), val => \$o->{var}{ip2} },
+ ],
+ next => 'summary'
+ },
+ warning => {
+ name => N('Warning.'),
+ data => [ { label => N('') } ],
+ next => 'summary'
+ },
+ error => {
+ name => N('Error.'),
+ data => [ { label => N('') } ],
+ next => 'config'
+ },
+ summary => {
+ name => N('') . "\n\n" . N('') . "\n\n" . N(''),
+ data => [
+ { label => N(''), type => 'field', val => \$o->{var}{ip1} },
+ { label => '' },
+ { label => N(''), type => 'field', val => \$o->{var}{ip2} },
+ ],
+ post => \&do_it,
+ next => 'end'
+ },
+ end => {
+ name => N('Congratulation'),
+ data => [ { label => N('') } ],
+ end => 1,
+ next => 0
+ },
+};
+
+sub new {
+ my ($class, $conf) = @_;
+ bless {
+ o => $o,
+ }, $class;
+}
+
+1;
diff --git a/news_wizard/Inn.pm b/news_wizard/Inn.pm
new file mode 100755
index 00000000..cc97e52d
--- /dev/null
+++ b/news_wizard/Inn.pm
@@ -0,0 +1,95 @@
+#!/usr/bin/perl
+
+# Drakwizard
+
+# Copyright (C) 2003 Florent Villard <warly@mandrakesoft.com>
+#
+# 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+package Inn;
+use lib qw(/usr/lib/libDrakX);
+use strict;
+
+use standalone;
+use interactive;
+use common;
+require "MDK/Wizard/IFCFG.pm";
+
+my $net = new IFCFG;
+
+my $o = {
+ name => 'configuration wizard',
+ var => {
+ ip1 => '',
+ ip2 => ''
+ }
+ };
+
+$o->{pages} = {
+ welcome => {
+ name => N('') . "\n\n" . N('') . "\n\n" . N(''),
+ no_back => 1,
+ next => 'ip_range'
+ },
+ confige => {
+ name => N('') . "\n\n" . N('') . "\n\n" . N(''),
+ pre => sub {
+ $o->{var}{ip1} ||= f1();
+ $o->{var}{ip2} ||= f2();
+ },
+ post => \&check,
+ data => [
+ { label => '' },
+ { label => N(''), val => \$o->{var}{ip1} },
+ { label => N(''), val => \$o->{var}{ip2} },
+ ],
+ next => 'summary'
+ },
+ warning => {
+ name => N('Warning.'),
+ data => [ { label => N('') } ],
+ next => 'summary'
+ },
+ error => {
+ name => N('Error.'),
+ data => [ { label => N('') } ],
+ next => 'config'
+ },
+ summary => {
+ name => N('') . "\n\n" . N('') . "\n\n" . N(''),
+ data => [
+ { label => N(''), type => 'field', val => \$o->{var}{ip1} },
+ { label => '' },
+ { label => N(''), type => 'field', val => \$o->{var}{ip2} },
+ ],
+ post => \&do_it,
+ next => 'end'
+ },
+ end => {
+ name => N('Congratulation'),
+ data => [ { label => N('') } ],
+ end => 1,
+ next => 0
+ },
+};
+
+sub new {
+ my ($class, $conf) = @_;
+ bless {
+ o => $o,
+ }, $class;
+}
+
+1;
diff --git a/postfix_wizard/Postfix.pm b/postfix_wizard/Postfix.pm
new file mode 100755
index 00000000..9b3c514a
--- /dev/null
+++ b/postfix_wizard/Postfix.pm
@@ -0,0 +1,187 @@
+#!/usr/bin/perl
+
+# Drakwizard
+
+# Copyright (C) 2002 Arnaud Desmons <adesmons@mandrakesoft.com>
+# 2003 Florent Villard <warly@mandrakesoft.com>
+#
+# 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+package Postfix;
+use strict;
+
+use standalone;
+use interactive;
+use common;
+use MDK::Wizard::Wizcommon;
+
+my $wiz = new Wizcommon;
+my $wiz_domain_name = $wiz->{net}->network_get("DOMAINNAME");
+my $wiz_host_name = $wiz->{net}->network_get("HOSTNAME");
+
+my $o = {
+ name => 'Postfix wizard',
+ var => {
+ wiz_mail_masquerade => '',
+ wiz_ext_mail_relay => ''
+ }
+ };
+
+$o->{pages} = {
+ welcome => {
+ name => N('Internet Mail Configuration Wizard') . "\n\n" . N('This wizard will help you configuring the Internet Mail services for your network.'),
+ no_back => 1,
+ next => 'config'
+ },
+ config => {
+ name => N('Outgoing Mail Address') . "\n\n" . N('You can select the kind of address that outgoing mail will show in the \qFrom:\q and \qReply-to\q field.') . "\n\n" . N('This should be chosen consistently with the address you use for incoming mail.'),
+ pre => sub {
+ $o->{var}{wiz_mail_masquerade} ||= get_mail_masquerade();
+ },
+ post => \&check_masquerade,
+ data => [
+ { label => '' },
+ { label => N('Mail Address:'), val => \$o->{var}{wiz_mail_masquerade} },
+ ],
+ next => 'isp'
+ },
+ warning => {
+ name => N('Warning:'),
+ data => [
+ { label => N('You entered an empty address for the mail gateway.') },
+ { label => N('') },
+ { label => N('Your choice can be accepted, but this will not allow you to send mail outside your local network. Press next to continue, or back to enter a value.') }
+ ],
+ next => 'summary'
+ },
+ masquerade_not_good => {
+ name => N('Error.'),
+ data => [ { label => N('Masquerade not good!') } ],
+ next => 'config'
+ },
+ isp => {
+ name => N('Internet Mail Gateway') . "\n\n" . N('Your server will send the outgoing through a mail gateway, that will take care of the final delivery.') . "\n\n" . N('Internet host names must be in the form \qhost.domain.domaintype\q; for example, if your provider is \qprovider.com\q, the internet mail server is usually \qsmtp.provider.com\q.'),
+ pre => sub {
+ $o->{var}{wiz_ext_mail_relay} ||= get_mail_relay();
+ },
+ post => \&check_relay,
+ data => [
+ { label => '' },
+ { label => N('Mail Server Name:'), val => \$o->{var}{wiz_ext_mail_relay} },
+ ],
+ next => 'summary'
+ },
+ summary => {
+ name => N('Configuring the Internet Mail') . "\n\n" . N('The wizard collected the following parameters needed to configure your Internet Mail Service:') . "\n\n" . N('To accept these values, and configure your server, click the Next button or use the Back button to correct them.'),
+ data => [
+ { label => N('Internet Mail Gateway'), fixed_val => \$o->{var}{wiz_ext_mail_relay} },
+ { label => '' },
+ { label => N('Form of the Address'), fixed_val => \$o->{var}{wiz_mail_masquerade} },
+ ],
+ post => \&do_it,
+ next => 'end'
+ },
+ end => {
+ name => N('Congratulation'),
+ data => [ { label => N('The wizard successfully configured your Internet Mail service of your server.') } ],
+ end => 1,
+ next => 0
+ },
+};
+
+sub new {
+ my ($class, $conf) = @_;
+ bless {
+ o => $o,
+ }, $class;
+}
+
+sub check_masquerade {
+ $o->{var}{wiz_mail_masquerade} or return 'masquerade_not_good';
+ $o->{var}{wiz_mail_masquerade} =~ /@(\S+)$/ or return 'masquerade_not_good';
+}
+
+sub check_relay {
+ $o->{var}{wiz_ext_mail_relay} or return 'warning';
+ $o->{var}{wiz_ext_mail_relay} =~ /(\S+)\.(\S+)$/ or return 'warning';
+}
+
+sub get_mail_masquerade {
+ my $login = `logname`;
+ my $relayhost = `/usr/sbin/postconf -h relayhost`;
+ chomp($relayhost);
+ ($relayhost) = $relayhost =~ /.*\.(.*\..*)/;
+ !length $relayhost and $relayhost = $wiz_domain_name;
+ chomp($login);
+ "$login\@$relayhost";
+}
+
+sub get_mail_relay {
+ my $relayhost = `/usr/sbin/postconf -h relayhost`;
+ chomp $relayhost;
+ !length $relayhost and $relayhost = "smtp.$wiz_domain_name";
+ $relayhost;
+}
+
+sub do_it {
+ $::DEBUG and return
+ my @conf = qw(/etc/postfix/aliases
+ /etc/postfix/canonical
+ /etc/postfix/main.cf
+ /etc/postfix/master.cf
+ /etc/postfix/virtual);
+ foreach (@conf) {
+ (-f $_) and MDK::Common::cp_af($_, $_.".orig");
+ }
+ @conf = ("myhostname = $wiz_host_name",
+ 'myorigin = $mydomain',
+ 'inet_interfaces = all',
+ 'mydestination = $myhostname, localhost.$mydomain',
+ 'masquerade_domains = $mydomain',
+ 'alias_maps = hash:/etc/postfix/aliases',
+ 'alias_database = hash:/etc/postfix/aliases',
+ 'virtual_maps = hash:/etc/postfix/virtual',
+ 'canonical_maps = hash:/etc/postfix/canonical',
+ "relayhost = $o->{var}{wiz_ext_mail_relay}"
+ );
+ foreach (@conf) {
+ system("/usr/sbin/postconf -e \'$_\'");
+ }
+ if (defined $o->{var}{wiz_ext_mail_relay}) {
+ my $file = "/etc/postfix/canonical";
+ my $canon = "\n\@$wiz_domain_name $o->{var}{wiz_mail_masquerade}";
+ my $t;
+ foreach (cat_($file)) {
+ if (/^\s*(?!\#)\s*\@$wiz_domain_name.*/) {
+ $t = $_;
+ last;
+ }
+ }
+ if ($t) { substInFile { s|$t|\#$&$canon|} $file }
+ else { append_to_file($file, $canon) }
+ }
+ system("/usr/sbin/postmap /etc/postfix/canonical");
+ system("/usr/sbin/postmap /etc/postfix/virtual");
+ system("/usr/sbin/postalias /etc/postfix/aliases");
+ system("/usr/sbin/postfix check");
+ if (services::is_service_running('postfix')) {
+ services::restart('postfix')
+ } else {
+ services::start('postfix')
+ }
+ services::is_service_running('xinetd') and services::restart('xinetd');
+}
+
+1;
diff --git a/proxy_wizard/Squid.pm b/proxy_wizard/Squid.pm
new file mode 100755
index 00000000..d20194a1
--- /dev/null
+++ b/proxy_wizard/Squid.pm
@@ -0,0 +1,95 @@
+#!/usr/bin/perl
+
+# Drakwizard
+
+# Copyright (C) 2003 Florent Villard <warly@mandrakesoft.com>
+#
+# 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+package Squid;
+use lib qw(/usr/lib/libDrakX);
+use strict;
+
+use standalone;
+use interactive;
+use common;
+require "MDK/Wizard/IFCFG.pm";
+
+my $net = new IFCFG;
+
+my $o = {
+ name => 'configuration wizard',
+ var => {
+ ip1 => '',
+ ip2 => ''
+ }
+ };
+
+$o->{pages} = {
+ welcome => {
+ name => N('') . "\n\n" . N('') . "\n\n" . N(''),
+ no_back => 1,
+ next => 'ip_range'
+ },
+ confige => {
+ name => N('') . "\n\n" . N('') . "\n\n" . N(''),
+ pre => sub {
+ $o->{var}{ip1} ||= f1();
+ $o->{var}{ip2} ||= f2();
+ },
+ post => \&check,
+ data => [
+ { label => '' },
+ { label => N(''), val => \$o->{var}{ip1} },
+ { label => N(''), val => \$o->{var}{ip2} },
+ ],
+ next => 'summary'
+ },
+ warning => {
+ name => N('Warning.'),
+ data => [ { label => N('') } ],
+ next => 'summary'
+ },
+ error => {
+ name => N('Error.'),
+ data => [ { label => N('') } ],
+ next => 'config'
+ },
+ summary => {
+ name => N('') . "\n\n" . N('') . "\n\n" . N(''),
+ data => [
+ { label => N(''), type => 'field', val => \$o->{var}{ip1} },
+ { label => '' },
+ { label => N(''), type => 'field', val => \$o->{var}{ip2} },
+ ],
+ post => \&do_it,
+ next => 'end'
+ },
+ end => {
+ name => N('Congratulation'),
+ data => [ { label => N('') } ],
+ end => 1,
+ next => 0
+ },
+};
+
+sub new {
+ my ($class, $conf) = @_;
+ bless {
+ o => $o,
+ }, $class;
+}
+
+1;
diff --git a/samba_wizard/Samba.pm b/samba_wizard/Samba.pm
new file mode 100755
index 00000000..ca7bbaa7
--- /dev/null
+++ b/samba_wizard/Samba.pm
@@ -0,0 +1,95 @@
+#!/usr/bin/perl
+
+# Drakwizard
+
+# Copyright (C) 2003 Florent Villard <warly@mandrakesoft.com>
+#
+# 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+package Samba;
+use lib qw(/usr/lib/libDrakX);
+use strict;
+
+use standalone;
+use interactive;
+use common;
+require "MDK/Wizard/IFCFG.pm";
+
+my $net = new IFCFG;
+
+my $o = {
+ name => 'configuration wizard',
+ var => {
+ ip1 => '',
+ ip2 => ''
+ }
+ };
+
+$o->{pages} = {
+ welcome => {
+ name => N('') . "\n\n" . N('') . "\n\n" . N(''),
+ no_back => 1,
+ next => 'ip_range'
+ },
+ confige => {
+ name => N('') . "\n\n" . N('') . "\n\n" . N(''),
+ pre => sub {
+ $o->{var}{ip1} ||= f1();
+ $o->{var}{ip2} ||= f2();
+ },
+ post => \&check,
+ data => [
+ { label => '' },
+ { label => N(''), val => \$o->{var}{ip1} },
+ { label => N(''), val => \$o->{var}{ip2} },
+ ],
+ next => 'summary'
+ },
+ warning => {
+ name => N('Warning.'),
+ data => [ { label => N('') } ],
+ next => 'summary'
+ },
+ error => {
+ name => N('Error.'),
+ data => [ { label => N('') } ],
+ next => 'config'
+ },
+ summary => {
+ name => N('') . "\n\n" . N('') . "\n\n" . N(''),
+ data => [
+ { label => N(''), type => 'field', val => \$o->{var}{ip1} },
+ { label => '' },
+ { label => N(''), type => 'field', val => \$o->{var}{ip2} },
+ ],
+ post => \&do_it,
+ next => 'end'
+ },
+ end => {
+ name => N('Congratulation'),
+ data => [ { label => N('') } ],
+ end => 1,
+ next => 0
+ },
+};
+
+sub new {
+ my ($class, $conf) = @_;
+ bless {
+ o => $o,
+ }, $class;
+}
+
+1;
diff --git a/web_wizard/Apache.pm b/web_wizard/Apache.pm
new file mode 100755
index 00000000..2585211b
--- /dev/null
+++ b/web_wizard/Apache.pm
@@ -0,0 +1,242 @@
+#!/usr/bin/perl
+
+# Drakwizard
+
+# Copyright (C) 2002 Arnaud Desmons <adesmons@mandrakesoft.com>
+# 2003 Florent Villard <warly@mandrakesoft.com>
+#
+# 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, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+package Apache;
+use lib qw(/usr/lib/libDrakX);
+use strict;
+
+use standalone;
+use interactive;
+use common;
+use MDK::Wizard::Wizcommon;
+use MDK::Wizard::Varspaceval;
+
+my $wiz = new Wizcommon;
+
+my $file;
+my $root;
+
+my $config;
+my $o = {
+ name => N('Web wizard'),
+ var => {
+ web_internal => '',
+ web_external => '',
+ user_mod => '',
+ user_dir => '',
+ shared_dir => ''
+ },
+ needed_rpm => [ ( $config->{ver} == 2 ? 'apache2' : 'apache') ]
+};
+
+$o->{pages} = {
+ welcome => {
+ name => N('Web Server Configuration Wizard') . "\n\n" . N('This wizard will help you configuring the Web Server for your network.'),
+ post => sub { $wiz->check_dhcp },
+ no_back => 1,
+ next => 'config'
+ },
+ config => {
+ name => N('Web Server') . "\n\n" . N('Your server can act as a Web Server toward your internal network (intranet) and as a Web Server for the Internet.') . "\n\n" . N('Select the kind of Web service you want to activate:') . "\n\n" . N('Don\'t check any box if you don\'t want to activate your Web Server.'),
+ data => [
+ { label => '' },
+ { text => N('Enable the Web Server for the Intranet'), type => 'bool', val => \$o->{var}{web_internal} },
+ { text => N('Enable the Web Server for the Internet'), type => 'bool', val => \$o->{var}{web_external} },
+ ],
+ next => 'ask_mod'
+ },
+ dhcp_warning => {
+ name => N('Warning.'),
+ data => [ { label => N('You are in dhcp, server may not work with your configuration.') } ],
+ next => 'summary'
+ },
+ ask_mod => {
+ name => N('Modules :') . "\n\n" . N('* User module : allows users to have a directory in their home directories available on your http server via http://www.yourserver.com/~user, you will be asked for the name of this directory afterward.'),
+ pre => sub { $o->{var}{user_mod} = is_last_user_mod()},
+ data => [
+ { label => '' },
+ { text => N('Allows users to get a directory in their homes directories
+available on your http server via http://www.yourserver.com/~user.'), type => 'bool', val => \$o->{var}{user_mod} },
+ ],
+ post => sub { return 'user_dir' if $o->{var}{user_mod} },
+ next => 'ask_dir'
+ },
+ user_dir => {
+ name => N('Type the name of the directory users should create in their homes (whitout ~/) to get it available via http://www.yourserver.com/~user'),
+ pre => sub { $o->{var}{user_dir} ||= 'public_html' },
+ data => [
+ { label => '' },
+ { label => N('user http sub-directory : ~/'), help => N('Type the name of the directory users should create in their homes (whitout ~/) to get it available via http://www.yourserver.com/~user'), val => \$o->{var}{user_dir} },
+ ],
+ next => 'ask_dir'
+ },
+ ask_dir => {
+ name => N('Type the path of the directory you want being the document root.'),
+ pre => sub { $o->{var}{shared_dir} ||= $root },
+ data => [
+ { label => '' },
+ { label => N('Document Root:'), val => \$o->{var}{shared_dir} },
+ ],
+ post => \&check_dir,
+ next => 'summary'
+ },
+ error_in_dir => {
+ name => N('Error.'),
+ data => [ { label => '' },
+ { label => N('The path you entered does not exist.') } ],
+ next => 'ask_dir'
+ },
+ error => {
+ name => N('Error.'),
+ data => [ { label => N('') } ],
+ next => 'config'
+ },
+ summary => {
+ name => N('Configuring the Web Server') . "\n\n" . N('The wizard collected the following parameters needed to configure your Web Server') . "\n\n" . N('To accept these values, and configure your server, click the Next button or use the Back button to correct them.'),
+ pre => sub {
+ $o->{var}{internal} = $o->{var}{web_internal} ? N("enabled") : N("disabled");
+ $o->{var}{external} = $o->{var}{web_external} ? N("enabled") : N("disabled")
+ },
+ data => [
+ { label => N('Intranet web server:'), fixed_val => \$o->{var}{internal} },
+ { label => '' },
+ { label => N('Internet web server:'), fixed_val => \$o->{var}{external} },
+ { label => '' },
+ { label => N('Document root:'), fixed_val => \$o->{var}{shared_dir} },
+ { label => '' },
+ { label => N('User directory:'), fixed_val => \$o->{var}{user_dir} },
+ ],
+ post => \&do_it,
+ next => 'end'
+ },
+ end => {
+ name => N('Congratulation'),
+ data => [
+ { label => '' },
+ { label => N('The wizard successfully configured your Intranet/Internet Web Server') } ],
+ end => 1,
+ next => 0
+ },
+};
+
+sub new {
+ my ($class, $conf) = @_;
+ $config = $conf;
+ $file = $config->{ver} == 2 ? "/etc/httpd/conf/httpd2.conf" : "/etc/httpd/conf/httpd.conf";
+ if (-f $file) {
+ open my $FH, $file or die "$! ($file)";
+ while (<$FH>) {
+ if (/^\s*\#?\s*DocumentRoot\s+(.*)/) {
+ close($FH);
+ $root = $1;
+ print "ROOT $root\n";
+ last;
+ }
+ }
+ close($FH);
+ } else {
+ return (0, N("%s does not exist.", $file))
+ }
+ bless {
+ o => $o,
+ }, $class;
+}
+
+sub check_dir {
+ -d $o->{var}{shared_dir} or return 'error_in_dir'
+}
+
+sub chg_docroot {
+ my $old;
+ substInFile {
+ s|(^\s*\#?\s*DocumentRoot\s*)(\S*).*|$1$o->{var}{shared_dir}| and $old ||=$2;
+ } $file;
+
+ substInFile {
+ s|^\s*<Directory\s*$old/?>|<Directory $o->{var}{shared_dir}>|;
+ } "/etc/httpd/conf/commonhttpd.conf" if $old;
+
+ substInFile {
+ s|^\s*<Directory\s*/var/www/html/?>|<Directory $o->{var}{shared_dir}>|;
+ } "/etc/httpd/conf/commonhttpd.conf";
+}
+
+sub is_user_mod {
+ if ($o->{var}{user_mod}) {
+ return 1;
+ }
+ $o->{var}{user_mod} = "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 ($o->{var}{user_mod}) {
+ substInFile {
+ s|(/home/\*/)$root(/?)|$1$o->{var}{user_dir}$2|g;
+ } "/etc/httpd/conf/commonhttpd.conf";
+ substInFile {
+ s|(\s*)UserDir\s*$root(/?)|$1UserDir $o->{var}{user_dir}$2|g;
+ s|(/home/\*/)$root(/?)|$1$o->{var}{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";
+ }
+}
+
+sub do_it {
+ $::DEBUG and return;
+ my $file = "/etc/httpd/conf/commonhttpd.conf";
+ my $that = "localhost";
+
+ if ($o->{var}{web_external} eq "1") {
+ $that = "all";
+ }
+ elsif ($o->{var}{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");
+}
+
+1;
diff --git a/web_wizard/scripts/Apache2conf.pm b/web_wizard/scripts/Apache2conf.pm
index b538fe74..94d284ce 100644
--- a/web_wizard/scripts/Apache2conf.pm
+++ b/web_wizard/scripts/Apache2conf.pm
@@ -15,6 +15,7 @@ sub check {
0;
}
+a
my $file = "/etc/httpd/conf/httpd2.conf";
my $root;