summaryrefslogtreecommitdiffstats
path: root/nfs_wizard
diff options
context:
space:
mode:
authorFlorent Villard <warly@mandriva.com>2003-11-05 09:44:50 +0000
committerFlorent Villard <warly@mandriva.com>2003-11-05 09:44:50 +0000
commit77f1ad96d339974fe8da213ed6ab7e6956e7409c (patch)
tree2e47c2161a2eef609e92f8dc53d2f3ea69e09cd3 /nfs_wizard
parent306951e28791b261f894a8b71255b4c45d105661 (diff)
downloaddrakwizard-77f1ad96d339974fe8da213ed6ab7e6956e7409c.tar
drakwizard-77f1ad96d339974fe8da213ed6ab7e6956e7409c.tar.gz
drakwizard-77f1ad96d339974fe8da213ed6ab7e6956e7409c.tar.bz2
drakwizard-77f1ad96d339974fe8da213ed6ab7e6956e7409c.tar.xz
drakwizard-77f1ad96d339974fe8da213ed6ab7e6956e7409c.zip
add forgotten modules
Diffstat (limited to 'nfs_wizard')
-rwxr-xr-xnfs_wizard/NFS.pm157
1 files changed, 157 insertions, 0 deletions
diff --git a/nfs_wizard/NFS.pm b/nfs_wizard/NFS.pm
new file mode 100755
index 00000000..dd898072
--- /dev/null
+++ b/nfs_wizard/NFS.pm
@@ -0,0 +1,157 @@
+#!/usr/bin/perl
+
+# Drakwizard
+
+# Copyright (C) 2002,2003 Mandrakesoft
+#
+# Authors: Arnaud Desmons <adesmons@mandrakesoft.com>
+# 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 MDK::Wizard::NFS;
+use strict;
+
+use common;
+use services;
+use MDK::Wizard::Wizcommon;
+
+my $wiz = new MDK::Wizard::Wizcommon;
+
+my $o = {
+ name => N('NFS Wizard'),
+ var => {
+ wiz_nfs_dir => '',
+ wiz_nfs_level => '',
+ wiz_netmask => ''
+ },
+ needed_rpm => [ 'nfs-utils' ],
+ defaultimage => "$ENV{__WIZ_HOME__}nfs_wizard/images/NFS.png"
+ };
+
+my %level = (
+ 1 => N('All - No access restriction'),
+ 2 => N('Local Network - access for local network (recommended)')
+);
+
+$o->{pages} = {
+ welcome => {
+ name => N('NFS Server Configuration Wizard') . "\n\n" . N('This wizard will help you configuring the NFS Server for your network.'),
+ no_back => 1,
+ next => 'nfs'
+ },
+ nfs => {
+ name => N('NFS Server'),
+ post => \&check,
+ data => [
+ { label => N('Directory:'), val => \$o->{var}{wiz_nfs_dir} },
+ ],
+ next => 'ask_level'
+ },
+ ask_level => {
+ name => N('Access Control') . "\n\n" . N('NFS can be restricted to a certain ip class') . "\n\n" . N('Choose the level that suits your needs. If you don\'t know, the Local Network level is usually the most appropriate. Beware that the All level may be not secure.'),
+ pre => sub {
+ $o->{var}{wiz_netmask} = network_mask() if !$o->{var}{wiz_netmask} || $o->{var}{wiz_netmask} eq '0.0.0.0/0.0.0.0'
+ },
+ data => [
+ { val => \$o->{var}{wiz_nfs_level}, list => [ keys %level ], format => sub { $level{$_[0]} } },
+ ],
+ post => \&chooser,
+ next => 'summary'
+ },
+ shownet => {
+ name => N('Grant access on local network') . "\n\n" . N('Access will be allowed for hosts on the network. Here is the information found about your current local network, you can modify it if needed.'),
+ data => [
+ { label => N('Authorized network:'), val => \$o->{var}{wiz_netmask} },
+ ],
+ next => 'summary'
+
+ },
+ error_dir => {
+ name => N('Error.') . "\n\n" . N('The path you entered does not exist.'),
+ ignore => 1,
+ next => 'nfs'
+ },
+ summary => {
+ name => N('The wizard collected the following parameters.'),
+ pre => sub {
+ $o->{var}{wiz_text_level} = $level{$o->{var}{wiz_nfs_level}};
+ $o->{var}{wiz_netmask} = $o->{var}{wiz_nfs_level} == 1 ? "0.0.0.0/0.0.0.0" : $o->{var}{wiz_netmask}
+ },
+ data => [
+ { label => N('Exported dir:'), fixed_val => \$o->{var}{wiz_nfs_dir} },
+ { label => N('Access :'), fixed_val => \$o->{var}{wiz_text_level} },
+ { label => N('Netmask :'), fixed_val => \$o->{var}{wiz_netmask} },
+ ],
+ post => \&do_it,
+ next => 'end'
+ },
+ end => {
+ name => N('Congratulations') . "\n\n" . N('The wizard successfully configured your NFS Server'),
+ end => 1,
+ next => 0
+},
+};
+
+sub new {
+ my ($class, $conf) = @_;
+ bless {
+ o => $o,
+ }, $class;
+}
+
+sub check {
+ -d $o->{var}{wiz_nfs_dir} or return 'error_dir'
+}
+
+sub network_mask {
+ my $wiz_ip_server = $wiz->{net}->itf_get("IPADDR");
+ my $mask = $wiz->{net}->itf_get("NETMASK");
+ $mask = $mask ? $mask : "255.255.255.0";
+ $wiz_ip_server = $wiz_ip_server ? $wiz_ip_server : "192.168.1.0";
+ "$1.$2.$3.0/$mask" if $wiz_ip_server =~ /(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
+}
+
+sub chooser {
+ $o->{var}{wiz_nfs_level} == 2 and 'shownet'
+}
+
+sub do_it {
+ $::testing and return;
+ my $line;
+ my $file = "/etc/exports";
+ chomp($o->{var}{wiz_nfs_dir});
+ -f $file and cp_af($file, $file.".orig");
+ if ($o->{var}{wiz_nfs_level} == 2) {
+ my $mask = $wiz->{net}->itf_get("NETMASK");
+ $line = "$o->{var}{wiz_nfs_dir} $o->{var}{wiz_netmask}(rw,no_root_squash,sync)\n";
+ }
+ else {
+ $line = "$o->{var}{wiz_nfs_dir} *(rw,no_root_squash,sync)\n";
+ }
+ my $t;
+ foreach (cat_($file)) {
+ if (/^(?!\#).*$o->{var}{wiz_nfs_dir}\s.*/) {
+ $t = $_;
+ last;
+ }
+ }
+ substInFile { s|^(?!\#).*$o->{var}{wiz_nfs_dir}\s.*|\#$&|} $file;
+ append_to_file($file, $line);
+ system("/usr/sbin/exportfs -a");
+ services::start('nfs') if services::is_service_running('nfs')
+}
+
+1;